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 50317A0543; Thu, 22 Sep 2022 13:52:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E560940156; Thu, 22 Sep 2022 13:52:55 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 93B79400D7 for ; Thu, 22 Sep 2022 13:52:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663847573; x=1695383573; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=yYQjYAbZf3L418g7O4aQPzL/CYhBXhKAEYUOphbn/vA=; b=NVzI69LXw+DMQcPNtohhL1QJzLRCei1xvd257sb4TZHZwx+0B3/Fo2kc OLiEh+ZxoZX8nWafCIKMhXLFKd9IPM726BXC5Cs9kWy307dtQc5Y/pIDX 3+woRipM5MBk1nHfdcoDOqu7gg3delNLU/LJWgGx/IvG75/tLD/w3FleJ iLe9Xd3OKenc4Vr0zVgStSXKGBQojBnbGRzCwKdWnGgIEaBQoCg0QDTxT eknbkvIA4YnOsehuOjdXR3m6upj0pbx0vF7nVuixFLKsQt+QDk6KojEeu iVK0I+gpxvJ2sAJSHnEYOFCjPSDQRIk6UswaMv1hrw4VT5e1tYZkM5nO5 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10477"; a="283327379" X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="283327379" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 04:52:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="622065459" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga007.fm.intel.com with ESMTP; 22 Sep 2022 04:52:52 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 04:52:51 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 04:52:50 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Thu, 22 Sep 2022 04:52:50 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.40) 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.2375.31; Thu, 22 Sep 2022 04:52:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mBA8xZrBpnxjaqZn/vgvQBru/z+uMV/dEMHjorFsNGRveIEQR5e1+cdmrWd1/juA1hGHpFCkT+1xS9LSas9u5+hvvEipB5fMn77nyEQWp2mgutKpXON1iRVFiHQbxs+/dH9YQfPhehbQ8CDiS2l/eFIU/Mu5+OehkZPCxbM3fcYeO+FtA4wRKoXCCPogq3JyxJr1QGM3FeKGIewAADvXCJqXgdmAuX4GHt4SVWLuAQC+lNCi5If6Ur+DMvjvGtFGm89i2J6Md3qvjMP3i2WqTyHYOiMWfOSWFNqjMX5KUsHQ+CRMLLImWinFVwyQ+khULd65YAZOYMpbgjJt3LY8wQ== 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=/hvOzHog8uXrli3SIOM3vIGTVbbvnzTm6k18cYsXaes=; b=HreVHLag7di0CmV4hz67dyL/Q9vvtqFFXIqOIv0yxNJz/dANXriQ0aF8QBJH56RhMMktBcqSiI13XjWUh7TcLpzcvtQJMV+GZ+KDZE0LicevCdU1DMJiheKNwbCaKSrOBNzo86xoZrYOkFo73hOOcRntcEuzX/qhnAEL5EFIzor7LRsCQzeComCsibrfKGRGzbdC6bnmR+ndC9BMHDfoJDqnMGUJI/l7FsHvlSLDnq5viicoCPiX/4QNNLW3fzgCHbfU9u9iw7mjyunU/vHIOkE0FInE2r1nPJ2XsZhQ69ti5kQKR+2YE5nFl3Mp9ofMtZ/rRijMJVLUGcQKUgR9Ww== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) by CY5PR11MB6137.namprd11.prod.outlook.com (2603:10b6:930:2b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.19; Thu, 22 Sep 2022 11:52:49 +0000 Received: from MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::13c:8120:d994:16d2]) by MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::13c:8120:d994:16d2%6]) with mapi id 15.20.5654.017; Thu, 22 Sep 2022 11:52:49 +0000 Date: Thu, 22 Sep 2022 12:52:42 +0100 From: Bruce Richardson To: Morten =?iso-8859-1?Q?Br=F8rup?= CC: , , Subject: Re: [PATCH v2] eal: Pointer alignment check improvements Message-ID: References: <20220921142830.71272-1-mb@smartsharesystems.com> <20220922114413.106291-1-mb@smartsharesystems.com> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220922114413.106291-1-mb@smartsharesystems.com> X-ClientProxiedBy: LO4P123CA0156.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:188::17) To MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR11MB1629:EE_|CY5PR11MB6137:EE_ X-MS-Office365-Filtering-Correlation-Id: a79e1067-496b-4385-b5e4-08da9c90f87a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WNdzd6vqVwUUdiw8oQyqJZucUGIoWRq7mlthc2V9TIgVkzNMPHTbpgA9NMuaV/zlupcGzukhywT34pl3mSHFqKmA1gYEJha+WV+4NGZQNXTSh0uqMV/wWobEgG9S4tIBVT+sDL6SfxvrwwpMJUrObDH4fP9C96/veZY3QGlNUIHYC9fLOhC0DcrYyytAnA1g/eUVJ+HKOgWb4nXHHEAWTDqpI4PCBfTI/jK90/bM7mvE1udo68bZfDUg0Af3MP4I3zxhneajvUcGnlyOipwyDKqtRtWCQvSsJCOgJEh0zyHVYnP2MGBBw36iBLy9pi2/f1MN6mCtVmmlSzUAQOUmhx3FOUxFC/84+KB1k9KiaLMfJUi5ApiHWdmNnIUQ+Dqo1f93s4+1foPhwJ9BchgFa2D8U8i0dcR3CUXzNEE0d5YUUksLaaJBuvzb8yoDBCTu3aAuq8omEHyYdSutEaNHMdlva138oaWF1uvqnuexK50kacu5W6MeQcEmBIovYHPNJhAeFnebE7xOk9FUyk/a9gyZXhzTIinoCFbxSy1sayhVu0bPeW2hGS1wp30jztbBv369FJTrEmAS8c2LHauyVmP6Q/M2ZZO6Dn0OsWWtzncVSJhejwoyn0JQ4ZKFkIydlUE+vltpSP4Kzielmug/jjTou1dPZHWokCmqfDxluE2ClZkPAL19gXgeMQu5iqdJ8AdWkPBpJkDvFvS/OVIZMw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1629.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(376002)(366004)(346002)(136003)(396003)(39860400002)(451199015)(66574015)(2906002)(86362001)(82960400001)(8936002)(44832011)(66476007)(5660300002)(38100700002)(41300700001)(66556008)(8676002)(66946007)(4326008)(83380400001)(6486002)(186003)(26005)(6916009)(316002)(6666004)(6512007)(6506007)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?yVkYxzS22nVBa8wnSpj7GZn93E7BYo36/Mx0KlE4cuIpknrLPvOteT2q7U?= =?iso-8859-1?Q?hPq47rAET4v4Yza6nADuV9MEP/HyH880zP4QHs4HgMr3KuNST6+lokxc9S?= =?iso-8859-1?Q?Q0R+l+LpbqF/5mJ+vbBcVmfsCfNApaUsLoIKZID1LB7Zij9nLXdFqVaVaO?= =?iso-8859-1?Q?btuphS9BSomTGeiyLW8aaCzVzTJC2YAM852UNnv4pB/n84+cmAN+p1B4Is?= =?iso-8859-1?Q?TmN1SBh7xX4I4389upMIxLlPlGVyVaYZgu0RnbdWAY5Zu7hK5OnyHc7UGp?= =?iso-8859-1?Q?VpRtvgRa8+4tPQVM5RPLedFo/d5UnQoRvJB3RdK1YfsXj05PTzh+LuzGCd?= =?iso-8859-1?Q?cSapn9sxOdZitUOd/qkjZKk3NK3Vaflb15E0UnCt+yRxQqzO2egzpD5WRp?= =?iso-8859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zvp7x1uS54yWlCKbz36YNZ7yiTW9FsxqCbUa?= =?iso-8859-1?Q?b1Uok2Anz+kcXyKM6NjIQp6+fKC/MwUT1EMSIhR/9og75e8pk63L22SSON?= =?iso-8859-1?Q?m5GhGm28DGeMY+L7W2kKWddZd2vVhIRnH02j7RyB/VZe+Nu9f+6EgZPm4L?= =?iso-8859-1?Q?Wrq2fW91eYZIs5uc1elzLAukLJjaXOB+9aRpsYrtKT1zmXYdDtfe20J4X+?= =?iso-8859-1?Q?d7VdPuq+46kdPay8n+RYmf/e/rC+s0StGVGE2iQhK0psXEvv/YXIhrCvxR?= =?iso-8859-1?Q?cPuw34PZfWenqY2xeMb9CyKlhNOwJQ6VfTzA3fw4Nd9TJsEl84IEtB04h4?= =?iso-8859-1?Q?cSXJBvoq1ARyvHIsxsSW8Ha7BtRBuy71nilGMIv5UAapng0LeH1uWd6g?= =?iso-8859-1?Q?=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: a79e1067-496b-4385-b5e4-08da9c90f87a X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1629.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 11:52:48.9048 (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: hTA5++WSv+x2h8BOM83IPwtsVKP46tScKZJ1HFpIt9hQlTdaOG824inZKJKPA8lnDDEcxxOgJdEKNBHQQ2TW0v7LJ19qyHL+q96Xvc2U70c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6137 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 On Thu, Sep 22, 2022 at 01:44:13PM +0200, Morten Brørup wrote: > Checking a const pointer for alignment would emit a warning about the > const qualifier being discarded. > > No need to calculate the aligned pointer; just check the last bits of the > pointer. > > v2: > - Remove compiler attribute ((const)) from function; > it was a coding style issue. > > Signed-off-by: Morten Brørup > --- > lib/eal/include/rte_common.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h > index 2e22c1b955..ed81e0db0a 100644 > --- a/lib/eal/include/rte_common.h > +++ b/lib/eal/include/rte_common.h > @@ -404,9 +404,9 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) > * True(1) where the pointer is correctly aligned, false(0) otherwise > */ > static inline int > -rte_is_aligned(void *ptr, unsigned align) > +rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align) > { > - return RTE_PTR_ALIGN(ptr, align) == ptr; > + return ((uintptr_t)ptr & (align - 1)) == 0; Are we confident that in future, or using come compiler settings, we won't get an error due to using "uintptr_t" rather than "const uintptr_t" in the cast? I would put a const in there myself, just to be safe. A further point, only-semi-related to this patch, which is fine as-is: looking at the code for the various macros in rte_common.h: * The various macros for working on pointers can can probably be converted to functions, since they don't need to work with variable-sized types. * We can then see about properly ensuring those inline functions are const-correct. /Bruce