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 5661BA0543; Thu, 22 Sep 2022 13:59:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4617040156; Thu, 22 Sep 2022 13:59:46 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 9946C400D7 for ; Thu, 22 Sep 2022 13:59:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663847984; x=1695383984; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=dx/47aGBAaldjgVMbSCmktGLi69KCtnUbXENyBZ1VWU=; b=S1y7ZOaLmKEJy6bw6NJoRaS8q3R8q5G5ga2OoDJHHWLGkEOYZXjVJZKY 1iUSyoMgCfF4Avwh/DUQynqc/ONaUrtPeZvxs/m/U9pmn+1QpgMO5zn6s z6piKJaofCqtKc4VRYRRnkzBROLXkVJ+TY5G0ObRfhZl2Dpj54iDbsyxc 8ezN250v1vzGcxbWZrK2KnJNbYWK7FEAmt8BuSpR12efwI42N5wWQJr+i Iea241jUKtgoCaa1r/hdIdVT+blYq1oVMai/HWApswRboggCbLb2MCZp+ MczSlhCyveH4v6Ah+QOdDhLNvPxUis86CN3ApsazZsy+NMAMpat+xJJoI g==; X-IronPort-AV: E=McAfee;i="6500,9779,10477"; a="326595707" X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="326595707" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 04:59:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="864826130" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga006.fm.intel.com with ESMTP; 22 Sep 2022 04:59:43 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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.2375.31; Thu, 22 Sep 2022 04:59:43 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) 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:59:42 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) 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:59:36 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (134.134.137.103) 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:59:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ED907LOg0RX43yeMc8x2vVs7BEWfv5rZQ5wkG0Bf2OdtevAmUQf+XibOwvWm4PioCSiGPVDMQazTZtA8PVf0l92/k1uaSsYejvrBJJPMkAvEN4f26GWtntDPoJqy7iBMXhbzx0K42SD7AU2mgTcSrF02xTXwvONsZtrSGA26CZYv5TvTG0hCFB3X7qJz1QjOKW7AvJAow9AmJLc8b/s1TKllpJcuMed02wIeH1xVC1SqzU3j+RHfPiz0FElr/7LE0O/TFZX7CmK1WOUzNh0RtPUYzLXpCYKG57Uqs3vSzqR8DaCgvrWdIny39F9GKy0XV+cGa5ANAPVTuc4JZ00ehA== 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=uYkiRppI8qU9TSw8zOGaIg6RTgAE/uXNaUzNhXJyKag=; b=OGVKrlSngrfHFr9+M9yMvuuSx0YC1QoRvW2GBO4h89mGrxqXVwbk4jAYJm4kRT8icksbBSLJyjxcGyh+nLk96g1BwRFzDRAZmp/CsrGvqddbGcG7iov8Kbdxpzox7JwJCr67M7GOk1iH92uKzjLQWkS9HyGq7pcoPlFUVtECQ4axg7wVQsNNLAZTqno/1DeGmIgbU1z/hM4Md2VTEaZVDWyqLTPH/SewQxpkMiy/4pKI7W1patDxA2rMFbvBCVtUkZ6WNl74obAebOFN1A0ys4eQBYSe81cmuZNFCDOFFDo4h38UJY4OiLqegHtSNuT9bx+WwnhOrPRoHYVHKQjveQ== 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 IA0PR11MB7188.namprd11.prod.outlook.com (2603:10b6:208:440::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.18; Thu, 22 Sep 2022 11:59:34 +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:59:34 +0000 Date: Thu, 22 Sep 2022 12:59:27 +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: X-ClientProxiedBy: LO4P265CA0087.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bd::18) To MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR11MB1629:EE_|IA0PR11MB7188:EE_ X-MS-Office365-Filtering-Correlation-Id: 00ca4013-4c9f-4c24-c466-08da9c91ea63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kiW6u5vhAoovREjmq52X937dbbjqd2L0O4axEz6SGHn0GBak0lGVhKpdJmA9p67cCC+joTFOma0FPFRQ4vV80TQyoByfLzydZCmtj96bk/Iq3t6CxIg5tFJdo0jggcRIQ3jiGc4RqMb9MgJg/lj4biRvo+xafJeebd1cvH3m6DtYYdmxbo7t3wyjm8yxZNyC3AsdiJQbLoEfALFPNE993YM/2JUDX86GuDndb29Dg4aGUiRbpu8Cn7rLNzwbBdzh1awBUU2RHfW87xTisj39muT17PXKT3DeVqDLxyDMBq3iNtFIV/h40NaOmEqG8EPI4MtzHQsLwTkcdzg0vVpR+ZvlR9Q75VWydh44WmHpeLrnGDHwitlXbSVR+f2LxlHRtFxtGVwTctdOCclDAWZFEA1DRJx52/4afl4cQO3XLzpNoeAr7iBz3+f71TQUqn0mH+yzHWx9Vhmjnqin70QDXTSuIdMZRGbvgTcijAFjXn1qWeiHgaf/9PHS1GonyFHe3w5kZyLyOCcpG4EVpJCPzf/4RWNRNRBQSejIQ/8ZX6QFhjTg13pek1zqZFSW/CQ1A9qVVZMRnL4cC8WD5iV4BjMbRoC60Jda80jjQMSD36fN8+3MgwWzrFAhK0DdENsZbvCAgahmGysCQ/8kQ7bxEAIPExwJsZfaCUCtfiRrN+TJpAeqw8N3o6FdJZMWQEDIeyZP0zCyZd0OdFgudwFa9A== 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)(136003)(376002)(366004)(396003)(39860400002)(346002)(451199015)(66946007)(5660300002)(66476007)(8676002)(316002)(66556008)(4326008)(44832011)(478600001)(6486002)(8936002)(6512007)(26005)(6666004)(41300700001)(2906002)(6506007)(38100700002)(82960400001)(66574015)(86362001)(186003)(83380400001)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?ruE8zcKCIp0gVpb1F4c9UkyRdKHpbBhZLssJMftJk/xTwL2Sqoy8ZPppwP?= =?iso-8859-1?Q?oTXCTPm3FE1X2zPJfg7MfVgURqn80ZyePo2T3eIGYawBDbU9L5C5jTl89y?= =?iso-8859-1?Q?UEe7PkxpXjFo8AlXwlRRmMOJywbrQBbLxyGdadOzVRW5tsLmGdp1rVxfT2?= =?iso-8859-1?Q?xANPbgV3E2MSeYZDCovYxwZPI4vA5g2wU+uUyM2b+KglmSZmQnp+eOr14U?= =?iso-8859-1?Q?kpMeKYlYyh/fBO5IU8ibh31iCmv/dr+Ch80OFR5AUl0I/MDSNPkWrmySgw?= =?iso-8859-1?Q?CSH+srXSRF2odeKEhlvR9kFcnwoW/XdlD28OOKhDoiYMy5cgbAytDXybAr?= =?iso-8859-1?Q?FEdAEi7A7QRNZq9DOmYAxx9/Ks1NLmPgNl423hJp/Yo6i4tpDHRfqXeVxt?= =?iso-8859-1?Q?YdEoprYa1S/mJ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so-8859-1?Q?hMLlDdQxLanCcgIIsaWhUOWRn+8jpeSrBy3pDMrnW08Vvyl3bw6/+hZbYd?= =?iso-8859-1?Q?FttrU4aL4X354QGvmGZNVXbo1Xj5iLKCnM/VPhrtMKgCtWta3/DURUmcGE?= =?iso-8859-1?Q?z7C/2/sMX+oWp8YCQmUry85WUxX0doSWHTb3p0+qvVbDFl+pu4Baq/L+hy?= =?iso-8859-1?Q?pcauYGTL6d6PNuPbSfi4xAIkt835pAMvokpzIc3+PQBoEhBOM7zlRWCScF?= =?iso-8859-1?Q?vzLNCt+sNpbcwtRMCMsbyFdC7T7B+thvyExyzqyi1ztKSjtKqUH95DwpNb?= =?iso-8859-1?Q?ecUmD1nP8maoLZnwExjIEV1clxtvh60JqP3eJdikVLEPe8TSUNdAej8wiW?= =?iso-8859-1?Q?Z7+tqpDTyPtwLXpuJLY=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 00ca4013-4c9f-4c24-c466-08da9c91ea63 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:59:34.6381 (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: Cr69FJuXRxb73FdURTI0cgk9+olRcjcv6iua7QfygAWkLhiHzji5ZTq1obcysFDsmdQjpGH6xhOEgVMFLbIHEg6li97GT9TjYwhJEjk92Go= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7188 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 12:52:42PM +0100, Bruce Richardson wrote: > 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. > Actually, on further investigation in trying this, it appears that the macros are used in a number of places with integer data too, despite the "PTR" in the name, so things are best alone for now, I think. /Bruce