bitops: Add non-atomic bitops for pointers
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Fri, 2 Jul 2021 11:18:22 +0000 (16:48 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 8 Jul 2021 03:01:45 +0000 (20:01 -0700)
commitcb0f80039fb7ec9981a74d22019daaa85ff51a3d
tree4a723ac4dfa94fb5af8474bb084e9f997559d805
parentfe21cb91ae7bca1ae7805454be80b6d03bec85f7
bitops: Add non-atomic bitops for pointers

cpumap needs to set, clear, and test the lowest bit in skb pointer in
various places. To make these checks less noisy, add pointer friendly
bitop macros that also do some typechecking to sanitize the argument.

These wrap the non-atomic bitops __set_bit, __clear_bit, and test_bit
but for pointer arguments. Pointer's address has to be passed in and it
is treated as an unsigned long *, since width and representation of
pointer and unsigned long match on targets Linux supports. They are
prefixed with double underscore to indicate lack of atomicity.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20210702111825.491065-3-memxor@gmail.com
include/linux/bitops.h
include/linux/typecheck.h