Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.5-2 tag (topic/kasan-bitops)
From: Michael Ellerman
Date: Tue Dec 10 2019 - 19:29:24 EST
Peter Zijlstra <peterz@xxxxxxxxxxxxx> writes:
> On Tue, Dec 10, 2019 at 04:38:54PM +1100, Michael Ellerman wrote:
>> Good question, I'll have a look.
>> There seems to be confusion about what the type of the bit number is,
>> which is leading to sign extension in some cases and not others.
>> It looks like the type should be unsigned long?
> I'm thinking unsigned makes most sense, I mean, negative bit offsets
> should 'work' but that's almost always guaranteed to be an out-of-bound
Yeah I agree.
> As to 'long' vs 'int', I'm not sure, 4G bits is a long bitmap. But I
> suppose since the bitmap itself is 'unsigned long', we might as well use
> 'unsigned long' for the bitnr too.
4G is a lot of bits, but it's not *that* many.
eg. If we had a bit per 4K page on a 32T machine that would be 8G bits.
So unsigned long seems best.
>> Documentation/core-api/atomic_ops.rst: void __clear_bit_unlock(unsigned long nr, unsigned long *addr);
>> arch/mips/include/asm/bitops.h:static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *addr)
>> arch/powerpc/include/asm/bitops.h:static inline void arch___clear_bit_unlock(int nr, volatile unsigned long *addr)
>> arch/riscv/include/asm/bitops.h:static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *addr)
>> arch/s390/include/asm/bitops.h:static inline void arch___clear_bit_unlock(unsigned long nr,
>> include/asm-generic/bitops/instrumented-lock.h:static inline void __clear_bit_unlock(long nr, volatile unsigned long *addr)
>> include/asm-generic/bitops/lock.h:static inline void __clear_bit_unlock(unsigned int nr,
>> So I guess step one is to convert our versions to use unsigned long, so
>> we're at least not tripping over that difference when comparing the
> Yeah, I'll look at fixing the generic code, bitops/atomic.h and
> bitops/non-atomic.h don't even agree on the type of bitnr.