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 016E045C76; Mon, 4 Nov 2024 13:19:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BDBBF40BA4; Mon, 4 Nov 2024 13:19:20 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mails.dpdk.org (Postfix) with ESMTP id EBBBB400D5 for ; Mon, 4 Nov 2024 13:19:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730722759; x=1762258759; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=AyV1mwkBv5SQr4xW8SHd4eJ/EObrRZtlB8atr0NWVrk=; b=iIaM/2ANj1jZGmi5CjY/IC5qwZVdcmw63tYX3wAP7sxgkymUNNANIQYV qF+lSlfnkunMuRkT7bhTzzr7uy0aR4+ha17S2Hkqq9LVnHfeih3dvkkcc qF7ZPf2SSRjprJWeMDq2Uxl7lxyLWwvCQAuEGEzAiDYmJGE9MaazVkW95 WvQ/NrIM+vUzJ7Gj0PX7FwfCuJo4ofFx7ExTSrPUDeG1S+SOIkmbL3CT7 QdjVXMGk+ZdcXVADOCGfCPK71ymh6X5IPo0JBk37Eb1+DiTqaN10G645W /6Np7+7L4v4qMQKdHOw9ItJxK+a32e8TLbAjHvJtlJRVxMTlUccAUacqn w==; X-CSE-ConnectionGUID: W+AT8s24SRCHLKGX9vARfg== X-CSE-MsgGUID: uTCY7g04QC2bZxzvaN2btg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="40965796" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="40965796" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 04:19:18 -0800 X-CSE-ConnectionGUID: zAQNQQIiS02Z4fWtQ8U99g== X-CSE-MsgGUID: /eD7invrQ0WMeLVY1RPiWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,257,1725346800"; d="scan'208";a="114427571" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Nov 2024 04:19:18 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) 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.2507.39; Mon, 4 Nov 2024 04:19:17 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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.2507.39 via Frontend Transport; Mon, 4 Nov 2024 04:19:17 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.44) 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.39; Mon, 4 Nov 2024 04:19:17 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JFomDns9frD59yCmpuQIEUyY9fFrqu+TQ3MNBYipI+aYKuXTPdnK4uNRRZ+ltqduY9pIOEmOr9MrdqF8Oc5l3ba4ET6m3go+Oh7R9M05vUrTixni2ltXsfeSvHHbFXTQWKA9/+eCSr5AwMDTBXTjvoy+yaaD2HGfMsZMAqgvZbNwMGHmQhdh7HIWnvePjBciUxpA4SnbMxpDsByXTxaQclNSuanSWSpJ7uA88uD/dQuSXf1ZQ3iEyZXbJRJ4tkI1b1UL2F9mRPuzHluTfvLswrRBlLwsQO0p4PLefKl+7bbfXDZWLI7Il7e1DkQcCZhI25rRcVswWLSo6+SVq+l2CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=LIhF9rKpReTaBbxJ+sdoWpjDAAwLq4ouZCacyLCcvds=; b=k7Fy9svjnV3ndIHzynkd3WS4FRY80eOMDO6T7edVT3fupRzWmHjac2Jn0CCAVsLKRGXWxltdwlwTeEPD30apabpY6Zaj+D2NbgFNOihSDdwrrebMq6SzXY1WGb0qN8JOtBI7xXHso+QLyeC+izqIOA1fMW4zg25MbCmryjYF56zGYQU6+5LF3FHr5SZoiD6EmqPxF4wiNjZJNC8ISDOlWzAgUogfHCl3ujq9P1sYZFwGU2aCpmXaqRzjEy9BA1cJgdCzWZJcmxY1+WApg0HssE3YGaBmG0ZL++MbJgm4Bi4cra0vJN4RKbaeYlsMtqVehVkq/wdHNjjnuJCmPqY6WA== 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 DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by SJ2PR11MB8324.namprd11.prod.outlook.com (2603:10b6:a03:538::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Mon, 4 Nov 2024 12:19:13 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%4]) with mapi id 15.20.8093.018; Mon, 4 Nov 2024 12:19:12 +0000 Date: Mon, 4 Nov 2024 12:19:06 +0000 From: Bruce Richardson To: Morten =?iso-8859-1?Q?Br=F8rup?= CC: Tyler Retzlaff , Thomas Monjalon , , , "Ferruh Yigit" , Andrew Rybchenko , Ajit Khaparde , Somnath Kotur , Gaetan Rivet , Jie Hai , Long Li , Wei Hu Subject: Re: [PATCH 1/2] eal: add unreachable and precondition hints Message-ID: References: <20241025115223.1230680-1-mb@smartsharesystems.com> <20241025115223.1230680-2-mb@smartsharesystems.com> <98CBD80474FA8B44BF855DF32C47DC35E9F86E@smartserver.smartshare.dk> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F86E@smartserver.smartshare.dk> X-ClientProxiedBy: ZR0P278CA0015.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::25) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|SJ2PR11MB8324:EE_ X-MS-Office365-Filtering-Correlation-Id: de399b18-2197-48e6-1724-08dcfccae46a X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?Q?FXUUeFXM211bX8aWLU0lnaf0RZn+bl5AkoVGPb/jo+TW5TRJf62fZ6B5K8?= =?iso-8859-1?Q?wsK/CBEqmGSsKf7zfs6WXRgsKZH/AeQLn7mXh2Z29Ey1ZsylM/lt0H+vRX?= =?iso-8859-1?Q?oZ07S8j9rT6pI6iVkfr5IUXyaKLle5FxeBdC7v3Jtr7sqsdm34hJo76hzS?= =?iso-8859-1?Q?vAaBgOAFJmS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=?iso-8859-1?Q?WkOUOuRBSVsfxC+pWjcYRnt9cJE1xVogroOkSC93KimGUoEeyt5P8GPRGs?= =?iso-8859-1?Q?4cpbkPRB/mr/KO4EoJbycffMLd1yauPdeZvoby9xWpmePd6Q77WrpfgS1a?= =?iso-8859-1?Q?imrNIxad3qd6M7Mwam5EiAtvW2jCfeXXdoDqeC1Djkux2UdV3DAPANSK/c?= =?iso-8859-1?Q?zZDMenbz5W5IjbqzSjFHTBjxeTea93Qu0tUG3ouwqKmyilbE6QYW4H7fi2?= =?iso-8859-1?Q?dgYHmWvxahGaCmNl7Nr3tfvjGN+2EpBJjT47QRqLh/tuNPqe7BuUdv8Mok?= =?iso-8859-1?Q?UB72nBaHqt?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(7416014)(376014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?R90/XgMGucR1FWHmbicOkicOa+U792MZWzS8CgzE3PDMI6H/d7DNEvy+i+?= =?iso-8859-1?Q?IPntBI09PRmfSuNB/Hq96TX8VhaisJ+ROXg/qIVin4QKu9N3e23ZC3msbm?= =?iso-8859-1?Q?1eak63gDL3SAEgZ/3hZbzqVmLlOnSl0OvNhLrYblTEvXbEURBs6bnfBXkm?= =?iso-8859-1?Q?twHOvHOkCUvODTlko2U9Xa7Kyfzjs04UR0mXtNv3aHZv1jEAMyxdtjUHuE?= =?iso-8859-1?Q?pL2JplvV9/7J01d17TTz/4eRp5v1vfHe03/gfQpsrNXeIidcLYO2DT9mQn?= =?iso-8859-1?Q?xIJdB0csgIntsu2UJ52PBUnJiUk5CWdIxnNW8nCARDfAqKimHtytci8vRT?= =?iso-8859-1?Q?RRb+j+h8QAxF/mClBxfqMJj+KxDqlZH3FiVfad42AGwkwMVgErIy5efEhA?= =?iso-8859-1?Q?G43AhDLE1XoHSV1/jxwmETtEm43GcJPD/zHkk1VytcWbXABlhoC3r/y1k+?= =?iso-8859-1?Q?32gh7ZYA6qiC+mjISnmwLeVJuGJ+4ENxxBDotFnK/S1jINmf45ImU+Ajcw?= =?iso-8859-1?Q?tBJR86eVs+1Iei/BCtwQJ4sVyihx0YEITcZx4mFkM93+wSAq/LG9LlgMDC?= =?iso-8859-1?Q?EJzZOJJJ3CN+mloTWOPwEVNQ93oQdwA9RF7NFipRC6n4tn59/CKowoZIpl?= =?iso-8859-1?Q?azyLQyeX7OrnPbtDlVcEC0wbAQoKOT4sYm0y0wPh9opku00tv0R8cqWzts?= =?iso-8859-1?Q?NdZnp49xmtcHh9zD+C1SgWxMQz66OS0r7UMO5lV9xUpQm2rkuuy+Ywc33A?= =?iso-8859-1?Q?CvgirWBzfI3CA7N3cPF+NzdrccRbAtA8p1+USQB6+qoqivRMW5riYa+q/x?= =?iso-8859-1?Q?plHH0muRqedjViAerykJqCspN6dQtCbsIBkBkSpSU1LuVk6p1bqhziAjgJ?= =?iso-8859-1?Q?gtOsplr8Qh2NDcFhUCACAW12eRkdURYmZJH8N8ZPlEjsQYPQAkFbHsp2m8?= =?iso-8859-1?Q?7vRZn0W5EqecyPRnZZzCqtKxvOanQEsAef74gF3nClTo7YB1eOfGNRg5W4?= =?iso-8859-1?Q?riHSQomIJsQPF5oviy6arkuXpEGqB55rQcaUTpgnjKosEhRgwT2wiXSjBm?= =?iso-8859-1?Q?dFo6QEG+XUXt22riagY37G5Co+K+DFhKqoP6XzzgxW96kInMzX/JJOyH2e?= =?iso-8859-1?Q?fPv7ZeDBIFtl+FPwDxE0sqBOc7ZUapQamv9fCGC82vXvl8bmRFlm1gtG+4?= =?iso-8859-1?Q?UOanotXA3Zxddb+Xz1n2kHpgQEUcYD+LTt+5N47dHngLOAz4RJWQcFTFOe?= =?iso-8859-1?Q?HgcP15hiLMC1RHx9dHSV2pmxxSeJW0tXshrDXTA+XXahlM0HXlc12xbFQm?= =?iso-8859-1?Q?Gva9Q8GRFSCvfj+XXhUNLM3OMg3F5V2X8G543Lxvnwhd2AFNvOdWPWnKx5?= =?iso-8859-1?Q?0JIMSY0WaSay+9NdzUVKlHeJ0qMnzDlEbHDDwDxB7YyuJE+zGKHFr49K9D?= =?iso-8859-1?Q?ow1TiMGC/BUjud2lGYXyuInZ6OkesSa/EuhUDgmca3Mt6Z1oF4+lneP4pc?= =?iso-8859-1?Q?Equ8gPTjDglqkjgojO69xMhO8saaNSlDzhBSPVtc5UTbluzPwxgWzmucax?= =?iso-8859-1?Q?GA4FUUekcQCx0OePlvrTRe1jtDMvmxIljYY6OEGuziQfdh8qFmhHp66+wr?= =?iso-8859-1?Q?tkNKAkQQ6nCi4Nwc/fyjJg2OrgGqzvQGOtWmycsmxIqj0ec/03SzrxiQ?= =?iso-8859-1?Q?=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: de399b18-2197-48e6-1724-08dcfccae46a X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2024 12:19:12.7897 (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: rsTuXvHfvzxN9P/dlpTxD1NIODMOSJFCJfnM2gNsQXZYD6Wk2doJOA38O9nWr5UxLGKnoW6apEzpYTjB9jQX0W7UtlH9yXNoRDAYD5y8OT0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR11MB8324 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 Mon, Nov 04, 2024 at 12:40:49PM +0100, Morten Brørup wrote: > Ping for review. > > > From: Morten Brørup [mailto:mb@smartsharesystems.com] > > Sent: Friday, 25 October 2024 13.52 > > > > Added two new compiler/optimizer hints: > > * The __rte_unreachable hint for use in points in code known never to > > be > > reached. > > * The __rte_assume hint for providing information about preconditions > > the > > compiler/optimizer might be unable to figure out by itself. > > > > Signed-off-by: Morten Brørup > > --- > > lib/eal/include/rte_common.h | 27 +++++++++++++++++++++++++++ > > 1 file changed, 27 insertions(+) > > > > diff --git a/lib/eal/include/rte_common.h > > b/lib/eal/include/rte_common.h > > index c79f9ed319..2f143c87e4 100644 > > --- a/lib/eal/include/rte_common.h > > +++ b/lib/eal/include/rte_common.h > > @@ -366,6 +366,16 @@ static void > > __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) > > #define __rte_noreturn __attribute__((noreturn)) > > #endif > > > > +/** > > + * Hint point in program never reached > > + */ > > +#if defined(RTE_TOOLCHAIN_GCC) || defined(RTE_TOOLCHAIN_CLANG) > > +#define __rte_unreachable() __extension__(__builtin_unreachable()) > > +#else > > +/* MSVC or ICC */ > > +#define __rte_unreachable() __assume(0) > > +#endif > > + Is there already somewhere in the code where we might want to use this? I'm not sure about just adding macros just in case they might be needed in future. Having unreachable code seems a bit problematic to me generally anyway. > > /** > > * Issue a warning in case the function's return value is ignored. > > * > > @@ -423,6 +433,23 @@ static void > > __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) > > #define __rte_cold __attribute__((cold)) > > #endif > > > > +/** > > + * Hint precondition > > + * > > + * @warning Depending on the compiler, any code in ``condition`` might > > be executed. > > + * This currently only occurs with GCC prior to version 13. > > + */ > > +#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 130000) > > +#define __rte_assume(condition) __attribute__((assume(condition))) > > +#elif defined(RTE_TOOLCHAIN_GCC) > > +#define __rte_assume(condition) do { if (!(condition)) > > __rte_unreachable(); } while (0) > > +#elif defined(RTE_TOOLCHAIN_CLANG) > > +#define __rte_assume(condition) > > __extension__(__builtin_assume(condition)) > > +#else > > +/* MSVC or ICC */ > > +#define __rte_assume(condition) __assume(condition) > > +#endif > > + This part seems ok, I see it used in the next patch, and also looks rather useful to have. /Bruce