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 7CBBE42850; Mon, 27 Mar 2023 18:35:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FB4741140; Mon, 27 Mar 2023 18:35:13 +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 D381D410D0 for ; Mon, 27 Mar 2023 18:35:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679934909; 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=gF0Icv7Yveyy/q7fNSpx82gt5pQiCRA19O4m29xIwA0=; b=W6gkodWAFKf+JtZEQKKkmY6r4gti0fN0tMRhhy54JSppv4PbQLRD8+9EZUbVcBZAErtBFB MfrTnP5FVljxlAdBBt/kzMFGBX0vFtYHGeP2XVHo17y4DpOuoZUrXE+bHGy6egF6ul2nwy kIaM1QTIffn79kf+quI35mKDBroyiBI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-235-HaMpdoAzMVOfTz8vCBqVTA-1; Mon, 27 Mar 2023 12:35:06 -0400 X-MC-Unique: HaMpdoAzMVOfTz8vCBqVTA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B186F3822DE2; Mon, 27 Mar 2023 16:35:05 +0000 (UTC) Received: from [10.39.208.21] (unknown [10.39.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C8F2243FBD; Mon, 27 Mar 2023 16:35:04 +0000 (UTC) Message-ID: <3a70ad5c-9b8c-a990-c184-c1e6d29c13ad@redhat.com> Date: Mon, 27 Mar 2023 18:35:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 To: Eelco Chaudron , Gowrishankar Muthukrishnan Cc: chenbo.xia@intel.com, dev@dpdk.org References: <167992139724.45323.17979512439014217881.stgit@ebuild.local> <4FB0405A-41E0-4CE2-B8B1-0974CD398956@redhat.com> From: Maxime Coquelin Subject: Re: [EXT] [PATCH] vhost: add device op to offload the interrupt kick In-Reply-To: <4FB0405A-41E0-4CE2-B8B1-0974CD398956@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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) { >>> + struct virtio_net *dev = get_device(vid); >>> + struct vhost_virtqueue *vq; >>> + >>> + if (!dev || queue_id >= VHOST_MAX_VRING) >>> + return; >>> + >>> + vq = dev->virtqueue[queue_id]; >>> + if (!vq) >>> + return; >>> + >>> + rte_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 structure, so I need the lock to read the vq->callfd, however, I can/should move 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? Maxime > >>> + if (vq->callfd >= 0) >>> + eventfd_write(vq->callfd, (eventfd_t)1); >>> + >>> + rte_spinlock_unlock(&vq->access_lock); >>> +} >>> + >> >> Thanks. >