bpf: Add bits iterator
authorYafang Shao <laoar.shao@gmail.com>
Fri, 17 May 2024 02:30:33 +0000 (10:30 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 29 May 2024 23:01:47 +0000 (16:01 -0700)
commit4665415975b0827e9646cab91c61d02a6b364d59
tree9b717740936f9082b47ef0e0209816dc8de26658
parentfbe3e8473f391adbf67eb0f317305fe62c66096c
bpf: Add bits iterator

Add three new kfuncs for the bits iterator:
- bpf_iter_bits_new
  Initialize a new bits iterator for a given memory area. Due to the
  limitation of bpf memalloc, the max number of words (8-byte units) that
  can be iterated over is limited to (4096 / 8).
- bpf_iter_bits_next
  Get the next bit in a bpf_iter_bits
- bpf_iter_bits_destroy
  Destroy a bpf_iter_bits

The bits iterator facilitates the iteration of the bits of a memory area,
such as cpumask. It can be used in any context and on any address.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240517023034.48138-2-laoar.shao@gmail.com
kernel/bpf/helpers.c