From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BDB894285A; Tue, 28 Mar 2023 14:14:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E28540EDF; Tue, 28 Mar 2023 14:14:53 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 4090840156 for ; Tue, 28 Mar 2023 14:14:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680005691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oT8htCmEjnSFhWCMY/GxmiffJd1J+FOilcEYJwkjgO4=; b=aLhgm59llepeOIuZoAgE8BDzu7/AxcXYbxkdkYknmHUMVdhDIn+g7/IHr7A5P+y5CjVN8H yXQBKFxwcMi3PuvWj+/1HEBVEVNprnhgMMP76WHnjGfcuua2ZlG4avNKROOio8XPCfFpfp a3js8fKCeAZaNxITPZ7k7dNQe8qIvlA= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-ls7JRP2BNf2JyNP_v7Khqw-1; Tue, 28 Mar 2023 08:14:40 -0400 X-MC-Unique: ls7JRP2BNf2JyNP_v7Khqw-1 Received: by mail-ed1-f72.google.com with SMTP id a40-20020a509eab000000b005024c025bf4so4898911edf.14 for ; Tue, 28 Mar 2023 05:14:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680005679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rfIdRNDyldG3X7ydQqs6kDk3JZSQCkNrtKobzvrhL2o=; b=Qbb6QbepQ052jxp/y0mkP18jPu3TEbY985ufSLpG2nBh0d1BD2M0pPDUIwY+ZNhqDL R7vj4AjRjUDx1dUoiNSRGNoM5BpvzsnDsiOyHNqzG2UjpouwlbmK3ZzMPL+oeJhZANSt TpjANzBBr2/bmV29MD3GkqnLdg5Ctp5FL5+T6lrdwRJZiLSi2cXpzhDiGAapk103emUo suiC/jB0u9fihgTEzgwPzZWpz1vePKZybxoRFbZ4IVH1zEr2CSVDxWKYxU2w16hXsaoK 1XaXlt4dCNMz4gBsEBePtU32Fdxw18S8OHzaKylJpi92ojIwsOUe3rR9jVRiH9Z0ABNo kfug== X-Gm-Message-State: AAQBX9e9KOGssbsl/Vo71bFWdxb6kTT2IPuCRIdK6bZO0RftqC/Qm8aF tZBK0ROmWnQFwTYFQVIUTlGHXaXXa9cv6F2+DCk0Tr3XRt8WTmfGq+AXAouduzViJSwyREitkzf AV4s= X-Received: by 2002:a17:906:f88c:b0:93b:866:bafe with SMTP id lg12-20020a170906f88c00b0093b0866bafemr16561073ejb.56.1680005679718; Tue, 28 Mar 2023 05:14:39 -0700 (PDT) X-Google-Smtp-Source: AKy350b7D/pouZFTVUFeRK3+vbfsDZOZCPmCoPUVcuZKFkMlwC13EHiG12c3cronzhWu48USDcytWw== X-Received: by 2002:a17:906:f88c:b0:93b:866:bafe with SMTP id lg12-20020a170906f88c00b0093b0866bafemr16561051ejb.56.1680005679447; Tue, 28 Mar 2023 05:14:39 -0700 (PDT) Received: from [10.39.193.2] (5920ab7b.static.cust.trined.nl. [89.32.171.123]) by smtp.gmail.com with ESMTPSA id be8-20020a1709070a4800b0093f822321fesm4162962ejc.137.2023.03.28.05.14.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2023 05:14:38 -0700 (PDT) From: Eelco Chaudron To: Maxime Coquelin Cc: Gowrishankar Muthukrishnan , chenbo.xia@intel.com, dev@dpdk.org Subject: Re: [EXT] [PATCH] vhost: add device op to offload the interrupt kick Date: Tue, 28 Mar 2023 14:14:37 +0200 X-Mailer: MailMate (1.14r5961) Message-ID: <55E22CA3-F1EC-47CC-8E8B-B856F9E064D5@redhat.com> In-Reply-To: <3a70ad5c-9b8c-a990-c184-c1e6d29c13ad@redhat.com> References: <167992139724.45323.17979512439014217881.stgit@ebuild.local> <4FB0405A-41E0-4CE2-B8B1-0974CD398956@redhat.com> <3a70ad5c-9b8c-a990-c184-c1e6d29c13ad@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 27 Mar 2023, at 18:35, Maxime Coquelin wrote: > On 3/27/23 18:04, Eelco Chaudron wrote: >> >> >> On 27 Mar 2023, at 17:16, Gowrishankar Muthukrishnan wrote: >> >>> Hi Eelco, >>> >>>> +void >>>> +rte_vhost_notify_guest(int vid, uint16_t queue_id) { >>>> +=09struct virtio_net *dev =3D get_device(vid); >>>> +=09struct vhost_virtqueue *vq; >>>> + >>>> +=09if (!dev || queue_id >=3D VHOST_MAX_VRING) >>>> +=09=09return; >>>> + >>>> +=09vq =3D dev->virtqueue[queue_id]; >>>> +=09if (!vq) >>>> +=09=09return; >>>> + >>>> +=09rte_spinlock_lock(&vq->access_lock); >>>> + >>> >>> Is spin lock needed here before system call ? >> >> I assumed access_lock is protecting all the following fields in this str= ucture, so I need the lock to read the vq->callfd, however, I can/should mo= ve the eventfd_write outside of the lock. > > The FD might be closed between the check and the call to eventfd_write > though, but I agree this is not optimal to call the eventfd_write under > the spinlock in your case, as you will block the pmd thread if it tries > to enqueue/dequeue packets on this queue, defeating the purpose of this > patch. > > Maybe the solution is to change to read-write locks for the access_lock > spinlock. The datapath (rte_vhost_enqueue_burst/rte_vhost_dequeue_burst) > and this API would use the read version, meaning they won't lock each > other, and the control path (lib/vhost/vhost_user.c) will use the write > version. > > Does that make sense? Yes, this makes sense, let me investigate this and get back. >>>> +=09if (vq->callfd >=3D 0) >>>> +=09=09eventfd_write(vq->callfd, (eventfd_t)1); >>>> + >>>> +=09rte_spinlock_unlock(&vq->access_lock); >>>> +} >>>> + >>> >>> Thanks. >>