Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752314AbdHJKiN (ORCPT ); Thu, 10 Aug 2017 06:38:13 -0400 Received: from mail-by2nam01on0071.outbound.protection.outlook.com ([104.47.34.71]:22940 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752012AbdHJKiL (ORCPT ); Thu, 10 Aug 2017 06:38:11 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Date: Thu, 10 Aug 2017 13:37:34 +0300 From: Yury Norov To: Rasmus Villemoes Cc: Andrew Morton , kbuild test robot , kbuild-all@01.org, Noam Camus , Matthew Wilcox , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] lib: add test for bitmap_parselist() Message-ID: <20170810103734.qkexg4lribuwkvre@yury-thinkpad> References: <20170807225438.16161-2-ynorov@caviumnetworks.com> <201708091143.QqTgSaxI%fengguang.wu@intel.com> <20170809133309.746aafee5e22c9345debd671@linux-foundation.org> <20170809225231.ythrktk43gswfnjd@yury-thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [105.142.242.124] X-ClientProxiedBy: AM4PR05CA0032.eurprd05.prod.outlook.com (10.171.184.173) To DM3PR07MB2124.namprd07.prod.outlook.com (10.164.4.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2cc1c347-b2fc-4b64-cb0c-08d4dfdbe474 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DM3PR07MB2124; X-Microsoft-Exchange-Diagnostics: 1;DM3P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pfTUqL+GhqnL7g5YpW9GS/s4XrmRVyUUzD35A2Aa8XuSU9x2JcpT3shm6j88QEtGZ0ZidLrlUAA87mc1QAGGNK/reX6nGlMHWM8Vb45mMORGwWaMMUbPwobQtg/mnwxE4zCXpLDWoyl8B/60ShlLzlIllJpz8tSj6ZrKEVx0njIfaMFF82WYVcjJCYKzi6KE7PWWJNyeYy/YiPFtePl3xDjME/9tfdPfwIvsBwx9etErwwlnRyk0D1hfH2FZ003NFfayqL9J/OIB6rU0Q9/WraIREZJ1LMznFTxqPFx6PAuyr9DNE9i8P613H4qwV5AerScYwayd1kiD3vtjaM4hzQr3bfknmoQck3FxBcfjaZsqyf4+r6mOqrzigBtd5h+WJNBWxocoZ6j0u2RXh/HAbbZXjKZaU9/5MIQuSl/Yuw6UY3bbxsoIZriyLc20JD8Sg=;4:yL7j0LhIerCywmJmCC9GOMhsEh5aicXOmhGrw7Htzyq6D27CEIWfAvjZ/iaPc+dCnnaC0I8IXbC/PN9llXQlIsaVW3oW8EUGO1L+uFKHPF19sNbUzGCN2AI3YQmRZDz0B/+WxoLpTL1C9KfsWg6PHbQPCZ2pXSg0KNjR7a1IAugesn5i01T0dGjvV1DLKM4dAxhXuXQWvuUfr4lnt1WXt03T6zTThVETJR8YXr8BHcv2uM/MwNj7hv3m7EgSM4hb+nfv50RTb7F7qJ5yMGSMtntpgGP8D0/ccP6nd8blRdA= X-Exchange-Antispam-Report-Test: UriScan:(131327999870524); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(3002001)(100000703101)(100105400095)(6041248)(20161123562025)(20161123560025)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM3PR07MB2124;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM3PR07MB2124; X-Forefront-PRVS: 03950F25EC X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6069001)(6009001)(39400400002)(39410400002)(39840400002)(39850400002)(39450400003)(199003)(189002)(24454002)(189998001)(83506001)(6116002)(42186005)(76506005)(3846002)(72206003)(68736007)(5660300001)(4326008)(478600001)(305945005)(1076002)(7350300001)(23726003)(25786009)(53546010)(6496005)(50466002)(9686003)(66066001)(6486002)(4001350100001)(6916009)(93886004)(106356001)(229853002)(8666007)(575784001)(101416001)(6666003)(54906002)(38730400002)(76176999)(105586002)(97736004)(54356999)(2950100002)(6246003)(33646002)(50986999)(7736002)(33716001)(81156014)(110136004)(2906002)(8676002)(81166006)(47776003)(42882006)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR07MB2124;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR07MB2124;23:n2lPdJ4LO236zMA9DWwh9P40f9UsfdtIXm/KBqU0c?= =?us-ascii?Q?zf9duY9AAZV5F1VcZg/RMCc+ME2hEKnDikv+xPTXCZTGEd86UYa9LL6GPk1J?= =?us-ascii?Q?lK/q4ipqMxPNnQNzu9zGdbQpq2pTQ61brMZke0KEMcnp1sgy1r6jathX2HJq?= =?us-ascii?Q?1wsRItDOmCK7I7uqyiCdzErqtuRQWFkyV+jwT0vmjFjLcH6eTG7kIjFNmTbJ?= =?us-ascii?Q?0fDRJeNMYfrXzqvDs3GBUdH+z66+ZCeyW8T96YB92JC1h9Gn+MMxKA12V1Mn?= =?us-ascii?Q?AoTvqWY8fuxiTIfWLzw0f4Jw4yavoLyJyqpzNn5m0BnQc4ccQtPmVLfjCXs0?= =?us-ascii?Q?0uQ+zk5tzMCly5U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Bv131YuJ21boRz0l1EggVHnVf/3QYV/vZM23Frh3FaCxgg6hyY7py3+RsikKeIxZZ98PZWkHmXxvbYsprxxfcZJSOn/VBEcb8GEsfkJm0ZdpXhMVcknjHHD9XSOH42gPZagDdcDCJto0L/bwFs0LmHYjMGnM4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2017 10:38:05.2886 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2124 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2866 Lines: 66 On Thu, Aug 10, 2017 at 09:30:31AM +0200, Rasmus Villemoes wrote: > > From be0e663b804daff0d0512e72cf94b5143270bd29 Mon Sep 17 00:00:00 2001 > > From: Yury Norov > > Date: Thu, 10 Aug 2017 01:25:46 +0300 > > Subject: [PATCH] bitmap: introduce BITMAP_FROM_U64() and use it in test for > > bitmap_parselist() > > > > The macro is the compile-time analogue of bitmap_from_u64() with the > > same purpose: convert the 64-bit number to the properly ordered pair > > of 32-bit parts to be suitable for filling the bitmap. > > > > Signed-off-by: Yury Norov > > --- > > include/linux/bitmap.h | 6 ++++++ > > lib/test_bitmap.c | 23 +++++++++++++++++++---- > > 2 files changed, 25 insertions(+), 4 deletions(-) > > > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > > index 5797ca6fdfe2..bdc487e47de1 100644 > > --- a/include/linux/bitmap.h > > +++ b/include/linux/bitmap.h > > @@ -378,6 +378,12 @@ static inline void bitmap_from_u64(unsigned long *dst, u64 mask) > > dst[1] = mask >> 32; > > } > > > > +#if __BITS_PER_LONG == 64 > > +#define BITMAP_FROM_U64(n) (n) > > +#else > > +#define BITMAP_FROM_U64(n) ((n) & ULONG_MAX), ((unsigned long long) (n) >> 32) > > +#endif > > + > > The 32 bit version probably needs to come in two flavours depending on > little/big endian, no? Actually no. For completeness: There are four combinations of endianess and length of the word in linux ABIs: LE64, BE64, LE32 and BE32. 64-bit LE and BE are naturally ordered and therefore don't require any special handling. 32-bit LE ABI orders lo word of 64-bit number prior to hi, and 32-bit BE orders hi word prior to lo in the memory. The bitmap in other hand is represented as the array of 32-bit words, and the position of the bit N may therefore be calculated as: word (N/32) and bit (N%32) in that word. For example, bit #42 is located at 10th position of 2nd word. It matches 32-bit LE ABI, and we can simply let the compiler store 64-bit value on the memory like it usually does. But for BE we therefore need to swap words manually. With all that, the macro (n & ULONG_MAX, n >> 32) does exactly what needed for 32-bit case. In LE environment it does in fact nothing, and in BE environment it swaps hi and lo words. > Could you also throw in some casts so that the behaviour is consistent > regardless of the type of the expression n, and so that both elements > in the pair are guaranteed to have the same type (unsigned long, > preferably, since that's what we're initializing). I.e., cast n to > (u64), do arithmetic, cast result to (unsigned long). If no objections, I'll change the patch like you proposed here, add the explanation below to the comment of macro and resend it after finishing the testing. (I need time to setup some 32-bit BE environment to do test.) Yury