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 EE1D1A0556; Mon, 17 Oct 2022 08:46:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D2F540143; Mon, 17 Oct 2022 08:46:46 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id EACDA400D7 for ; Mon, 17 Oct 2022 08:46:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665989205; x=1697525205; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=o0S1ZOltBQ3ozhi+iUX0knl1kZE6IJcBe2SSj+GprYc=; b=KAkpqOkBNrL4qbAPThofcdN8BJK7hIDnXv7f08ttHGaq48LxTLEjgzc+ 21TE0hPyspPXSU1KLdxdA50O16Oos1SwKKTUIFmGxz6lx1cOFG943hOqo caChc5Hn6n14nwf148GwNV6GTaYlVSjVV4s+VARBuhmCw2NVepztzvI/4 jjHT93ows1LtGUTO4jXBjmienZQSB5JUs4+CKO0V5gWruMYYhtjGVlLCu jYzQ9qC208TdAYyGT6GDloN674kmgPwXlQ6/ImhYD9Kq4e5n3a1VrfBAP oWm5ajf18tQq/tChVvB1gctUSLXfRJTAXd3+653Os+DAXHLtMx9IemLDQ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="392027882" X-IronPort-AV: E=Sophos;i="5.95,190,1661842800"; d="scan'208";a="392027882" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2022 23:46:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="717387614" X-IronPort-AV: E=Sophos;i="5.95,190,1661842800"; d="scan'208";a="717387614" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by FMSMGA003.fm.intel.com with ESMTP; 16 Oct 2022 23:46:43 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) 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; Sun, 16 Oct 2022 23:46:43 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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 via Frontend Transport; Sun, 16 Oct 2022 23:46:43 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) 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; Sun, 16 Oct 2022 23:46:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YZYsZu0v8jBth6jYA5Q6UUkrvOdMYLer1epb2Tdy1tj7+ANbTuXNAiBhiLQ2hlimMkk2hf0JfM7PmQLvFBnoSlTUpVPGcOdEWIMcNkR4ET0TBbip7YDb3rG+78wsD0Sc/oqT7k8bcxzIyErg0Rg/2njG1VoLQLTspi+4IOx+8SnsS9K8jO9hXv84yPTi5vMiOCQu+tmrCcKPXE+c7zqz4XDMj6OHC9cZ3DPvfDlF0LXooJaK2wLFrCiYTvzLED8LtOqayhOb11c0fY4yPo23/+xGD/Es18WuhadmwF4arK8udp/nIstS4xQAcGxKyZmpbAP2QmsQJOlgTse9mzHQ1A== 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=kAx+dd0c29ySRJt8vmDZKbgWm+VAKA5ft55jI8YEgZw=; b=WnXP6LjlOr31U41yHedh3+VCVbMTi+RMm5uh/xiI7DAJr4IBlDS411A0CrWs9BV72NVU8+mb4KZrhuwq9xfyqYh/ZvGRS26BD1CHTKPjdeoZntYPAJ1/f+fx9a/MmLHNhRcdaZkAAi9lwo1PNXF1knxTpbn6Jkvjfn1N47elfxTMS5/DEKP04AEL9bTmZ51rtPSde1JYjjFhgGvyC9UEBW1Z1tKKgaHC5IQc95GHW9osMEkQSTekDzCGhocGNBOanvtx6CxlWUhQ5BJkAz/z8Qp2YXL6fEZcFTDks1oPtKb65qtBEuOTLXoLrQVotuhUfjU0O410xwkReMC069AQ+g== 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 DS7PR11MB5968.namprd11.prod.outlook.com (2603:10b6:8:73::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.43; Mon, 17 Oct 2022 06:46:41 +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.030; Mon, 17 Oct 2022 06:46:41 +0000 From: "Xia, Chenbo" To: "Liu, Changpeng" , "dev@dpdk.org" CC: Maxime Coquelin , David Marchand Subject: RE: [PATCH v2] vhost: add new `rte_vhost_vring_call_nonblock` API Thread-Topic: [PATCH v2] vhost: add new `rte_vhost_vring_call_nonblock` API Thread-Index: AQHY3gWKNmktqunO7UqAhZfjnWWkh64SKwIg Date: Mon, 17 Oct 2022 06:46:41 +0000 Message-ID: References: <20220906022225.17215-1-changpeng.liu@intel.com> <20221012064007.56040-1-changpeng.liu@intel.com> In-Reply-To: <20221012064007.56040-1-changpeng.liu@intel.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.500.17 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_|DS7PR11MB5968:EE_ x-ms-office365-filtering-correlation-id: 4189f747-3d90-4871-ef2a-08dab00b593d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: akGyDBxqEQkPUPogRoxPgCVZNXWWwzgSOCmvUECCiT6hZkRaKVj9m//DYEZg7ujNZ75s5OZ5yOozaNv+vxJIUmBzaUwj9TUPXLMizWIe7KTBRXcRoYwW2/LTEc2E/nfYzzshOA+F3eJMlaeaDEtApFOoPzyNyHEM1ufx/AP3MZmqBkH2sqmnRsjL4p/bKurYlsVtTQCbWdTEmywijrOsT0JJF23O7ZaOAjF1Q9JG85AZkysYfZ6BzTUJb8pwmRg7+Uiqc8xDuyfKWh2bC7CmNLgO8sPiZMcXrDpX1PLtykrdlP19FzVSSML1thQJemqwMwHKwbODN+cZlssxN0NK2JPNCNPgWgwpv7PTCp4G2V1ZfS+jCXGmfKXG/1hytkaloWPDVEjSYVgl4Tqmu7UaZ9ZX5SPzIuwCFwQpm4S1Hkc10djNXO8hcSWp3Cp9PH6eW0FuS2f7G7sdM3MUPJDnszkUGjV/jb8gREPHL92QwZC6NSQ2JltHRY1MBla2TcT+mDBggNx12OTuFbBgfSojiSgEexCnPaTHM3oiekRT4BCkjK2+yvTSK9MJtZaUO6bC24pwMLY6GYx/yIxuZ20Ib+EzSyD0IhZwoPoPHimzPJeX+CU7BOywq1kbUwNOk9xPidkF44i0ar4PFD1GZOcGkqxV36IOW0kNp2uI9WEUfIOlmpERCgpU1yR6eZM9HXo5dEdroOb0GuOQJuoFzvA4ernWEUD3syi1+bdm5YRuTX9MQ4FzZGBpXuO1wT7h/usQuorOvKC8rC6BtUpI5mXkVrJUnCYi8oU25vcixh+yIebnT6sQeAxP3grhaF8T2LcdC3H4PpdP5VcGKJbQB6liYQ== 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)(366004)(396003)(346002)(136003)(39860400002)(376002)(451199015)(186003)(6506007)(9686003)(7696005)(26005)(53546011)(83380400001)(2906002)(5660300002)(55016003)(316002)(54906003)(110136005)(8936002)(966005)(478600001)(41300700001)(52536014)(71200400001)(4326008)(8676002)(64756008)(66446008)(66476007)(66556008)(66946007)(76116006)(33656002)(86362001)(122000001)(38100700002)(38070700005)(82960400001)(81973001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wiVs/FEGUffWiH6pP+jP44JmgDO3urxUDce2QVJ5xmjJT191/RCaQ7DeNpON?= =?us-ascii?Q?1w7NhlwlqtTY5zE/mmcU/3RC7AKOAWkL+M7fqkI5RPMuUyKhfH8gGhVF+p7a?= =?us-ascii?Q?y5oixOi4mmpMwxd3zR+QQWTKQ+MHaXkTBRjpuhZK35vzy/qk9AMO24VvyOOH?= =?us-ascii?Q?LEYhWj34AZaiOs6zy5QzDVnDgRrZCJ9M/DRG44MbhHiRMgSWj0mm+XCNkTpZ?= =?us-ascii?Q?DahBv3Zt0EBhCt0+GEMWiZdOz+Rids8xutMnH0tVLYatcGCqDbUbNMXCg6jT?= =?us-ascii?Q?SqjUvS67zwmhUJOLeFRHPBvF5nkdxvirv86wSIq/QUMO3eOVntxZ6QPR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T7seGtwUEkfZZ32QvMMIz9iWCnCyVwCUm/t/Tnfq8jbazm+R54mZr?= =?us-ascii?Q?bMsUPUaZx8Bnu+gNKcUYOMaoGhKx1T5yDxjfrmQ5G/Q8bQ81FKB+0hzigZ2y?= =?us-ascii?Q?zY9IcSw6KgRd+v3twT2eh5Xb2ku46CZ+x2kTFZRJPoK6fcKG9/9XF+SfVWAe?= =?us-ascii?Q?Xb+8vX3WySvlmKknVYkmaBhTjsrRHIoOTFOC/ZWGv0Uh83nl9/nERqop8TZD?= =?us-ascii?Q?yY377lxXkfOYUcXFAzD8Q6p5COJuKsXvb6wCkauUO53cMoNL9gUIbfReccd+?= =?us-ascii?Q?qkvbSrOiW0hDmACxT3q/bJ04JoQstLVW1RLwqdZaI805Bl+FZncoiP1N1B8w?= =?us-ascii?Q?jFkLYpdqud2sj0bOBl2TBXzYmJtWKu353yq+pOzE?= 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: 4189f747-3d90-4871-ef2a-08dab00b593d X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Oct 2022 06:46:41.4237 (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: EPWCyR34GsJgh9qIChAHympFmy99QNOqG2M+JlqA1zflaKRG9aTwFJey2Gm0wtFYkvzMF6Dqi6iiqOH7I5QhjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR11MB5968 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 Hi Changpeng, > -----Original Message----- > From: Liu, Changpeng > Sent: Wednesday, October 12, 2022 2:40 PM > To: dev@dpdk.org > Cc: Liu, Changpeng ; Maxime Coquelin > ; Xia, Chenbo ; David > Marchand > Subject: [PATCH v2] 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 > --- > lib/vhost/rte_vhost.h | 15 +++++++++++++++ > lib/vhost/version.map | 3 +++ > lib/vhost/vhost.c | 30 ++++++++++++++++++++++++++++++ > 3 files changed, 48 insertions(+) For new API, we need to update release_22_11.rst and vhost_lib.rst. You can refer to http://patchwork.dpdk.org/project/dpdk/patch/2022101309270= 8.4922-2-xuan.ding@intel.com/ Thanks, Chenbo >=20 > 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