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 95066A057B; Wed, 19 Oct 2022 07:27:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7E64B4069C; Wed, 19 Oct 2022 07:27:21 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 7656640041 for ; Wed, 19 Oct 2022 07:27:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666157239; x=1697693239; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=dzEq8ttcp0IZh8sN3f2ZIud1S6fqOub6ypeOfuDJisw=; b=LB0turAiDp3cQ1BquhK2f6MFKKRXl2MLFL49JFqKJip2/G9xV/htb4Ah aLbGR94C3/GeGs8RAHylVM7IsPDqqMzD0BGGwdsPYPPJsz3YYyGHw8Qcb JpHYmY/SpHvLoKtW96Eedr5GNer75E5c+e6XTElhPHsAcRmy376ydHh9T QZ4enyi7UaqooO4llbCibmm67aWCxgngmNr0wNBRavtZMsBBg92xxaD1r K9DY1lM4PLS+7hgE8nVlaINLiZ/d2VIwEbxopv68vbERvXT+Ut/BFBG59 2irGYDAfjDUhAmOh9Jthmd1YTTfcHMsDN1HvyjutF4qNrrQgydpcDmbAY w==; X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="293705714" X-IronPort-AV: E=Sophos;i="5.95,195,1661842800"; d="scan'208";a="293705714" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 22:27:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="660164190" X-IronPort-AV: E=Sophos;i="5.95,195,1661842800"; d="scan'208";a="660164190" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga008.jf.intel.com with ESMTP; 18 Oct 2022 22:27:18 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 22:27:17 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 22:27:16 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 18 Oct 2022 22:27:16 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.175) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 18 Oct 2022 22:27:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R2MC7bSuH98c4e/gmNID2M4Z5fApPVb3y0lCyeONkWjjUSkwc6K96AMUTF6RcF04JX21CE4q2CSvkZBiDpvEZGlf3JvYBYH040uwjYjFvKQxfBtGwnU8wg+XHy6cIfAJemG5eCckQmBCilt/mISx66PErc1VEH4Eb8dF2RX+aEfKNGothIqF0qErv/+W8xXxj7Vl62gBr8GVsVzNWW3xCZNPFaAfM2YyBca3Ja/+EzKTqp6h10PLbaGxUm2Ez/yQOL4G/e8hQBrmjqkoHXrVlDAf3vRqcd3pwkZUrCI3S0Ah3yTJbpprW1lVP3k5BhC9fABCTRGPxWcXfVOWMyhF+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RHBt/Nf7OuZ+Nb1sfyUhiABo8aizyJvdsmlAXXWezDg=; b=VzJedeikbGnF6Q4oOdr/bPjCCi33mYoKW4bxxtLl/XjJQ5KEOfJ26uSAAG5aMwFtZyC5vsqpoVWgUhSk58mlVg2iE05FvS8ecIB0jffpQ2lbcE5a0/DRlFlNOp/dN5S3uH9MoMw3IjOrMIqt8o4uSkkTvDflz5kZZ8/gsMBfFPF0qoeUkbPr/+qA/PoPUsVJAJ253jRU2Jpa3vsjqfTd5htbRpD0SoQrlt0lDpuR60lMet/PDmKfj1cxxgQRnPdieAAsJXKQLSsOQWj+mYZBOxeGTrKNb0SY3sHViI7MEwe0YMKgs4EZbHugUJhETBimvEmAXvVRej67KLt+N2z4lA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by IA0PR11MB7282.namprd11.prod.outlook.com (2603:10b6:208:43a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Wed, 19 Oct 2022 05:27:15 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::39bf:57b1:4824:d40d]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::39bf:57b1:4824:d40d%6]) with mapi id 15.20.5723.033; Wed, 19 Oct 2022 05:27:14 +0000 From: "Xia, Chenbo" To: "Liu, Changpeng" , "dev@dpdk.org" CC: Maxime Coquelin , David Marchand Subject: RE: [PATCH v4] vhost: add new `rte_vhost_vring_call_nonblock` API Thread-Topic: [PATCH v4] vhost: add new `rte_vhost_vring_call_nonblock` API Thread-Index: AQHY4fzejiFRhEqWekinGmHgPO9FA64VMtWA Date: Wed, 19 Oct 2022 05:27:14 +0000 Message-ID: References: <20221017071457.28589-1-changpeng.liu@intel.com> <20221017074817.28889-1-changpeng.liu@intel.com> In-Reply-To: <20221017074817.28889-1-changpeng.liu@intel.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3504:EE_|IA0PR11MB7282:EE_ x-ms-office365-filtering-correlation-id: 3b643595-afd0-427f-0581-08dab19294ea x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +oZdZAtjewiDxNhQ7gXroxEx8dYlipSXzpHUSZOXCea1txRX0PDUQoWmSAdyWwjpN1SdRxaQsTQY9SBl3XFNLFS90bNwC6ztPoLJDt/bVIM9U9vjjRiS3+cNiLMPXghUdsGNqoKNpPzM/p7qeG2qbEQ8gOYBevI/SKpIye9aNqCu0puBPV0bRsB7GWElZjjVwO54vxHa8UFy/EGEuSfZrltY0i1+4B4wnwXmwKRPrYUqXP6htjNAVuDpwcw2fQqB8y+0oNCMEmu1I3PMFvvbFFfp8NtkH+hYBSEzFxfWeMUHjWbF/dv+6e4+WIfiko0JhaWnIXgV6cQUGDBn+UA26mRaMH8ZdrlF0NMmrOkQwHyoQp1vQO/Ka5Hn4MAt89NWfGGKQOJqqsxNqoiNVhaJ0mst2H0qHYEF/9Tj8/TlHXzUYAjFfK7q5x1IcoCHuppN4ZPmBnUwwXU7FQlPEVH7y54aIGH//22wVRLF7jaAypAzcxEUWj+ymc2JG9uoabM9RZ5CFH+myv0hPQxOpH+NRRVHVvxK5EMrbst3HZIPxjrsKGG6ocEF5vrqiWpRUBHKWbeq9Xo1sAkJoKb0IetBcI8FeDu5y/Pl49GQ/Nm6kIraSWGJcjlr+64U3gTWXTn9Cz20V3DZwq2uxSXrpw51NNMuDkyiHmvmZIwwcwucE/pBjREOq09HEHb0DEd2Ho3sIMFbE/HdZIPU7uKKtSf0SL1eyMy3EHPlJZ72CyLcnHHCrcFqv2xUiZj7ACDTzTt7BXmWqBaF/iC/WZtAX1V8uQRqvC1nx3a73FRGYXAedeg= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(376002)(346002)(396003)(366004)(39860400002)(136003)(451199015)(83380400001)(186003)(2906002)(9686003)(33656002)(26005)(8676002)(66446008)(6506007)(7696005)(64756008)(41300700001)(53546011)(4326008)(86362001)(38070700005)(82960400001)(54906003)(66556008)(122000001)(38100700002)(316002)(76116006)(55016003)(52536014)(8936002)(110136005)(5660300002)(66476007)(478600001)(71200400001)(66946007)(81973001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Co8706FERx1ZdwXUeXNMRKNW+R1YIx4ccepqeCArJVzhhY1Td5ByLTxQNLmE?= =?us-ascii?Q?TWBVIG0hUVASvdVLPoB3kT5nGzrl/eK6UTszpO9XVDdAd+Ff2EWjUYAIoDH/?= =?us-ascii?Q?5ib0q5Cg7aRrTHSzwU5QdFSq5jgoTcIxVlbBg1fzmxoCNJX06X1gQugim9DN?= =?us-ascii?Q?PnP8iOdiEuXX9/N7hIYi552wuoLI3IBndupInM2bJ0TLW6pNIQGxnEBEpnsz?= =?us-ascii?Q?tXGAesI5vhelQ8CPbcYUFI+jFlIxCC1b15sokWvb71UdZt5JDWjabh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RSaUZQvwoxoQ64KvzApAW12ktjGh3W/c/J2?= =?us-ascii?Q?evyHqgszsWgedB7fYjy0P3OcmCNNRhCDM1mGVWWVyS+zMMtrNpjQ3cYVu3mQ?= =?us-ascii?Q?sE7DGHPVyz4UJvGHVojcH9IJb0g6SFra1UteG1y3U/C2lqWK7iL07lAvxOOY?= =?us-ascii?Q?DeSt/UK2g8EkyWALC3fERUnpVZmiDGwjUIL//DKTKSGugTkom9vFLlMMnCqd?= =?us-ascii?Q?16TzShf7kwN3nlBmcx4U7nMqxbFdXkmM+ltjQI5ZaqxbgS9dfLpyTKJyCijR?= =?us-ascii?Q?iTEJoN2UnTyoC91jKCSDrPrZHRPVA5JIx1v9LicTvvd5KYx0LFvS3zlyEq80?= =?us-ascii?Q?ZlMOvQh1jOx1Z1yeobDZ1Z7mtysn4EfLydCGXKE6I2ouTLRz8FQDkwbXga8U?= =?us-ascii?Q?8A9ePdPv3OqLATC7r28ePiNyKiO4FqqEX6K8kfsz?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b643595-afd0-427f-0581-08dab19294ea X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Oct 2022 05:27:14.7740 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: wCDKLjSiO/Fy/CGKe073gysCa/PVSVHXV9UgQUMlK+iuczspM9lQ/nQlosiYPHUZv2zrSafj5T5cYjrGz/Y/Sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7282 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Liu, Changpeng > Sent: Monday, October 17, 2022 3:48 PM > To: dev@dpdk.org > Cc: Liu, Changpeng ; Maxime Coquelin > ; Xia, Chenbo ; David > Marchand > Subject: [PATCH v4] vhost: add new `rte_vhost_vring_call_nonblock` API >=20 > Vhost-user library locks all VQ's access lock when processing > vring based messages, such as SET_VRING_KICK and SET_VRING_CALL, > and the data processing thread may already be started, e.g: SPDK > vhost-blk and vhost-scsi will start the data processing thread > when one vring is ready, then deadlock may happen when SPDK is > posting interrupts to VM. Here, we add a new API which allows > caller to try again later for this case. >=20 > Bugzilla ID: 1015 > Fixes: c5736998305d ("vhost: fix missing virtqueue lock protection") >=20 > Signed-off-by: Changpeng Liu > --- > doc/guides/prog_guide/vhost_lib.rst | 6 ++++++ > doc/guides/rel_notes/release_22_11.rst | 6 ++++++ > lib/vhost/rte_vhost.h | 15 +++++++++++++ > lib/vhost/version.map | 3 +++ > lib/vhost/vhost.c | 30 ++++++++++++++++++++++++++ > 5 files changed, 60 insertions(+) >=20 > diff --git a/doc/guides/prog_guide/vhost_lib.rst > b/doc/guides/prog_guide/vhost_lib.rst > index bad4d819e1..52f0589f51 100644 > --- a/doc/guides/prog_guide/vhost_lib.rst > +++ b/doc/guides/prog_guide/vhost_lib.rst > @@ -297,6 +297,12 @@ The following is an overview of some key Vhost API > functions: > Clear in-flight packets which are submitted to async channel in vhost > async data > path. Completed packets are returned to applications through ``pkts``. >=20 > +* ``rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)`` > + > + Notify the guest that used descriptors have been added to the vring. > This function > + will return -EAGAIN when vq's access lock is held by other thread, use= r > should try > + again later. > + > * ``rte_vhost_vring_stats_get_names(int vid, uint16_t queue_id, struct > rte_vhost_stat_name *names, unsigned int size)`` >=20 > This function returns the names of the queue statistics. It requires > diff --git a/doc/guides/rel_notes/release_22_11.rst > b/doc/guides/rel_notes/release_22_11.rst > index 2da8bc9661..b3d1ba043c 100644 > --- a/doc/guides/rel_notes/release_22_11.rst > +++ b/doc/guides/rel_notes/release_22_11.rst > @@ -225,6 +225,12 @@ New Features > sysfs entries to adjust the minimum and maximum uncore frequency value= s, > which works on Linux with Intel hardware only. >=20 > +* **Added non-blocking notify API to the vhost library.** > + > + Added ``rte_vhost_vring_call_nonblock`` API to notify the guest that > + used descriptors have been added to the vring in non-blocking way. Use= r > + should check the return value of this API and try again if needed. > + > * **Rewritten pmdinfo script.** >=20 > The ``dpdk-pmdinfo.py`` script was rewritten to produce valid JSON onl= y. > diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h > index bb7d86a432..d22b25cd4e 100644 > --- a/lib/vhost/rte_vhost.h > +++ b/lib/vhost/rte_vhost.h > @@ -909,6 +909,21 @@ rte_vhost_clr_inflight_desc_packed(int vid, uint16_t > vring_idx, > */ > int rte_vhost_vring_call(int vid, uint16_t vring_idx); >=20 > +/** > + * Notify the guest that used descriptors have been added to the vring. > This > + * function acts as a memory barrier. This function will return -EAGAIN > when > + * vq's access lock is held by other thread, user should try again later= . > + * > + * @param vid > + * vhost device ID > + * @param vring_idx > + * vring index > + * @return > + * 0 on success, -1 on failure, -EAGAIN for another retry > + */ > +__rte_experimental > +int rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx); > + > /** > * Get vhost RX queue avail count. > * > diff --git a/lib/vhost/version.map b/lib/vhost/version.map > index 7a00b65740..c8c44b8326 100644 > --- a/lib/vhost/version.map > +++ b/lib/vhost/version.map > @@ -94,6 +94,9 @@ EXPERIMENTAL { > rte_vhost_async_try_dequeue_burst; > rte_vhost_driver_get_vdpa_dev_type; > rte_vhost_clear_queue; > + > + # added in 22.11 > + rte_vhost_vring_call_nonblock; > }; >=20 > INTERNAL { > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index 8740aa2788..ed6efb003f 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -1317,6 +1317,36 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx) > return 0; > } >=20 > +int > +rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx) > +{ > + struct virtio_net *dev; > + struct vhost_virtqueue *vq; > + > + dev =3D get_device(vid); > + if (!dev) > + return -1; > + > + if (vring_idx >=3D VHOST_MAX_VRING) > + return -1; > + > + vq =3D dev->virtqueue[vring_idx]; > + if (!vq) > + return -1; > + > + if (!rte_spinlock_trylock(&vq->access_lock)) > + return -EAGAIN; > + > + if (vq_is_packed(dev)) > + vhost_vring_call_packed(dev, vq); > + else > + vhost_vring_call_split(dev, vq); > + > + rte_spinlock_unlock(&vq->access_lock); > + > + return 0; > +} > + > uint16_t > rte_vhost_avail_entries(int vid, uint16_t queue_id) > { > -- > 2.21.3 Reviewed-by: Chenbo Xia