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 D5609A0556; Mon, 17 Oct 2022 09:40:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA26140143; Mon, 17 Oct 2022 09:40:02 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 56C29400D7 for ; Mon, 17 Oct 2022 09:40:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665992401; x=1697528401; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=BNfXWte7q137Ng1rtVrzeLPaVg2Zmlq6SoO8/4DqWDs=; b=VohQz8gL+eXldHxWKUWkxsyKwyPzHPWAkQ1lS//jWRHe5lVhkUnIXcFV vmlvLQfB8m9/BZ2a92DTHj5P7yZsP16fM4Rq4jlotb9cHSdJvm8p5UMYo e+LMJsFa7+ATHGr+r1biEfK5wTAkuH7tawN4jCaEJ5nCD+e/vtiTyY1ON aF4hKjuB7+aKAAQOz6RK8apWl2zW/ACphvRbNBKw3bcXIm1IxI48FJC1m FtdEolkEk34Trf+zBuJ5IMVx2sSooEbiDr3taeWDvEmo+uYUzUqmNE3IC EsrY7hTZR/KMBHZxNJVd8Z6GMtlTGY4Bk5FLWqZTYs2Crk8WKBAgJwARZ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="285456600" X-IronPort-AV: E=Sophos;i="5.95,190,1661842800"; d="scan'208";a="285456600" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2022 00:40:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10502"; a="630588945" X-IronPort-AV: E=Sophos;i="5.95,190,1661842800"; d="scan'208";a="630588945" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga007.fm.intel.com with ESMTP; 17 Oct 2022 00:40:00 -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; Mon, 17 Oct 2022 00:39:59 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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; Mon, 17 Oct 2022 00:39:59 -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; Mon, 17 Oct 2022 00:39:59 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.173) 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; Mon, 17 Oct 2022 00:39:59 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DgfJbt/0FOKqXDuQ12rJ2fweRcqpan9xfv9PhhL6ZxnSn5TgTWWdvs9fz9c0qixJLoDsAW38MeYHewLUMOYU7cNHoVM/1iXFXjhXYlSWyhaEAYpfr0G76Bwo6DuQVrj/OccL7zNQRfN1bQ0M+ytNAYgMdBPLeA9rhQwD7LNGjEe9XmzmttOZ6pJry+t7+HpsSJRL4Wq7k3o3QrOFvM7dTM8tYQwyI94JSX/qxPtfchylY3Et3+yflYfNVqyGoCL1mlyQLF2pOrTJpoTUcfQUhimjUQ7lGQ0ywa9lhhKZ4Syh4XofVpYPYAn+M706IVOg2HeQ0b+gb+Yh/Apvt+hfww== 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=E+y6SyUNuupSvO5V8ZkGiDcMgiywRQYieJveJDZoyOU=; b=RABM3z2ldhMUu745sAPzdLZswXtLWzRrt6x7JOOU4XhXfkQ89libWNbwJBka+raGRvwQUB4o019AtLma40zPd1x8PTJRJcmWLMrUcWe48ePP2+NL4f82L9Ur9s3BRRx4+zthNzw6KpSNVKUF3Cd9c12Zd2RylCFMFcRyPG1ZpdvDuDGia5+ChkXv4YTF8Ch3PMOrYZsKR5x+EV0y3kRoaiyBEMIN/pOLg/XmHvNBKSXYoo8PtC8xiP0qDZuwx836hw7262K9keYe1M8KqOzNzPKjFXLRspe/hfKTPgeHOnceDF5WdBI7K6M09/BvT9jsxwuVfcRUoOlZF3WI9pj2pA== 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 CO1PR11MB5172.namprd11.prod.outlook.com (2603:10b6:303:6c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Mon, 17 Oct 2022 07:39:57 +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 07:39:57 +0000 From: "Xia, Chenbo" To: "Liu, Changpeng" , "dev@dpdk.org" CC: Maxime Coquelin , David Marchand Subject: RE: [PATCH v3] vhost: add new `rte_vhost_vring_call_nonblock` API Thread-Topic: [PATCH v3] vhost: add new `rte_vhost_vring_call_nonblock` API Thread-Index: AQHY4fg/OTHm7Foqokmc92ut206REK4SL72w Date: Mon, 17 Oct 2022 07:39:57 +0000 Message-ID: References: <20221012064007.56040-1-changpeng.liu@intel.com> <20221017071457.28589-1-changpeng.liu@intel.com> In-Reply-To: <20221017071457.28589-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_|CO1PR11MB5172:EE_ x-ms-office365-filtering-correlation-id: 67b846a1-c8f5-4218-1a0c-08dab012ca51 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: FLwUThWspKXC1RMJgxZM1Gl2ueP+1KgZHaKFh07MuVgPHjRwA1MwgZmQT3f/M5wD4s9gupKk/A45fyu2SNu+0cUvCtQEecSq7tzydvea81KNHJaW1UsXHIqMDNmtVxJkGNNLwlal2yH8j84hac4SymwQXQ6Eu11IqzPI0QIGwjGssUdgXNE9spX1HbMKd2fbOn0qxAayoOW/oD7CdutFBzEgp8dZgTEw5SZ/kP2BP5kdPsgMHd+FoWedMfeJa1R3ZHLtHwSV72gTUlQu6W6ZMZIfwxvAR+D5dv4v6UMQNRgjlereFmk6TBg87jJGztxEgV8rTUJ0XuxV34OFVlsDnOBBLIg5u611wzPdfFczRlMEY80p0Tu/iIvd2HxbsR4WQxnmjkvSbGyLzWjYSzKxmwbi5xyrwVzirA06NRk832juW46a5TJQDUp6TW4c28rIiqDT9uQhROgBinNdjG3b2DLyB6nVHRbss8Rs3RubJohkBZqNEwo7cspoL9bMJF/A95KtRMbv9A/a/bHZc9VcvAGZTNiQvuhhayeab5JQdwc8FBJOyvn1RGsXpTRrwqd0awTEpnRc5t8ZzqiTAFqx9N+RiPKO1FZek2GZq2dPZuv9jutPqX42ke2WAtm4EMt7YcuT20WhlPtob5LCKdVCiQSoLNHy3G2802jN4v6K5svyWxUiVQbMUOGfPPaQ7h0PTSKWA2pK2HJMU/S/NNj9lNhnqw/vZzvv5Sy7K5kvDILs/juaePG29kJFtQoYF5L+8QfNtarv/DvkrsElDdt42ooO9++OriW2bMCJ3RrOlJE= 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)(366004)(376002)(346002)(39860400002)(396003)(451199015)(66946007)(316002)(110136005)(478600001)(54906003)(71200400001)(66446008)(66556008)(64756008)(66476007)(76116006)(8676002)(4326008)(8936002)(9686003)(41300700001)(26005)(5660300002)(186003)(7696005)(2906002)(6506007)(122000001)(83380400001)(86362001)(38070700005)(82960400001)(52536014)(38100700002)(33656002)(53546011)(55016003)(81973001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?F473NYljo+4fg7+4At4bzZXyP3xtd+V4XKm3TKJLP7xrBctzdOAjT+GazBSc?= =?us-ascii?Q?wL62PHCfIB/HggQzYIXo6zYhS5yZ+jzCvMHgZTW/Rl9M1oQ7HSkA6MDiZf5b?= =?us-ascii?Q?NjmQM6EO7fgw1YQtYIcTIBdiQMscEBl/minlxCNMiygdvIZlV4/PNsmEvOJO?= =?us-ascii?Q?rIH+uJCrAP/EgF7jrQ3XBSfHrJPDBS+QMEaG175mKpimtV0bJYPM6r0C13D7?= =?us-ascii?Q?XbuCQTN6m8He3zAdKi0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= =?us-ascii?Q?2QZxT5CKTZQVQv9if1bBYDM7DYAF0Ew9Xplr7yhvhSl61ujnamZuVdxzDRMp?= =?us-ascii?Q?U8xwIV6deTkawE9E9TkFdVb+d1oMzRbDekv3gcYO2R83GTPUILWbdRoKk1/O?= =?us-ascii?Q?R1LgOnQrEGj4kOkrRD1wC5ZUrXGd2POy7IJ87dAZ+zufgulUMtOO1CcQv5Hk?= =?us-ascii?Q?F58bVD0j0nhUNeZQJXQPZbfp5VU1RlMb4WC8kAh8PcJUXk/H0RQFl4ZrV62+?= =?us-ascii?Q?abcrTqlvgz9DFz2R+e/EryscHOtvrJ79RQSiPD+bhcTLRTsf/ByjKkXY9AZ4?= =?us-ascii?Q?c8PD+/RjJbuBIgsO01dtitfzXhq31oOnc35DNUV4t6Omt0jgBZ4WmutowG6U?= =?us-ascii?Q?78HRG9NuHo9DL6qLc1EeH7jrZcSIedYusf6gldPGBUY8a2LjYxAFocdmGSfW?= =?us-ascii?Q?Kp1P9k6AQHnEwM+XZioNzql65I71XuIybxNfWYph?= 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: 67b846a1-c8f5-4218-1a0c-08dab012ca51 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Oct 2022 07:39:57.6402 (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: GouqgUpeSlF0ot7o4rylkM0ZceN0DVUyqS6dCKOTh5sCAtdt6Qc9G2mqwDJ8aqL+4gKEtWxpt281W+1AVuIPJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB5172 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: Monday, October 17, 2022 3:15 PM > To: dev@dpdk.org > Cc: Liu, Changpeng ; Maxime Coquelin > ; Xia, Chenbo ; David > Marchand > Subject: [PATCH v3] 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..9b3783ffd8 100644 > --- a/doc/guides/rel_notes/release_22_11.rst > +++ b/doc/guides/rel_notes/release_22_11.rst > @@ -236,6 +236,12 @@ New Features >=20 > strings $dpdk_binary_or_driver | sed -n 's/^PMD_INFO_STRING=3D //p' >=20 > +* **Added non-block notify API to the vhost library.** > + > + Added API to notify the guest that used descriptors have been added > + to the vring in non-block way, user should check the return value of > + this API. > + This may be better: * **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. User should check the return value of this API and try again if needed. And for new features, library should come before scripts, so you need to mo= ve this before ' Rewritten pmdinfo script. ' item. Thanks, Chenbo >=20 > Removed Items > ------------- > 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