From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.200.25 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796265072; b=JpeTQb/ewmWiLvYnczTy9C16TRswCA7SwDcHDLbgtIdjmTdwzoMeL+ABV0FEmS1Xytsb 320paOuldAMuSgzcJzyjuee7zip0/l/+tuI5WpOw2shNAGqTHZq8GCf7XEpD6r++MTswW QYEblsiDIpkPLLvu/08TNNsLN66D+VzAEL9ksaqG4RY9rst0vT35Qt8y9MOWKXIgJlMVb lkpi0CdfztQrpnICfs+fQeDeBaVAt8UuQpEWHsAgs7KChUv7fpimeM7Iit/vaQNB+4rOq snJbQgNrT8vAcMkXUoPxc8vqqkc9cEo8uKLljvimi0M1Pz3a8XhtNm7XejGmbyt8B0g== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796265072; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:Content-Type:Content-Disposition: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=9tEsnocPFaXQkUGLHpw0c2GCZW7WtZVNTqYEZMrd58Y=; b=tiWiXdwFv63QXDMHmX9ONJlIsz6mPtGUxc795K18/KU9QVxCba0QsdsutG98mtjrbE66 hTGUqqPmESpPxPBk323PK2bCNAM0uaMgCrhGqdJMLzJH1Eu5R8Wlv78xxKe87E6sChXtU skQcQfGsd6qqwKgLVlMDycp02CzOU/l0Hwh/g6cf8WCiq63eEfVZxmeSqNnfbvaU63cZc He7fOHgL/uMaDjcd79VaFQXUBRF2JFTZjvBvqMAjJNUJW8P0eVPoAdmJXo9XZTLeDiaVl acVwokIwhjwm6zxTsjrOo5fikFjwJll9RdmxzyYLw7pALDbsOX9+iQjYsVKhZDOK73w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=gkdtyxit; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.200.25 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012025.outbound.protection.outlook.com [40.107.200.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F4192606A32C; Thu, 3 Dec 2026 02:31:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F4192606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=gkdtyxit ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VBAxoKcXjc0plf39yqzKFCUxbRkdwz4FNj7UlFLrqv3JhKgo/L52e6bu0pH07A2me0+vDS1gzfeUHBXPYeLF4pV2tWNoJCpgGC7LmcDHty21tqEV9ea3aWJ5jMwsMkU5QLO/htHE5eB0VEdM4hreF3GD9d2Xi7g+idTesPlwFg/QFWKkk9ujEdRs51lV7/1n4uJrYMiGFeGBmdL/qEiKq3Cp01wSSLIFxlfJxvRkkMxs2mnAPy4XBb3R22bLWtFDKQw243ev8E4T7DYPrCCY5Zep8+O7VRRys5UTYu8qkHZ39/7fV53+nNO6Wd0emo6BZ9+n9FM92lWp3zq6j64ryg== 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=9tEsnocPFaXQkUGLHpw0c2GCZW7WtZVNTqYEZMrd58Y=; b=FR0ZYwMSTZ7xCAN2B9ifkz2+uEAiSEtnudPgbkXlYVWiIDCKN1KhedqaOqHDxKV4gmTTBfUcR1KZ+o2GFlmdAwNnoMq0hIr5wDwZyb45dLyWIh8Jb0ucW1dsGVBJGsiIbJY789hj4nh46pm8A08lcbllv13tXNmtOiPUzcjzEws6dA817Pm5XgxPSrwLE5oLEFWEEDnYd6qhFnxpPFKILWj1lObo9KEHdbXMYTDEC9kHUhZw9D8VhPef9c2uupKbM54Q/3YP/OX9/JDrvFo/q4heO7ObYeNYqE/GxFRRw0osxt/eXhXZ6MOzJ3NuXdIEWJw7LV5AFizv2/3l7dtdSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9tEsnocPFaXQkUGLHpw0c2GCZW7WtZVNTqYEZMrd58Y=; b=gkdtyxitEcthkQ4822RbzQaqMyj92sRVrdMQc39ubB8cUtgNbCZmdOJ2AyydtGyend3GJsExq+OJPVQn2HNUUoNqT9bi1UuZ/h3xPQe2NhrC9OoDYM6oj+TDrwMVJ1NyFYL57chLjz8iBuLoI+NJuDOApfwkoZ7ZOzp8IFGldLB5vTd6I045Dkd6erTaiNrOM8QkUk9PdjJm6MJhcy7aYYINRbCIanSW1c4P3z1EALpSXJrtvXwQWPmz+9ULsIw5OvTBPepRjhNYlqFKvw6EPTiTMCj9lztFbsXjthf/fSt3muBhJTk63aKXTTx6Qweq4AiQChM1Os/6HZVT9I4X3A== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BN7PR12MB2803.namprd12.prod.outlook.com (2603:10b6:408:32::22) by SA3PR12MB239779.namprd12.prod.outlook.com (2603:10b6:806:5a5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Thu, 3 Dec 2026 02:31:07 +0000 Received: from BN7PR12MB2803.namprd12.prod.outlook.com ([fe80::79d9:104f:cfa9:7f32]) by BN7PR12MB2803.namprd12.prod.outlook.com ([fe80::79d9:104f:cfa9:7f32%5]) with mapi id 15.21.0688.009; Thu, 3 Dec 2026 02:31:07 +0000 Date: Wed, 2 Dec 2026 21:31:06 -0500 From: Yury Norov To: Tzu-Ching Yang Cc: Max Filippov , Chris Zankel , Yury Norov , Rasmus Villemoes , Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] xtensa: bitops: use the builtins for __ffs(), ffs(), ffz() and __fls() Message-ID: References: <20261201142253.1986402-1-shingekinocore@gmail.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201142253.1986402-1-shingekinocore@gmail.com> X-ClientProxiedBy: MN2PR22CA0017.namprd22.prod.outlook.com (2603:10b6:208:238::22) To BN7PR12MB2803.namprd12.prod.outlook.com (2603:10b6:408:32::22) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN7PR12MB2803:EE_|SA3PR12MB239779:EE_ X-MS-Office365-Filtering-Correlation-Id: 60719c7f-4e73-4a1f-c939-08df50e57c59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|23010399003|1800799024|10070799003|11063799006|6133799003|261009223027099003|261009221227099003|261009220027099003|261009223327099003|261009221727099003|3023799007|22082099003|18002099003|56012099006|10067099003|261022075727099003|261102123227099003|261021121427099003|261028144727099003|261021123027099003|261026140227099003|261026121527099003|261022105027099003|261022113327099003|261022115727099003; X-Microsoft-Antispam-Message-Info: Tw08YSkvW0JMZuPFAKlYycp16qI2jdFoA5ey0tw0/UNdrHONdxQnvs0tabx/xHqUWmQEENijWeESKUj1n6zJHQr/65LACOI6yQHT6YYvAgvL0vEmSj5fh0NDiwjzw2i1m9ctrpprRy2f2fDcLGCxNiz85mgoSicFNzspEBOqCUe9EaGVp8aemMb5D1QHJEjr9cyA2iJ2EtphdLMC7nSucNXLUruh2hyinfBBiQPa+UzJD7WNUofthFU+W3TOIAD0RM1J6u5wfo1/qUf+I+7+T7j0gLiUQZPNv+bwit1G9UaHnT/+sKVPK8KG8HmMpZstQe2HGo6F1hFQI8c0OF5Xsd7+7IMd0rOYiPAyyDUd5DZ9BtIGdpQXdqwK4BkJKpdcLtyc2vJwENy3BLme2za0i/Un6tfWLtAyEjpmn1C+ncorsOoeNXVKloQXkjzTMwNko2P52nyOTjkW2Kul7UYLi57TzfWOws1U9jxGPl/VDnbFPLnoPGp9y8YsS+mZhc05ziSAibA2AEs7zDxktBwMBMm+nlkyZ9ok6BBDkhNTN7ZtRQavMgvyyFcR31mlQJ6+1hg+jFujFbkNz1tr3eIUNj1cR6Q5fvfGqlfYpaaY6FSEEr2pXZaN2GAlbn1BFPNI1e7Fn3HXgE2b56Y9TrxNCenlhdN0XMPEDkFKAYSTZJs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN7PR12MB2803.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(23010399003)(1800799024)(10070799003)(11063799006)(6133799003)(261009223027099003)(261009221227099003)(261009220027099003)(261009223327099003)(261009221727099003)(3023799007)(22082099003)(18002099003)(56012099006)(10067099003)(261022075727099003)(261102123227099003)(261021121427099003)(261028144727099003)(261021123027099003)(261026140227099003)(261026121527099003)(261022105027099003)(261022113327099003)(261022115727099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?yrz8MfJ2rljiddcONX8OxQ6bfTu5UCN01J96jH9B8Pb205nBk9xYGAI1KUGZ?= =?us-ascii?Q?TfYjXIUW9+VTeaiuRKrEtCC4OlU7ZuumPIg+8yBy+16jpC8Qbtk8MI7feEyJ?= =?us-ascii?Q?VzCkQlt4m+QYE0VRAiFo7mvuF40xidpTsJvvUxHTc02rG211hRZuQ7RSx6mo?= =?us-ascii?Q?b4z0V/pDpw4D/k0jLu7UZWoCQJ0sw7XaNSJ/MugMR4zl8V0FL1yHcEsgc4nj?= =?us-ascii?Q?d50c3wN+Ja8RRTNZPdsfxTSJxk9YcUQzgKIpdLBPKOHxHNx4KQ42i2XTbqcg?= =?us-ascii?Q?Yk6q1nGRHFw8XMDska8kncnNz6HPjyfbu66W0lWBqIxi7aOkRGXTxmPjqoSy?= =?us-ascii?Q?ash/UiBzWAcXQvnCrEnpfjBE9qYC//y9Anfin8RF/XLydipVAcOPDk5E0l0H?= =?us-ascii?Q?7NJ+/eNpN7k7KE3BNoqXwLwYGUYH3gY+LszZrDC1uzNwDcr8EYoGyM3sRxE5?= =?us-ascii?Q?ucYvS4Tij31187caXzF9UphblFKYNBOK9gu7bk0iiDFAaQwR2eoVWDQVrE1g?= =?us-ascii?Q?2BriID+/SbuKRrx4SCVAWO91P8qECG1KJ6E+cX8PsIPHjqfRJWuks71NjiPE?= =?us-ascii?Q?L3MGdRPwoZBldx1JyqkDhcMKXivJmk/H19IDSULNc6JEl5Ucd5+6qku94dGp?= =?us-ascii?Q?PDL939rzVhhq5+W51pYAlZm4Cfpd4ENDvopW11AVu4cYJ09rMi+PVW81XpKy?= =?us-ascii?Q?W/g1MSA3gmgOnF2DObqJokhkx1/XjhD2eum1Vaw4S18wT9vszWXhL4MKIFP3?= =?us-ascii?Q?lTUN0rxbm0pXc2A1axZcbKrkpCnyY3bei5pPUQBJAGK/wY06ommTHCWS8hgi?= =?us-ascii?Q?eJv2yiXSWT/7RS+56NdkqfWWV6gMX9U3QMb74cGNQfVzbmJ5FPc2VTb2akOu?= =?us-ascii?Q?oSynWUzfA+2d5SEOcNzcHmVhnSV3mAD5JbgFF8YZjJ5clFjDJSv1L7kecyhf?= =?us-ascii?Q?zqkBv0z4EDlzs6zGPLvo0XMN8F2B3jEmLpAuuis/tiZWTuDAmh2nebPFgI2b?= =?us-ascii?Q?zNS+AD/AMfeZa1YZmO7yQLQtxnVvz2sH5lRqpMT5g+CSfwVOj4JQYnP5QEKp?= =?us-ascii?Q?sdyjMqqGNJB5vAFDJI4g8Y1GplAGt+oNJzM3ru5MkDbbz88ba7HO861E6ec7?= =?us-ascii?Q?H3v9avgOX/33bPNBQtq/xvi/0K+p4FbhtmpYPvXCDCawKgy0W/RCG0aggz/4?= =?us-ascii?Q?hwYsUUNTHOAdE5jiE0JZDRK8wths7SWqICGObvxKbuGsm1/KYiIOUyqzRmya?= =?us-ascii?Q?rKxc/JYQpwZ5w1A5PHajgFGYfVTNXShc8zDNwjLAa/BDdYzCZH2/lsiT9hac?= =?us-ascii?Q?Xr1dptMBSQEDNMocloxY2AnM72qsXEH++BP4VVjyK9Rmvf/toCoTYdrw/0yQ?= =?us-ascii?Q?kCI/yZ/6BHDvruvxJjAEUg/VDaysbK3YUWm3lpTCNu6YojjSabSv+91HXeNn?= =?us-ascii?Q?PAbrFzO8Re6BTxFfwj9xbymJnHFNq0Xz85KhzY7AOweBZpVM8fQGztG7V8UT?= =?us-ascii?Q?I/cUkys/UCKahiE5rh3HI8/RrBhw+ClLtEznPgq+o72+A9v0w6YV7oXQ3jL5?= =?us-ascii?Q?ld8SBbdaNtv6qk1nZet4eLvR2jY3FqLmIgwfO80QUh0QKjuABvYN0lcC2Fhy?= =?us-ascii?Q?AhUNskKUKoekw/bAIXIc/+h87+0QqM/cRPF0gBESZmp059S+yuws8z3pM+W8?= =?us-ascii?Q?YiAlWAy5QQRHiLVHOLOfvDGpFY3dGst18oPX5Yx+2eloSxk2zg5WZjXtRU9u?= =?us-ascii?Q?+JJUb9ZYlIywzq8XFvZbtLcuSSbpngC9A8xy4BmW2sFKis1blfv1?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60719c7f-4e73-4a1f-c939-08df50e57c59 X-MS-Exchange-CrossTenant-AuthSource: BN7PR12MB2803.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 02:31:07.7945 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FdytTNlu0Qkt9OFc1l+zOOadOEtFNWzJ4jQORTALVJH83GicufH/QgoahYRFkTBZP0QURNd8Vgi2Kip1EsyJLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB239779 On Tue, Dec 01, 2026 at 10:22:53PM +0800, Tzu-Ching Yang wrote: > Let GCC compute __ffs(), ffs(), ffz() and __fls() at compile time when > the argument is a constant, on cores with the NSA option, by using the > compiler builtins instead of the nsau asm wrappers; GCC implements the > builtins with the same nsau instruction on these cores. The nsau > wrappers come from the initial port in 2005, commit 9a8fd5589902 > ("[PATCH] xtensa: Architecture support for Tensilica Xtensa Part 6"), > and from 2009 for __fls(), so they predate the asm-generic builtin > versions, which were added in 2012. > > Use the asm-generic builtin versions of __ffs(), ffs() and __fls() > inside the existing XCHAL_HAVE_NSA block, and use the generic ffz(), > which is __ffs(~x), with and without XCHAL_HAVE_NSA instead of only > without it. fls() keeps its asm, as the builtin version of fls() needs > a test for zero that nsau makes unnecessary by returning 32 for 0. > > With GCC 8 to 16, the functions of each vmlinux tested are smaller in > total with this patch than without it, by at least 1346 and at most > 10002 bytes (scripts/bloat-o-meter -t; 37 builds on xtensa-for-next: 8 > defconfigs, each with at least two of these compilers). > > With GCC 8 to 13, none of the __ffs()-based functions of > lib/find_bit.c that find_bit_benchmark tests executes more > instructions than without this patch. With GCC 14 to 16, each of these > functions executes one instruction more per call that finds a bit than > without this patch (two more in __find_nth_bit() with GCC 15 and 16, > one of them a register move), as these compilers need one instruction > more than GCC 13 to add __builtin_ctzl() to a value in a register [1]. > > The generic ffz() lets GCC 10 to 16 inline next_signal() into > dequeue_signal(), which they do not do without this patch. For > generic_kc705_defconfig with GCC 16.2 for the dc233c core, a call of > dequeue_signal() then executes 2 to 22 instructions fewer than without > this patch, counted along the disassembly, and dequeue_signal() is 163 > bytes larger. On the fd allocation and block flush paths, counted in > three builds, a call executes between three instructions fewer and > four more than without this patch. > > ffs(0) still returns 0; __ffs(0), __fls(0) and ffz(~0UL) remain > undefined. __ffs() and __fls() now return unsigned int instead of > unsigned long, and ffz() unsigned int instead of int, like the > asm-generic versions that the !XCHAL_HAVE_NSA case already uses; > unsigned int and unsigned long are 32 bits wide on xtensa. ffs() and > ffz() become macros, for __builtin_ffs() and __ffs(~(x)). > > Suggested-by: Arnd Bergmann > Link: https://lore.kernel.org/all/affe7da1-41aa-4710-bee0-5e3c2b8a8dfc@app.fastmail.com/ > Link: https://gcc.gnu.org/PR129142 [1] > Signed-off-by: Tzu-Ching Yang > --- > I have no xtensa hardware. On QEMU kc705, the ffs and bitops KUnit tests > pass before and after, with the dc233c core and GCC 13.5 to 16.2 built > for that core, and with the test_kc705_be core and the kernel.org GCC > 8.1 to 16.2. Under QEMU user mode, the old and new __ffs(), ffs(), ffz() > and __fls() return the same values for every defined 32-bit input with > GCC 8 to 16. Max, could you run the ffs and bitops KUnit tests and > lib/find_bit_benchmark.c before and after on hardware, for example the > KC705 board with dc233c? > > In virt_defconfig with GCC 16.2 for dc233c, the number of nsau > instructions whose operand is a constant (loaded by movi or l32r earlier > in the same basic block) goes from 178 without this patch to 9 with it, > and napi_pp_put_page() shrinks from 284 to 146 bytes because > PP_MAGIC_MASK, which uses __fls() and __ffs(PAGE_OFFSET), now folds. > > Executed instructions per iteration of four find_bit_benchmark tests > on QEMU kc705 with dc233c, counted by a TCG plugin (random bitmap, > generic_kc705_defconfig with the benchmark built in, the same bitmaps > before and after, written through the QEMU gdbstub): > > GCC 13.5 GCC 16.2 > before after before after > ------------------------------------------------------ > find_next_bit 30.2 30.2 26.3 27.3 > find_first_bit 2587.1 2587.1 2586.1 2587.1 > find_nth_bit 17482.5 17482.5 19017.7 19019.7 > find_last_bit 32.2 32.2 29.2 29.2 > > Instructions per call with this patch minus without it (negative: > fewer with this patch) on paths that use ffz(), counted along the > disassembly: > > kc705 kc705 iss > GCC 16.2 GCC 13.5 kernel.org > dc233c dc233c GCC 16.2 > --------------------------------------------------------------- > dequeue_signal(), five cases -2 to -22 -5 to -26 -3 to -22 > get_signal(), no sync. signal +1 0 0 > alloc_fd(), fast path -1 -3 +2 > blk_flush_complete_seq() -2 to +3 -3 to +4 -2 to +1 > flush_end_io() -1 to +1 -1 to +1 +1 to +3 > and per request it ends 0 +1 0 > > kc705 is generic_kc705_defconfig, iss is iss_defconfig. The five cases > are no signal pending and one signal in either word of the thread's > or the shared pending set. With the kernel.org GCC 10 to 15 > (iss_defconfig), the five cases take 1 to 27 instructions fewer than > without this patch, except one signal in word 0 of the thread's set > with GCC 12.5, which takes 2 more. > > The builtins need a GCC built for a core with NSA, as the rest of > such a kernel already does (entry.S uses nsau); with a GCC built > without NSA, this patch fails to link (undefined __ffssi2). You're a kernel engineer. Your job is writing some code, but more important, making your own judgement and your own analysis. Poking AI in a hope that your reviewers will read those endless and pointless "conclusions" and approve your work is a wrong approach. Your work is to read it yourself, make your own decision and explain it in your own words. > I can send one of these two versions instead: I'm sure you can. While your token balance is positive, you can do everything. > - keep the ffz() asm: the paths of the ffz() table stay as without > this patch; 32 of the 37 vmlinux are up to 230 bytes smaller than > with this patch, the other five 1 to 160 bytes larger; > - keep the __ffs() and ffz() asm: lib/find_bit.o stays as in > xtensa-for-next with GCC 8 to 16, but __ffs() and ffz() of a > constant do not fold; the 37 vmlinux are 1370 to 9972 bytes larger > than with this patch (-651 to +86 against xtensa-for-next). > > Against xtensa-for-next (de1aec038588); also applies to v7.4-rc5 and > bitmap-for-next. > arch/xtensa/include/asm/bitops.h | 45 +++----------------------------- > 1 file changed, 4 insertions(+), 41 deletions(-) > > diff --git a/arch/xtensa/include/asm/bitops.h b/arch/xtensa/include/asm/bitops.h > index f7390b6761e1..ba7e0b61ccdb 100644 > --- a/arch/xtensa/include/asm/bitops.h > +++ b/arch/xtensa/include/asm/bitops.h > @@ -32,36 +32,6 @@ static inline unsigned long __cntlz (unsigned long x) > return lz; > } > > -/* > - * ffz: Find first zero in word. Undefined if no zero exists. > - * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). > - */ > - > -static inline int __attribute_const__ ffz(unsigned long x) > -{ > - return 31 - __cntlz(~x & -~x); > -} > - > -/* > - * __ffs: Find first bit set in word. Return 0 for bit 0 > - */ > - > -static inline __attribute_const__ unsigned long __ffs(unsigned long x) > -{ > - return 31 - __cntlz(x & -x); > -} > - > -/* > - * ffs: Find first bit set in word. This is defined the same way as > - * the libc and compiler builtin ffs routines, therefore > - * differs in spirit from the above ffz (man ffs). > - */ > - > -static inline __attribute_const__ int ffs(unsigned long x) > -{ > - return 32 - __cntlz(x & -x); > -} > - > /* > * fls: Find last (most-significant) bit set in word. > * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. > @@ -72,28 +42,21 @@ static inline __attribute_const__ int fls (unsigned int x) > return 32 - __cntlz(x); > } > > -/** > - * __fls - find last (most-significant) set bit in a long word > - * @word: the word to search > - * > - * Undefined if no set bit exists, so code should check against 0 first. > - */ > -static inline __attribute_const__ unsigned long __fls(unsigned long word) > -{ > - return 31 - __cntlz(word); > -} > +# include > +# include > +# include > #else > > /* Use the generic implementation if we don't have the nsa/nsau instructions. */ > > # include > # include > -# include > # include > # include > > #endif > > +#include > #include > > #if XCHAL_HAVE_EXCLUSIVE > > base-commit: de1aec038588f12b1faeef9e94abe9608814d39a > -- > 2.34.1 OK... The patch itself looks clean. I'll take the code in bitmap-for-next, but not that word salad in the commit message. Please write better commit messages next time if you want to move your patches with me. Thanks, Yury