From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07BF7C433EF for ; Wed, 15 Jun 2022 15:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232815AbiFOPwU convert rfc822-to-8bit (ORCPT ); Wed, 15 Jun 2022 11:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243579AbiFOPwT (ORCPT ); Wed, 15 Jun 2022 11:52:19 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0747A340E9 for ; Wed, 15 Jun 2022 08:52:16 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-152-_cqVfPGpOlGHZ7eUZ755_g-1; Wed, 15 Jun 2022 16:52:14 +0100 X-MC-Unique: _cqVfPGpOlGHZ7eUZ755_g-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Wed, 15 Jun 2022 16:52:11 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.036; Wed, 15 Jun 2022 16:52:11 +0100 From: David Laight 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" , "linux-m68k@lists.linux-m68k.org" , "linux-sh@vger.kernel.org" , "sparclinux@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2 4/6] bitops: define const_*() versions of the non-atomics Thread-Topic: [PATCH v2 4/6] bitops: define const_*() versions of the non-atomics Thread-Index: AQHYgL/NSGjbw1zE9ky1U7EvBf8PSa1QnWmQ 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> In-Reply-To: <20220615135506.1264880-1-alexandr.lobakin@intel.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-sh@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)