From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 4A4851C01; Tue, 17 Jul 2018 11:49:19 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 02:49:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,365,1526367600"; d="scan'208";a="73430566" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2018 02:48:59 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 17 Jul 2018 02:48:57 -0700 Received: from lcsmsx155.ger.corp.intel.com (10.186.165.233) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 17 Jul 2018 02:48:57 -0700 Received: from hasmsx106.ger.corp.intel.com ([169.254.10.9]) by LCSMSX155.ger.corp.intel.com ([169.254.12.58]) with mapi id 14.03.0319.002; Tue, 17 Jul 2018 12:48:52 +0300 From: "Stojaczyk, DariuszX" To: "Burakov, Anatoly" , "dev@dpdk.org" CC: "thomas@monjalon.net" , "Yao, Lei A" , "stable@dpdk.org" Thread-Topic: [PATCH] mem: fix alignment of requested virtual areas Thread-Index: AQHUHRVUSKqkse88xEm3j5vDe/OxJ6STK/9g Date: Tue, 17 Jul 2018 09:48:50 +0000 Message-ID: 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: dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2ViMTNhZDYtNDhjOS00NTU0LWFhNzYtM2U2NGI4OTY3ZGQyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJiSjdnNjJwSjNZOUdlMVwvaytUS1RoNDlhWGJlVVR4dGdvNU5ERWFSc25qQ2Y2YzBaUnd6WnpZSlwvWDY1SUtHdU4ifQ== x-ctpclassification: CTP_NT x-originating-ip: [10.104.17.213] Content-Type: text/plain; charset="Windows-1252" 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: Tue, 17 Jul 2018 09:49:20 -0000 > -----Original Message----- > From: Burakov, Anatoly > Sent: Monday, July 16, 2018 4:57 PM > To: dev@dpdk.org > Cc: thomas@monjalon.net; Yao, Lei A ; Stojaczyk, Dar= iuszX > ; 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 Acked-by: Dariusz Stojaczyk > --- > 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 *si= ze, > 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 tha= n > - * 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