From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id B170198; Mon, 16 Jul 2018 17:20:28 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 08:20:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,361,1526367600"; d="scan'208";a="71806598" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 16 Jul 2018 08:20:27 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 16 Jul 2018 08:20:27 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 16 Jul 2018 08:20:27 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.57]) by shsmsx102.ccr.corp.intel.com ([169.254.2.124]) with mapi id 14.03.0319.002; Mon, 16 Jul 2018 23:20:25 +0800 From: "Yao, Lei A" To: "Burakov, Anatoly" , "dev@dpdk.org" CC: "thomas@monjalon.net" , "Stojaczyk, DariuszX" , "stable@dpdk.org" Thread-Topic: [PATCH] mem: fix alignment of requested virtual areas Thread-Index: AQHUHRVT450+yaACsE2PltIcvMuWSKSR8nCQ Date: Mon, 16 Jul 2018 15:20:23 +0000 Message-ID: <2DBBFF226F7CF64BAFCA79B681719D953A4EBCCA@SHSMSX101.ccr.corp.intel.com> References: <1e4e38f022da0d791b454b8d9cddce61b479b7ad.1531752592.git.anatoly.burakov@intel.com> In-Reply-To: <1e4e38f022da0d791b454b8d9cddce61b479b7ad.1531752592.git.anatoly.burakov@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTZlOTY2N2ItNDZiYi00MDdjLWE5MzctMjQ3MDViNTdjZjM5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidityeGlmV1ZIRlRJTTd5SGh4b3RMYmNKaU5GNEJ4eHgyckNySTBzeDA0WUlhMTE0MWZXME1uNmNnS0J5TTZVciJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [PATCH] mem: fix alignment of requested virtual areas X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2018 15:20:29 -0000 > -----Original Message----- > From: Burakov, Anatoly > Sent: Monday, July 16, 2018 3:57 PM > To: dev@dpdk.org > Cc: thomas@monjalon.net; Yao, Lei A ; Stojaczyk, > DariuszX ; stable@dpdk.org > Subject: [PATCH] mem: fix alignment of requested virtual areas >=20 > The original code did not align any addresses that were requested as > page-aligned, but were different because addr_is_hint was set. >=20 > Below fix by Dariusz has introduced an issue where all unaligned addresse= s > were left as unaligned. >=20 > This patch is a partial revert of > commit 7fa7216ed48d ("mem: fix alignment of requested virtual areas") >=20 > and implements a proper fix for this issue, by asking for alignment in al= l > but the following two cases: >=20 > 1) page size is equal to system page size, or > 2) we got an aligned requested address, and will not accept a different o= ne >=20 > This ensures that alignment is performed in all cases, except for those w= e > can guarantee that the address will not need alignment. >=20 > Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory= ") > Fixes: 7fa7216ed48d ("mem: fix alignment of requested virtual areas") > Cc: dariuszx.stojaczyk@intel.com > Cc: stable@dpdk.org >=20 > Signed-off-by: Anatoly Burakov Tested-by: Lei Yao This patch is passed with following two multi process test 1. quota_watermark sample test( qw as primary, qwctl as secondary) 2. Testpmd with NIC and vdev(primary)+ dpdk-procinfo(secondary) > --- > lib/librte_eal/common/eal_common_memory.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) >=20 > diff --git a/lib/librte_eal/common/eal_common_memory.c > b/lib/librte_eal/common/eal_common_memory.c > index 659cc08f6..fbfb1b055 100644 > --- a/lib/librte_eal/common/eal_common_memory.c > +++ b/lib/librte_eal/common/eal_common_memory.c > @@ -66,14 +66,17 @@ eal_get_virtual_area(void *requested_addr, size_t > *size, > addr_is_hint =3D true; > } >=20 > - /* if requested address is not aligned by page size, or if requested > - * address is NULL, add page size to requested length as we may get > an > - * address that's aligned by system page size, which can be smaller > than > - * our requested page size. additionally, we shouldn't try to align if > - * system page size is the same as requested page size. > + /* we don't need alignment of resulting pointer in the following > cases: > + * > + * 1. page size is equal to system size > + * 2. we have a requested address, and it is page-aligned, and we will > + * be discarding the address if we get a different one. > + * > + * for all other cases, alignment is potentially necessary. > */ > no_align =3D (requested_addr !=3D NULL && > - ((uintptr_t)requested_addr & (page_sz - 1))) || > + requested_addr =3D=3D RTE_PTR_ALIGN(requested_addr, > page_sz) && > + !addr_is_hint) || > page_sz =3D=3D system_page_sz; >=20 > do { > -- > 2.17.1