[PATCH bpf-next 0/4] bpf: Add bpf_iter_cpumask

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Three new kfuncs, namely bpf_iter_cpumask_{new,next,destroy}, have been
added for the new bpf_iter_cpumask functionality. These kfuncs enable the
iteration of percpu data, such as runqueues, psi_group_cpu, and more.

Additionally, a new kfunc, bpf_cpumask_set_from_pid, has been introduced to
specify the cpumask for iteration. This function retrieves the cpumask from
a specific task, facilitating the iteration of percpu data associated with
these CPUs.

In our specific use case, we leverage the cgroup iterator to traverse
percpu data, subsequently exposing it to userspace through a seq file.
Refer to the test cases in patch #4 for further context and examples.

Moreover, this patchset incorporates a change in the cgroup subsystem,
ensuring consistent access to PSI for all cgroups via the struct cgroup.

Changes:
- bpf: Add new bpf helper bpf_for_each_cpu
  https://lwn.net/ml/bpf/20230801142912.55078-1-laoar.shao@xxxxxxxxx/

Yafang Shao (4):
  cgroup, psi: Init PSI of root cgroup to psi_system
  bpf: Add bpf_iter_cpumask kfuncs
  bpf: Add new kfunc bpf_cpumask_set_from_pid
  selftests/bpf: Add selftests for cpumask iter

 include/linux/psi.h                                |   2 +-
 kernel/bpf/cpumask.c                               |  65 ++++++++++
 kernel/cgroup/cgroup.c                             |   5 +-
 .../selftests/bpf/prog_tests/cpumask_iter.c        | 132 +++++++++++++++++++++
 tools/testing/selftests/bpf/progs/cpumask_common.h |   4 +
 .../selftests/bpf/progs/test_cpumask_iter.c        |  50 ++++++++
 6 files changed, 256 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/cpumask_iter.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_cpumask_iter.c

-- 
1.8.3.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux