Messages in this thread | | | 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 |
| |
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)
| |