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 EBDBA43F30; Sun, 28 Apr 2024 02:46:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C671C4021F; Sun, 28 Apr 2024 02:46:11 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by mails.dpdk.org (Postfix) with ESMTP id E8705400D7 for ; Sun, 28 Apr 2024 02:46:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714265169; x=1745801169; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=v7zIGeA+lOoy/6XRCf7lRjhCWVrozNWcCqAjwTwrUCk=; b=W22vuY1KGfb6PtaJ1kU9EkuMg5x2wcnR/BUYHWtM4LTNaSAB+XbSBJ6t 0VmfJjs98tBDhnh+pW8S0mfZrZ3ffii9LEEN1auz56QdnhqOQwiXkxcyA 54xO6L32uYtov+v6vMXZT4jLazw1g8I5c2VC9PQtJ1DTzAGVipL7oicx4 cQ/V0A56dMJneoqW/zFL2jACE2k0IgHp0pb4fiYbO0hO3KuHu+H4OVa4U wGnmeLKyx9lPhEd1aUqEPe4vC+k+CyMhlSEUzdGB1CX529S+2aFXETZxn B3fFRhsqHbTXbT4wDeZY9E9ysOt6UJlIk2mRDn7AJuvGZU2kPnFhUuPgT A==; X-CSE-ConnectionGUID: OE0ppSwfQe6ZN6wHcx9ZEg== X-CSE-MsgGUID: zaVgRiNWTyi96YCWOyHl5g== X-IronPort-AV: E=McAfee;i="6600,9927,11057"; a="21373481" X-IronPort-AV: E=Sophos;i="6.07,236,1708416000"; d="scan'208";a="21373481" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2024 17:46:07 -0700 X-CSE-ConnectionGUID: ESZCuOp5T52kOlnPShpdfg== X-CSE-MsgGUID: DFkA5bMkS8yRX0Rwzy2KmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,236,1708416000"; d="scan'208";a="30412622" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmviesa004.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 27 Apr 2024 17:46:07 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sat, 27 Apr 2024 17:46:06 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sat, 27 Apr 2024 17:46:06 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Sat, 27 Apr 2024 17:46:06 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) 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.2507.35; Sat, 27 Apr 2024 17:46:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HEt76hO7eK9jZ5BcNjjlotkAZTzY6cj9FNbkJIjl0tmbzje7f9h9e2zqj0TsI59gwQcfboPmw+teEQMPXL+B+gja5iaVZCkQAoa+3bGg/IHgXFyAki8ET7KbKBwNVAhL5N4TBcHjoDbu+Gf2o74bMi/ommVQ7ECY6q0jYGVxbwqm9STKmH5IEdghvyiqlwzBWOo7aURD0wv4Fwp72K9CErvIp4yo1FBe6IegwmpI1dhgQnTwdjUXoNk8XM33QMXzvIOncCIR9+vvncyo2quFzTj7PVPYO8Zsdb9RkDM4dj13bFNvPxgVS8NynqNcxC/ZbvhaxodA9a9REs8aPSb+Xw== 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=kJK+xbe+tsX8fMK6OnDli6gLPq8eqJpa1zyR/Vd8Zqs=; b=gVGcvi88RzoFRGLB0K5h/UpabRQk3dIEd6Ckij6mhM+4QaOYUXHISEUURzdkkJo3rakyB21UpZ/8O8gEhF2lQUWQhf0FLNFE+nYUQ52gXdAbs2paVfieuEACx6bd/zfEzb5B7LsUHb7piPwt8Kp2fuNuRuhUrcfX7P3Meq4MUvETOuXbvfZ3Rs8MyyB8BE8eN5CvkJ653qtiQGUFqfjydU3R8br8+xYV7+9Bst49SJOB8lTIEp9IlFRQ5mpvdrlBZeDtlkTvKtV1/+fjjNtL87iRHmkOwvJD9Si69d9MjKdwALiih5u59KuzeJG2xL8uwqFwedMAYTy9k5pDbA4PwQ== 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 PH0PR11MB4775.namprd11.prod.outlook.com (2603:10b6:510:34::22) by PH7PR11MB6721.namprd11.prod.outlook.com (2603:10b6:510:1ad::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.32; Sun, 28 Apr 2024 00:46:04 +0000 Received: from PH0PR11MB4775.namprd11.prod.outlook.com ([fe80::a8f9:b889:964f:c495]) by PH0PR11MB4775.namprd11.prod.outlook.com ([fe80::a8f9:b889:964f:c495%7]) with mapi id 15.20.7519.031; Sun, 28 Apr 2024 00:46:03 +0000 From: "Du, Frank" To: "Loftus, Ciara" CC: "dev@dpdk.org" Subject: RE: [PATCH] net/af_xdp: fix umem map size for zero copy Thread-Topic: [PATCH] net/af_xdp: fix umem map size for zero copy Thread-Index: AQHal3X0NdCqwzNRlEWfqf7wkDAJ8rF6XluAgAJ6TuA= Date: Sun, 28 Apr 2024 00:46:03 +0000 Message-ID: References: <20240426005128.148730-1-frank.du@intel.com> In-Reply-To: Accept-Language: en-US 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: PH0PR11MB4775:EE_|PH7PR11MB6721:EE_ x-ms-office365-filtering-correlation-id: 78843605-40dc-4687-093d-08dc671c9509 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|366007|1800799015|376005|38070700009; x-microsoft-antispam-message-info: =?us-ascii?Q?tbtwyFjVgjVbDtCcS56IuuzZk50KCbhHp7HKw8zTZnS9PQT3mDa9/UqZJJK5?= =?us-ascii?Q?zGBPMf5cV7vI/voFWs7prVDnspkFA2aQDduHRu7jWQAwFW9gtYK8o0/Qbiqk?= =?us-ascii?Q?fOd049F+Bh10Su4Y+eAU63Ppg9nlxZy7HhQs0lgkhMkgqdDlZn7UcI4jwvxS?= =?us-ascii?Q?omKL17yNzYfabptDcFwJTZ/bUCa5xS1VXcPygZxPhS1ylfaOm2R3IQpKunuI?= =?us-ascii?Q?kd+zMjafZ2AdEPptKk6OduIMxxiaRdqF28VA38iXsoVO17TTLXfF8BFGg9oj?= =?us-ascii?Q?XeYcaGxI7FFtPtdBJVseXlrCxUyVo3as0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Cj6MVsybRAwFb8hobqPmdaimWfQXG/p2SB4gW+H//Sji?= =?us-ascii?Q?3aAoFXuRvSuWzb6SPgLoDG2VuYuM9+0WsYq281Cd0MXZgO80U4Ua3MzFs353?= =?us-ascii?Q?RMPUyUemXIXNTHP55xc/JMM0tRhIRR/NqkeRAKUt5L8XSQ=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB4775.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?56cIvIueFRtEUj5iQtotE30obazGrK4yYzeVHGNZyf2hRlLxi5ZZfEiJtVdH?= =?us-ascii?Q?3JDj2YehE5zr7rdMv9hEapAPInj7mj6up40Q3+FtALfYyLMMdinexyV5z6aw?= =?us-ascii?Q?a1yCitWoVGgfrFi/HIMWD5AW0q8tiOuueH3NTlB9B0X5QvH97OxLEtcwKzfU?= =?us-ascii?Q?RA2ZR+c7d4edskBEk7RA1V80CQdIE/XfZvz98BNzzNiVyrGaGPL3X2J/VbMH?= =?us-ascii?Q?9zoPMrURFJkG3VkH8e7iU4QZ9blEIJdd3vROH2JQlkzM7CHv22lkj/yLljGm?= =?us-ascii?Q?PYzhjE8iQBcA0JPQVnQksav87yvcuuaj6Un2wzhqhjR5n7VhGiHY9LtnLHvS?= =?us-ascii?Q?Rp5Z6DGxAe7AeqK9FTmnWU57+6lykwRFKMOzDn9YbaOopNIQAVeB6AsmBVA8?= =?us-ascii?Q?vyvbwJBLmf24fwsOJFdT/BEdxWPgkU7VuOdk5aJnufPYeUtnJi27SrWDBmBt?= =?us-ascii?Q?h+EZvAUJiXig2Hr2bOioBdPvIW3u2icrAD2tBNvXBL21CTpNjc9CRs3nVIb4?= =?us-ascii?Q?ifggZYk/dD880H4y3Lso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oerBFZC/IgR37O5dzccMNlVkjOPCYIk0FWaYmEfKbMU4G3qBzNcxPTYzY/?= =?us-ascii?Q?zZ6pyKNs3F7aOiI4GV6JGmdhhoE3QGjVN1AWdqIVDiLXArFyEzDjIs9F/4gJ?= =?us-ascii?Q?PZjTwe8pnk53+dwl7/9pNWJlQ5jUTBI62Bld+zwo?= 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: PH0PR11MB4775.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78843605-40dc-4687-093d-08dc671c9509 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2024 00:46:03.6622 (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: J1qarR+rpZv0BWAk9N//hGGjFoY5lE2MgboUOpEDwfEYclMnm6KAUICKW4pSZPEyDu7eBkR48kQ7h7sOE8iQ4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6721 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: Loftus, Ciara > Sent: Friday, April 26, 2024 6:44 PM > To: Du, Frank > Cc: dev@dpdk.org > Subject: RE: [PATCH] net/af_xdp: fix umem map size for zero copy >=20 > > Subject: [PATCH] net/af_xdp: fix umem map size for zero copy > > > > The current calculation assumes that the mbufs are contiguous. > > However, this assumption is incorrect when the memory spans across a hu= ge > page. > > Correct to directly read the size from the mempool memory chunks. > > > > Signed-off-by: Frank Du > > --- > > drivers/net/af_xdp/rte_eth_af_xdp.c | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c > > b/drivers/net/af_xdp/rte_eth_af_xdp.c > > index 268a130c49..cb95d17d13 100644 > > --- a/drivers/net/af_xdp/rte_eth_af_xdp.c > > +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c > > @@ -1039,7 +1039,7 @@ eth_link_update(struct rte_eth_dev *dev > > __rte_unused, } > > > > #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG) > > -static inline uintptr_t get_base_addr(struct rte_mempool *mp, > > uint64_t > > *align) > > +static inline uintptr_t get_memhdr_info(struct rte_mempool *mp, > > +uint64_t > > *align, size_t *len) > > { > > struct rte_mempool_memhdr *memhdr; > > uintptr_t memhdr_addr, aligned_addr; @@ -1048,6 +1048,7 @@ static > > inline uintptr_t get_base_addr(struct rte_mempool *mp, uint64_t > > *align) > > memhdr_addr =3D (uintptr_t)memhdr->addr; > > aligned_addr =3D memhdr_addr & ~(getpagesize() - 1); > > *align =3D memhdr_addr - aligned_addr; > > + *len =3D memhdr->len; > > > > return aligned_addr; > > } > > @@ -1125,6 +1126,7 @@ xsk_umem_info *xdp_umem_configure(struct > > pmd_internals *internals, > > void *base_addr =3D NULL; > > struct rte_mempool *mb_pool =3D rxq->mb_pool; > > uint64_t umem_size, align =3D 0; > > + size_t len =3D 0; > > > > if (internals->shared_umem) { > > if (get_shared_umem(rxq, internals->if_name, &umem) < 0) @@ > > -1156,10 +1158,8 @@ xsk_umem_info *xdp_umem_configure(struct > > pmd_internals *internals, > > } > > > > umem->mb_pool =3D mb_pool; > > - base_addr =3D (void *)get_base_addr(mb_pool, &align); > > - umem_size =3D (uint64_t)mb_pool->populated_size * > > - (uint64_t)usr_config.frame_size + > > - align; > > + base_addr =3D (void *)get_memhdr_info(mb_pool, &align, > > &len); > > + umem_size =3D (uint64_t)len + align; >=20 > len is set to the length of the first memhdr of the mempool. There may be= many > other memhdrs in the mempool. So I don't think this is the correct value = to use for > calculating the entire umem size. Current each xdp rx ring is bonded to one single umem region, it can't reus= e the memory if there are multiple memhdrs in the mempool. How about adding a check on t= he number of the memory chunks to only allow one single memhdr mempool can be used he= re? >=20 > > > > ret =3D xsk_umem__create(&umem->umem, base_addr, > umem_size, > > &rxq->fq, &rxq->cq, &usr_config); > > -- > > 2.34.1