From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Laight Subject: RE: [PATCH v2 4/6] bitops: define const_*() versions of the non-atomics Date: Wed, 15 Jun 2022 15:52:11 +0000 Message-ID: <09c5a168af144f0f917f5f2f453e309a@AcuMS.aculab.com> References: <20220610113427.908751-1-alexandr.lobakin@intel.com> <20220610113427.908751-5-alexandr.lobakin@intel.com> <20220615135506.1264880-1-alexandr.lobakin@intel.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8BIT Return-path: In-Reply-To: <20220615135506.1264880-1-alexandr.lobakin@intel.com> Content-Language: en-US List-ID: Content-Type: text/plain; charset="us-ascii" To: 'Alexander Lobakin' , Yury Norov Cc: Arnd Bergmann , Andy Shevchenko , Mark Rutland , Matt Turner , Brian Cain , Geert Uytterhoeven , Yoshinori Sato , Rich Felker , "David S. Miller" , Kees Cook , "Peter Zijlstra (Intel)" , Marco Elver , Borislav Petkov , Tony Luck , Greg Kroah-Hartman , "linux-alpha@vger.kernel.org" , "linux-hexagon@vger.kernel.org" , "linux-ia64@vger.kernel.org" From: Alexander Lobakin > Sent: 15 June 2022 14:55 ... > > > +/** > > > + * const_test_bit - Determine whether a bit is set > > > + * @nr: bit number to test > > > + * @addr: Address to start counting from > > > + * > > > + * A version of generic_test_bit() which discards the `volatile` qualifier to > > > + * allow the compiler to optimize code harder. Non-atomic and to be used only > > > + * for testing compile-time constants, e.g. from the corresponding macro, or > > > + * when you really know what you are doing. > > > > Not sure I understand the last sentence... Can you please rephrase? > > I basically want to tell that there potentinally might be cases for > using those outside of the actual macros from 6/6. But it might be > redundant at all to mention this. I bet that is a function has: long bitmask; ... if (test_bit(&bitmask, 12)) then the 'volatile' forces the compiler to actually write the value out to memory (stack) instead of doing a register op. OTOH such code should be using &. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)