From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ABFDBA0521; Tue, 28 Jul 2020 05:10:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3383D1BFF2; Tue, 28 Jul 2020 05:10:04 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 6E4D32B8D for ; Tue, 28 Jul 2020 05:10:02 +0200 (CEST) IronPort-SDR: TPRKaH4M7HHLLivWVFvIO0g35ErpFJd7uMvSK3HD621FsjvfV71hPGlx96NrlynAcJVhk/6b3H 76O7L0rFSMCQ== X-IronPort-AV: E=McAfee;i="6000,8403,9695"; a="130706916" X-IronPort-AV: E=Sophos;i="5.75,404,1589266800"; d="scan'208";a="130706916" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2020 20:10:01 -0700 IronPort-SDR: Kll6gpGfzBtBrN7RqagtDhoh2SBc6xKaNT1WIcrfh/e7nIUjWbztuGMvctXkbm747UnKWkUJA4 aLqYkDJh3uYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,404,1589266800"; d="scan'208";a="320239506" Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by orsmga008.jf.intel.com with ESMTP; 27 Jul 2020 20:10:00 -0700 Received: from orsmsx111.amr.corp.intel.com (10.22.240.12) by ORSMSX102.amr.corp.intel.com (10.22.225.129) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 20:10:00 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX111.amr.corp.intel.com (10.22.240.12) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 20:10:00 -0700 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (104.47.44.54) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 20:09:59 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mG+gkVTGvoNCPAkHkGtm6u0igFwLFHEpkvhQTkYEHAKU/Nv7BMXlntB9tKzB50qzcUhiQNI7Va2C2Oo5YGyHQD3Vnlu+RRZwrTkDUxBIYCXEnc98mX5KdrstHJ8rtm0HoB1nyMyjGm7oqLVcpFEoCZ1975xkvFP6vi34nGjHG3PsgBzyksZ7BrSTlrsAiCBFrCWACJdqdIYHLKkekc1syHamkb1BqEd2zUSs+9PD3oJftCNCDK9ZmCrvYqvhG2eP2y+qYediNQU+I1wCFOfbmbeAvzMOnJlB/+lSQ+GgJKQlaJjsDlQ03iP55pc4XdFmE2i0kNpkBpnkrOW6JPmTnQ== 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-SenderADCheck; bh=7btzAMI5ZHf2wQPIAhE9iTEZixeLzn2RFLqx6LWTNio=; b=K8tPA94kn1px4imbpNdKA1BFP+t4BCq6gXnpQd80NFzTPA/CeOoy4VM3Tn4CwPCYUek3y/wH4ofwts23keDtZ9e4QrekjybFqJlaZ2/l1Zn4YuagrlIDkc9jzGK8eL8XBKmlt3jx8TIBFD+moH1ggmPmdGOLknn2FSFjKjmaiU4M4t8cW1kd1QnFmgQFYZXdoKUVdrrqPs8yEibfpRm8qD5ITh4PJeT9WMFsteQtA15dUA+YDU7SB5JiMu2pENHMPNrX1vqEgpEGM9sdHu3KuGeWLWcQ4eYmsnGz4nFKcU7kU1/X/mafyyaM9fHKv+9rJWkpYZQSUVFZpeWWqgdgwQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7btzAMI5ZHf2wQPIAhE9iTEZixeLzn2RFLqx6LWTNio=; b=TnMaX+xGUEMX28tYL6BEAMsCMECesbDBarISzcZJJ66xpDJishZWMiLCtESdOo/5phHLSwk/yL4aingTNnSmuu/cb+j7yHZUlbpfMIlDOR3xzBvSAaKQD0F7Vf4bVmZaEL1os8YUpIW0HvXKvJKpSDNRC+dv7VF2oVoaFeFkiVc= Received: from DM5PR1101MB2169.namprd11.prod.outlook.com (2603:10b6:4:51::14) by DM5PR11MB1899.namprd11.prod.outlook.com (2603:10b6:3:10b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.24; Tue, 28 Jul 2020 03:09:57 +0000 Received: from DM5PR1101MB2169.namprd11.prod.outlook.com ([fe80::d96a:61:33a9:9036]) by DM5PR1101MB2169.namprd11.prod.outlook.com ([fe80::d96a:61:33a9:9036%12]) with mapi id 15.20.3216.033; Tue, 28 Jul 2020 03:09:57 +0000 From: "Fu, Patrick" To: "Xia, Chenbo" , "dev@dpdk.org" , "maxime.coquelin@redhat.com" Thread-Topic: [PATCH v3] vhost: fix async copy fail on multi-page buffers Thread-Index: AQHWY+A8tE+aQL2IsE6kfH7GxtbeJ6kbZ9QAgADn/MA= Date: Tue, 28 Jul 2020 03:09:57 +0000 Message-ID: References: <20200720025242.3066787-1-patrick.fu@intel.com> <20200727063307.3703071-1-patrick.fu@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1780a8f5-f854-4346-384f-08d832a3b54f x-ms-traffictypediagnostic: DM5PR11MB1899: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: raJpeQpTELojGWkgtoIsExv5s2LMPKdmnYrtz02LNDqvHJmfQlRJ5Gx9W1PrBRwmbk4oX8/nFCjLkF3HGEdqgGPtLXKXl2YVQeytuKseuJ0lEqejyR/uvp0XI1bqPCdBmDvxNYVyWEbiun7nVmWanHxHoD6hEJjbtDsbi/wgnOyGu+DxkoXWVTuGT8bpE1fV2NICHONw1KPcHFYuRqBs1Jjn3YGL8JjUVv2oAf4rAre3vCTu6P7eSc6nMoVNCKpytLa9GI3iABkEv2ZjzY+ewSY/QeMaqt1sNsZ3Vp0+lv/IjXhuLuJ/R//GAmBo4U3UubeIiB6XRFtirpJf74cewg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR1101MB2169.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(376002)(136003)(39860400002)(366004)(396003)(8676002)(8936002)(2906002)(83380400001)(55016002)(9686003)(71200400001)(86362001)(5660300002)(53546011)(66476007)(66556008)(33656002)(52536014)(64756008)(7696005)(66446008)(66946007)(6506007)(316002)(26005)(478600001)(186003)(76116006)(110136005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: JGfeuPbfvFSVwiYZcp4X9C0mlgA6NjRzrTqUTSLxJg2V35IMYodSUyPDWR2vW8xcX1JmhkyevbTCtvUz2BshEtKehyVNGMKZboSTlv8r6k1epTFkQQ5+iJ1+pZhzvy+yWOo0EEmd6ZaKAhco3a50magps6jmG8MmIl/z3zQpJfAGOegPhNo3pfSyc7YqJU57D+tqmHkVTXJ/QD/fGARXk2ovTNCNcYfUzUtLSXkMd/5/t3vNShmmElghZu58hgLpf59Ll/nVjYC6bE+RkGUgdoFYJK31pZ3N3qZaUqoh8VTi+ZZl6gNid8mbIFBm4ihI1ydHVkKoMvL1j9J+Uwfs/FGJ/29hT2AQG006gTOwOdSCkM1U8QESOSNYu+0uRxCeGo1T4i9diQHqfq+/wst7eXW/Dm/qw2xjCBMSq8p3e9Td3zgxf/0Xl0zDvVH10zHqE+drU64idxs88qeHSsRPQzTUP/S28nM1MzuYg4QOlSHLpE3PYI9Tng+yyzfKTkWB 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: DM5PR1101MB2169.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1780a8f5-f854-4346-384f-08d832a3b54f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2020 03:09:57.4121 (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: u9Cd4v8xDjO2b6XQPutQacxk/VPs3YS+qYBFARcfqQ5xDGsYBjngObx2isT7V7w3hOGmu8La0ahHpVAw6InOmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1899 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3] vhost: fix async copy fail on multi-page buffers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, > -----Original Message----- > From: Xia, Chenbo > Sent: Monday, July 27, 2020 9:14 PM > To: Fu, Patrick ; dev@dpdk.org; > maxime.coquelin@redhat.com > Subject: RE: [PATCH v3] vhost: fix async copy fail on multi-page buffers >=20 > Hi Patrick, >=20 > > -----Original Message----- > > From: Fu, Patrick > > Sent: Monday, July 27, 2020 2:33 PM > > To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo > > > > Cc: Fu, Patrick > > Subject: [PATCH v3] vhost: fix async copy fail on multi-page buffers > > > > lib/librte_vhost/vhost.h | 50 +++++++++++++++++++++++++++++++++++ > > lib/librte_vhost/virtio_net.c | 40 +++++++++++++++++----------- > > 2 files changed, 75 insertions(+), 15 deletions(-) > > > > + } else { > > + for (i =3D 0; i < dev->nr_guest_pages; i++) { > > + page =3D &dev->guest_pages[i]; > > + > > + if (gpa >=3D page->guest_phys_addr) { > > + if (gpa + gpa_size < >=20 > Should the '<' be '<=3D' here? >=20 Yes, it should be. Will update in v4 patch > > static __rte_always_inline uint64_t > > hva_to_gpa(struct virtio_net *dev, uint64_t vva, uint64_t len) { > > diff --git a/lib/librte_vhost/virtio_net.c > > b/lib/librte_vhost/virtio_net.c index > > 95a0bc19f..124a33a10 100644 > > --- a/lib/librte_vhost/virtio_net.c > > +++ b/lib/librte_vhost/virtio_net.c > > @@ -980,6 +980,7 @@ async_mbuf_to_desc(struct virtio_net *dev, struct > > vhost_virtqueue *vq, > > struct batch_copy_elem *batch_copy =3D vq->batch_copy_elems; > > struct virtio_net_hdr_mrg_rxbuf tmp_hdr, *hdr =3D NULL; > > int error =3D 0; > > + uint64_t mapped_len; > > > > uint32_t tlen =3D 0; > > int tvec_idx =3D 0; > > @@ -1072,24 +1073,31 @@ async_mbuf_to_desc(struct virtio_net *dev, > > struct vhost_virtqueue *vq, > > > > cpy_len =3D RTE_MIN(buf_avail, mbuf_avail); > > > > - if (unlikely(cpy_len >=3D cpy_threshold)) { > > - hpa =3D (void *)(uintptr_t)gpa_to_hpa(dev, > > - buf_iova + buf_offset, cpy_len); > > + while (unlikely(cpy_len && cpy_len >=3D cpy_threshold)) { > > + hpa =3D (void *)(uintptr_t)gpa_to_first_hpa(dev, > > + buf_iova + buf_offset, > > + cpy_len, &mapped_len); > > > > - if (unlikely(!hpa)) { > > - error =3D -1; > > - goto out; > > - } > > + if (unlikely(!hpa || mapped_len < cpy_threshold)) > > + break; > > > > async_fill_vec(src_iovec + tvec_idx, > > (void *)(uintptr_t)rte_pktmbuf_iova_offset(m, > > - mbuf_offset), cpy_len); > > + mbuf_offset), (size_t)mapped_len); > > > > - async_fill_vec(dst_iovec + tvec_idx, hpa, cpy_len); > > + async_fill_vec(dst_iovec + tvec_idx, > > + hpa, (size_t)mapped_len); > > > > - tlen +=3D cpy_len; > > + tlen +=3D (uint32_t)mapped_len; > > + cpy_len -=3D (uint32_t)mapped_len; > > + mbuf_avail -=3D (uint32_t)mapped_len; > > + mbuf_offset +=3D (uint32_t)mapped_len; > > + buf_avail -=3D (uint32_t)mapped_len; > > + buf_offset +=3D (uint32_t)mapped_len; >=20 > Will it be ok we just transform the uint64_t to uint32_t here? > What if mapped_len > MAX uint32_t ? >=20 "mapped_len" could not exceed "cpy_len" (according to the gpa_to_first_hpa(= ) logic). As cpy_len is uint32, mapped_len is safe to down casting. Thanks, Patrick