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 9AA92A034C for ; Mon, 24 Oct 2022 10:43:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88EDB4280E; Mon, 24 Oct 2022 10:43:21 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 0D03F427F7; Mon, 24 Oct 2022 10:43:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666600998; x=1698136998; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=s7DCWPIwF1L2Qr9h9v+RzqSOHGLchw8krllO1HD4q+E=; b=bMPp7mFQIj6ngWZCUO/06f03IJeXC+2TANWmeuC3Ubq0he7r1pnjhwt6 fByusWljnAKje/24wEJxR+R/ylNze/ClMw2xhtjEL7o0vyCPty/6A++Qi R3VlFxEcJYFaW/vRmypLwsxAJNXeuI3XkHEG7VsCe8BLhpoCrl8bN0pi5 prGeYPK/cm9daPmpgKNycPbFVWfL9x93G92pEwlnD9pRSD34SdhY3/PAM QBWvGsJjq8/xEqw7LyEoFRERaVezk4xDWrU0HhxLRcgMrOAwrFuSCBW36 lJHQyMYjxfzlz3nHOZnuRSm+czREr5z+8RpTGFgb0vasHMOMWcsWXfyWp A==; X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="369436241" X-IronPort-AV: E=Sophos;i="5.95,207,1661842800"; d="scan'208";a="369436241" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2022 01:43:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="806240688" X-IronPort-AV: E=Sophos;i="5.95,207,1661842800"; d="scan'208";a="806240688" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga005.jf.intel.com with ESMTP; 24 Oct 2022 01:43:16 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 01:43:16 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 01:43:15 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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, 24 Oct 2022 01:43:15 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.46) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Mon, 24 Oct 2022 01:43:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3QpVLWInNuUBulG3qJXtnRbEf5XzMb2PZpr9LbhfTpCnS6m8K8CTt0ESSkvkadmmSVEy2jjTqwZxh2FIgFG1vuXshO3Vt3GxQzyPxtYaM5x+8r77ts7vJj5TyL0S6MfGR7zsWNkiDvtDOXB4X9teWyxpejiDvUXWFbLe5znl79lE032mL6A94TfWIFmklixyXQ/1woCvXKarmo5EFRgzLvsgY+WkbvuQlQUHNqSEQRCFqJAbnHEih/bKEDurJvPPhyaXRjZNUu/EoZOHFLSJlOv6akFbiS8bvFUtUnJiA1oT+PXGjIpLRqWLowJXTgjsyHy255X/tQNU5Bqw7apzw== 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=2qQrukqf3b68i38JcdUiFIT5aboG8nU8hNrR66GHcZo=; b=Q1IibQQgXtGTOiXbFu1Ra4oNipzKa8ZQYz7tHg5tGFvu3AV6eW1wHPwPwGYS+CGdH9N/eLdNOp0qdBal5RgCRm/XAXYQuSKDlquGrwJsnEZfdwMlQy8bZg1vI/xIPtfLHl4DGh/iWq48Nd5jp6hg8p/81dgzyXcJetp52L0sPOWhpU5G+dhvdIUWSimFp7HwPNTOeTeSmAjNWAYipYmULoAxpct36iNEs2nYUXXbxuNf/qOJqT2wKW52dz++h+yplpHtzZgtLK+d1aVgD9n5n5TqsbrVv1r9yFnlz1RBjD47AvMLW2CQIno8ihD5xItbnOpXl1tHZBZbzE3Re1t73w== 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 CH0PR11MB5347.namprd11.prod.outlook.com (2603:10b6:610:ba::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Mon, 24 Oct 2022 08:43:12 +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; Mon, 24 Oct 2022 08:43:12 +0000 From: "Xia, Chenbo" To: "Jiang, Cheng1" , "maxime.coquelin@redhat.com" CC: "dev@dpdk.org" , "Hu, Jiayu" , "Ding, Xuan" , "Ma, WenwuX" , "Wang, YuanX" , "Yang, YvonneX" , "He, Xingguang" , "stable@dpdk.org" Subject: RE: [PATCH v2 2/2] vhost: fix slot index calculation in async vhost Thread-Topic: [PATCH v2 2/2] vhost: fix slot index calculation in async vhost Thread-Index: AQHY3SQEmQwmGeiTTUaZoVXvUE7CkK4dTupw Date: Mon, 24 Oct 2022 08:43:11 +0000 Message-ID: References: <20220822043126.19340-1-cheng1.jiang@intel.com> <20221011030803.16746-1-cheng1.jiang@intel.com> <20221011030803.16746-3-cheng1.jiang@intel.com> In-Reply-To: <20221011030803.16746-3-cheng1.jiang@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_|CH0PR11MB5347:EE_ x-ms-office365-filtering-correlation-id: 69a0a307-e983-4ecd-f7ae-08dab59bc8d0 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: eYRqz+AaJJ1diksy5kuovCPkGMfn8XKgCpadTNVsUdzN7YgHm3ZQxcmQZY7JX2CsTWhloTJvvrU0g+1vZQAEAebE0fnYj28ii0bj4MirGlGSH91peXvfpFab6EmPniDOYM2aiOaptLqBk+YTHO5J8kqrfQJ0YGQJxyVQyQQlDLVCtFyVG1eqOfntmb7VxQDcZbajwNZERKJXhkPnluLo5rS9XTopAlX6TOduvbUSl4/32BIwEcBp5HWOQ6ScXkeiQHQyy0NUJxl2ZQ/IninYskPhgQ9BWocAGox8cKQriQNMylBkKfx/RuyoqY7A01HF4OoBjkqqvkymKbxYOMOznvCAGCOv5UhJEWwbgWtJAMJv5n9v1lgYC1jFz43aZAV5PNd22ejrqxXMhbru3zYvi3gBMWRKjvrXjGM1ehw1bfjlyCmEpKoqWGv4dDBUjqGvLlfHGjC1we3eGCRapmsybr9eUAVHZrS3KEbnmO2dEoxyHz0hCt6L0XBeUChBwzxAT5S2g/51uMmowMjn55i2sdNSFRaFuWpWVBQ6Gdrjxgn7ImV/TbY8LrVF0m0G8iBckryk62lGTLpIxcBGac5aRyqse1FDe0Bh7TGgn4S45qqbiVXlEMR1Zc7QZ4RwL+RE8ZR+b1mEoh8uADClbyXknxX2T8gRc4RZMBKTW4P5Plw7UwyMI1grKag8RvAWlUqa147fwAwfajx+JpyDmGD6tUQfVLvOM3U7c6KwGhwQS4L/xs/vIlQXZ5jPGM6dRjcLTaXiV/P/BVBNz7qmKnpDSw== 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)(376002)(346002)(396003)(39860400002)(136003)(451199015)(86362001)(186003)(2906002)(52536014)(8936002)(82960400001)(5660300002)(41300700001)(55016003)(66946007)(9686003)(122000001)(38070700005)(38100700002)(26005)(83380400001)(33656002)(316002)(478600001)(54906003)(110136005)(76116006)(64756008)(66556008)(4326008)(8676002)(71200400001)(7696005)(53546011)(66476007)(6506007)(66446008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?B5vL7suRZsdLhgZWJvIPzfUOExcjktZwTo+zUDNzkYQ8yIeqMEhkLrt5EI9x?= =?us-ascii?Q?Bx27zpI5DqUKiui8Nwoh9y2gVy8PKcPZnahlANarAU3H29ZD0NjZ9zWGU3mr?= =?us-ascii?Q?i6J9MQsno2TlZA8d5OUl8qWo+BXSPLMCPhUfNjpQcHMGQ1VnPAVzqu4SLKCD?= =?us-ascii?Q?kDQbnNRYzioT7JFQd4e05iCNGpgQXxhHzbUl8qk95vKov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X0kPuXynKnrHu8byOAN14sk5Y5LgDebxIsXCkKZUDKap9Y?= =?us-ascii?Q?qXQcZJrWTQg3hvlEUpebkHn/g6pA3yBbCm+ExHtQA2Vyr7oZ4vLZaW96BfDN?= =?us-ascii?Q?brGUblqE1j3lAEOp1Wr66I66cyDB8YzwunYnDnHLvewK+JX3ihyg4+ydsCHb?= =?us-ascii?Q?JTPhw+4YITB9KaVHLImqv22ql1vFZYLiUjaK6L3Bcg/Bh127wRmyzr+s/hmG?= =?us-ascii?Q?rBTHOgRIMYGgNwa7zP/ThmOK2YiXxJ6Ca6cNovdINC0rq1X91+CGhr6V+4VZ?= =?us-ascii?Q?lsOznkV4oKGtc3VM1m+IMhQ2Bb6FaPHFsqR3db16F6GVPesJjgl34MZrRhMJ?= =?us-ascii?Q?b0MBghHJGovc4J/dDo4Jx9aA1Qf0u3M8Aj/IllfgObJOGRUXA86nxreKBTzB?= =?us-ascii?Q?/HY62Bh+pDwYRlpCaqoqpfYd4eKzS0S+tSh/rlIKNKIGMkA3CCHRJArpAWtl?= =?us-ascii?Q?iCKV9shX7Es4WYy9nWZQRU90aJiovdQ0AUku30F3?= 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: 69a0a307-e983-4ecd-f7ae-08dab59bc8d0 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Oct 2022 08:43:11.9417 (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: ArOHz/JzvQP1uyKL72Ga46KkbPsIz35dcHBVbmo2xn1QawyrAZ8r4cL5DoMZBgajMtTTS/6NDKoOzdaLsGCUxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB5347 X-OriginatorOrg: intel.com X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org > -----Original Message----- > From: Jiang, Cheng1 > Sent: Tuesday, October 11, 2022 11:08 AM > To: maxime.coquelin@redhat.com; Xia, Chenbo > Cc: dev@dpdk.org; Hu, Jiayu ; Ding, Xuan > ; Ma, WenwuX ; Wang, YuanX > ; Yang, YvonneX ; He, > Xingguang ; Jiang, Cheng1 ; > stable@dpdk.org > Subject: [PATCH v2 2/2] vhost: fix slot index calculation in async vhost >=20 > When the packet receiving failure and the DMA ring full occur > simultaneously in the asynchronous vhost, the slot_idx needs to be > decreased by 1. For packed virtqueue, the slot index should be > ring_size - 1, if the slot_idx is currently 0, since the ring size is > not necessarily the power of 2. >=20 > Fixes: 84d5204310d7 ("vhost: support async dequeue for split ring") > Fixes: fe8477ebbd94 ("vhost: support async packed ring dequeue") > Cc: stable@dpdk.org >=20 > Signed-off-by: Cheng Jiang > --- > lib/vhost/virtio_net.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > index 457ac2e92a..efebd063d7 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -3457,6 +3457,7 @@ virtio_dev_tx_async_split(struct virtio_net *dev, > struct vhost_virtqueue *vq, > allocerr_warned =3D true; > } > dropped =3D true; > + slot_idx--; > break; > } >=20 > @@ -3647,6 +3648,12 @@ virtio_dev_tx_async_packed(struct virtio_net *dev, > struct vhost_virtqueue *vq, > if (unlikely(virtio_dev_tx_async_single_packed(dev, vq, > mbuf_pool, pkt, > slot_idx, legacy_ol_flags))) { > rte_pktmbuf_free_bulk(&pkts_prealloc[pkt_idx], count - > pkt_idx); > + > + if (slot_idx =3D=3D 0) > + slot_idx =3D vq->size - 1; > + else > + slot_idx--; > + > break; > } >=20 > @@ -3674,8 +3681,13 @@ virtio_dev_tx_async_packed(struct virtio_net *dev, > struct vhost_virtqueue *vq, > async->buffer_idx_packed +=3D vq->size - pkt_err; >=20 > while (pkt_err-- > 0) { > - rte_pktmbuf_free(pkts_info[slot_idx % vq->size].mbuf); > - slot_idx--; > + rte_pktmbuf_free(pkts_info[slot_idx].mbuf); > + descs_err +=3D pkts_info[slot_idx].descs; > + > + if (slot_idx =3D=3D 0) > + slot_idx =3D vq->size - 1; > + else > + slot_idx--; > } >=20 > /* recover available ring */ > -- > 2.35.1 Reviewed-by: Chenbo Xia