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 D10E0A0542; Wed, 26 Oct 2022 11:24:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3B7B42BAB; Wed, 26 Oct 2022 11:24:32 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id A53F440041 for ; Wed, 26 Oct 2022 11:24:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666776267; x=1698312267; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=eaXX/Via3JdveS23dj6idDT4eZXdlRmqHnZ4S4+MAC0=; b=XYTSBjVJS8JtCmZ1PfB9UC7j99+A3Aj4jo+ahKvPIjrmbjzGWC1s5os6 iJKV45PbyBXrrbRZ8B5GSPmo1BPy2sp3tb15cptLrMflDi4dugkU4anHm Tr3r76amEpl3uZwh5jGJWrM4cs0hvB8w95wgWtiN10AeI7zMDPG4rbrwV 83/BcvYb8AE/On9CGh945qRymdDFS4VXCCAW2Rmszy3z/hOe6W/3Die3y EouAqE1/188f/CFauIll5/96JuADwukVB67DRb8ua2UgQHEW6swfNiEXn ql2adDDFrwjnc5jt7n+WmxMLLjm1znRsi1JmIVQLRYSVJZYt9btjYXwdJ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10511"; a="309592008" X-IronPort-AV: E=Sophos;i="5.95,214,1661842800"; d="scan'208";a="309592008" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 02:24:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10511"; a="877123721" X-IronPort-AV: E=Sophos;i="5.95,214,1661842800"; d="scan'208";a="877123721" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga006.fm.intel.com with ESMTP; 26 Oct 2022 02:24:26 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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; Wed, 26 Oct 2022 02:24:25 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) 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; Wed, 26 Oct 2022 02:24:25 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Wed, 26 Oct 2022 02:24:25 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OEw24Pxpb0HEpJWzxh+kmOaIJLD+JO8iB5j9+ByanOpc/EWT7e+hUs26B6z3gheSKuDF8gByxpYCdx5XfDz0T/TI8SS4n5DnmwWirsSEhVil+zQEWvK3UvGXN3CgCcww6UKE+9gUDgD6Rk76aF+6XPGyXBnFopu4AZUxZ6WX66UE/EIMT2CniBy+oDPXRYm7xHPHCErgmDUlkq2Ceggn9sLgpCZNFH7su0e6YYHkmEYZG6MEd02W+OQAKr0uaWd5kmnbyveeVaeDkUgaY5ynlz8D5FM7dTgwX/p+z6R5NqaI5CZiuHnQB3KSe+kFkZtiq0f+a1wkWtC12xJ/xjECzQ== 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=GA33eDPW9a7ZU0oOuoeyleeBHQ7SCo2W4xRaWAljPUE=; b=U/aSdj27Xb+EdWB4JWrKOIUHJQzbuLT5rGtL6oHfZ5YmUDQv1Yv+bnzQTwh5eP09TVLhQ4h4eh0coreLHUC5GXKaIxa1dIHDmF9IiR4DOppSs0oEexFOI8qSOeOqZQmPHy+lz5Uj5sKXW1aUWxNcfttd4EY5RTqsEs47dE8BZTXLmp5S8bOxFT0VAgeYnrcqKkisfGjzlmlNdGLWw1Uvehf1eGzYzbb2BCTYSEbRittYMNiv/UzQ+uV4/XBd++v82lSve6pi679dcszQbtcUhAS/tM4xVe6bMWpCe4eChfueoAHCpkmcDWIClLC1SPgXuQnYFrZ+u7tVgJdr5NeHUw== 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 MN0PR11MB6302.namprd11.prod.outlook.com (2603:10b6:208:3c2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Wed, 26 Oct 2022 09:24:23 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::1a91:6a56:1250:ef0e]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::1a91:6a56:1250:ef0e%7]) with mapi id 15.20.5746.023; Wed, 26 Oct 2022 09:24:23 +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: AQHY4fzejiFRhEqWekinGmHgPO9FA64gdDvA Date: Wed, 26 Oct 2022 09:24:23 +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_|MN0PR11MB6302:EE_ x-ms-office365-filtering-correlation-id: c2a0d4a0-7c18-40f8-18d6-08dab733decc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: IXA7Gb5GjHW0vsijznhGWl2pvT+37XmWRpE6HR5pk0+tQTx0t5XKZGLbYDT32j2RESrEiserkWVBV85mmF3AregsRYSnOejPjkJ+R94AVBWH4eP3HH1sZa0lEhAYIPU3wkVtE7HOPzzImu5XgpdL1xC+0D+DRA0ryqzDtz9V4LygQbck2VqcMSVSO2kMM8wZro9hKlJQVQ8ebcDoKy+yJfomgIARLEw8FEHf7WmhIw8t1ANYpoti5K/0yEv+q65UsOEc2fD4Ozv58gNEc+gx1V426GNBI2tRMNjHmfq6cQgdW2+mql8se7bCKBu/+FESgyQxEgmeCJcZjPJ06n1etbcX67p0VLuzCIBe8vHGlt6Kygc6ENTlMxkHoETk+xTCWydJHFCWEzGXEej1fmRTeyu7f+5IsFCH8Af5tUgw6TfSgKIinxfpHdMDLZnmJw2EWfn8cGKtgnEZFnI4W4fnBm2Kyiboull5oO7dDIsvc8YoNyyvrVhVtROLFvNLZTEpGayJ4E6vbpj6/4GQtDntcUHiyz67tykL4Waz9KxrdHBg0WiSDuWrtsNrvZ4YBdYVHxxsjl2o2GVzQW6tYqlEdw0q8bBfI0fkE+HQsadvQa7GByrxpo3OYXkF78h3OzSM2VDyKK/CVkx5lCgDQ3bXPiFwBfX8i4YZD8V5w6Uc0DsBqya1xwQdY+FbR0E0wcs8uD3WWS2ZM2o0mRHlkHJLXiKkHDj8c9u7QsAlvVdugLMNkaC21tch9qLlBHEs2Bqk5QR1fA3ebZVKJ+qD40/CnVY3hIKhenC6OOmI+FpCpoE= 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)(136003)(346002)(376002)(366004)(39860400002)(396003)(451199015)(2906002)(66946007)(122000001)(8676002)(66446008)(66476007)(76116006)(41300700001)(54906003)(64756008)(52536014)(478600001)(33656002)(8936002)(38070700005)(71200400001)(110136005)(316002)(5660300002)(83380400001)(86362001)(38100700002)(53546011)(7696005)(82960400001)(26005)(6506007)(9686003)(186003)(55016003)(66556008)(4326008)(81973001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?GwF58XsWQR+c5cs7nChD3kqYrgYqWSXjzTmNvwY57CcUTDuN9mYQotWEJEoc?= =?us-ascii?Q?yBYbozA0g+O0vwxRXW9oTO2vRtgaxeijdiVVvKml43Is+rOrq8Z6Y6g1SYHk?= =?us-ascii?Q?W47Cuv5lTqxK8zBr5OBHtPBF2zfd0piKOtYexXqgUgIh11DyyqlzH7RcHh0r?= =?us-ascii?Q?hcwioWKBREYlfJpbzecTZr0DTBgJCZh0gVLFhYBKZVLB66QD10nJup9+WhGZ?= =?us-ascii?Q?MMGO92qSFBGlCq+G2o/qa4qWrdUA+Andt7VBzNVNQI/bvf6Lsg0fo+0wE7Fe?= =?us-ascii?Q?8mc84I4gNssr16yb4rN39NT2fHjA+n+BFVlgP7e59ib/qe7DfpC+Gi3/LCzw?= =?us-ascii?Q?sBoaPV1vD4VChZEtKxHeeNhhx5jtSsu0M1qUEtfeyheslx/JNaPMMCVJgd5Y?= =?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XH0ZyB3TWnGzF45ECQ?= =?us-ascii?Q?pMkcw1KSJYUGdY8zXzovSfnfianAg5ENpAkNud8Ef4scuy2xsd+0Q46FlSUV?= =?us-ascii?Q?Xehuhk2XFa9ff2k0Rvwa1nVrndM5sMfOJfO+jGPXT4DCCjkT9yloLRoomoYG?= =?us-ascii?Q?CAG/IPCEX0XZdifAHMsshv85edeOGHBH4ufqdQ7WHCUkgaBMpsnRS+PDn94v?= =?us-ascii?Q?lqn7UMt96DQo7ZnZvXVfZvUALk7G8+AQsty1f/5eMD68EFN7CXV1C7KxXabk?= =?us-ascii?Q?/nBKCSPhPiz3BIO4O1U2G5Wffg8OgWQOqhuew1z5?= 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: c2a0d4a0-7c18-40f8-18d6-08dab733decc X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Oct 2022 09:24:23.5010 (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: 17tfoDxUdTC5CyEuQaN2A+CZ0USItKVq5ZKpSBrvFeuuG8ssom8YdZ05KrA7I/A0RYY8OYaDtarv+31SmkpKsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR11MB6302 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 Change title to 'vhost: add non-blocking API for posting interrupt' Applied to next-virtio/main. thanks