mirror_ubuntu-kernels/tools/include/asm-generic/bitops
Sean Christopherson 7f2b47f22b tools: Take @bit as an "unsigned long" in {clear,set}_bit() helpers
Take @bit as an unsigned long instead of a signed int in clear_bit() and
set_bit() so that they match the double-underscore versions, __clear_bit()
and __set_bit().  This will allow converting users that really don't want
atomic operations to the double-underscores without introducing a
functional change, which will in turn allow making {clear,set}_bit()
atomic (as advertised).

Practically speaking, this _should_ have no functional impact.  KVM's
selftests usage is either hardcoded (Hyper-V tests) or is artificially
limited (arch_timer test and dirty_log test).  In KVM, dirty_log test is
the only mildly interesting case as it's use indirectly restricted to
unsigned 32-bit values, but in theory it could generate a negative value
when cast to a signed int.  But in that case, taking an "unsigned long"
is actually a bug fix.

Perf's usage is more difficult to audit, but any code that is affected
by the switch is likely already broken.  perf_header__{set,clear}_feat()
and perf_file_header__read() effectively use only hardcoded enums with
small, positive values, atom_new() passes an unsigned long, but its value
is capped at 128 via NR_ATOM_PER_PAGE, etc...

The only real potential for breakage is in the perf flows that take a
"cpu", but it's unlikely perf is subtly relying on a negative index into
bitmaps, e.g. "cpu" can be "-1", but only as "not valid" placeholder.

Note, tools/testing/nvdimm/ makes heavy use of set_bit(), but that code
builds into a kernel module of sorts, i.e. pulls in all of the kernel's
header and so is getting the kernel's atomic set_bit().  The NVDIMM test
usage of atomics is likely unnecessary, e.g. ndtest_dimm_register() sets
bits in a local variable, but that's neither here nor there as far as
this change is concerned.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221119013450.2643007-5-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-12-02 13:22:32 -05:00
..
__ffs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
__ffz.h tools lib: Add for_each_clear_bit macro 2016-10-24 11:07:33 -03:00
__fls.h tools/headers: Synchronize kernel ABI headers 2017-11-04 09:27:46 +01:00
arch_hweight.h tools/headers: Synchronize kernel ABI headers 2017-11-04 09:27:46 +01:00
atomic.h tools: Take @bit as an "unsigned long" in {clear,set}_bit() helpers 2022-12-02 13:22:32 -05:00
const_hweight.h tools/headers: Synchronize kernel ABI headers 2017-11-04 09:27:46 +01:00
fls64.h tools/headers: Synchronize kernel ABI headers 2017-11-04 09:27:46 +01:00
fls.h fls: change parameter to unsigned int 2019-01-04 13:13:46 -08:00
hweight.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
non-atomic.h bitops: wrap non-atomic bitops with a transparent macro 2022-06-30 19:52:41 -07:00