
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICA1GK -------------------------------- Add bpf_nr_{running,context_switches,iowait} to get statistics about CPU runqueue and scheduling. Signed-off-by: GONG Ruiqi <gongruiqi1@huawei.com> --- kernel/bpf-rvi/common_kfuncs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kernel/bpf-rvi/common_kfuncs.c b/kernel/bpf-rvi/common_kfuncs.c index abcfb4515372..9eae982c081d 100644 --- a/kernel/bpf-rvi/common_kfuncs.c +++ b/kernel/bpf-rvi/common_kfuncs.c @@ -7,6 +7,7 @@ #include <linux/page_counter.h> #include <linux/seq_file.h> #include <linux/sched/stat.h> +#include <linux/kernel_stat.h> #include <linux/time64.h> #include <linux/timekeeping.h> #include <linux/time_namespace.h> @@ -74,12 +75,30 @@ __bpf_kfunc unsigned long bpf_get_total_forks(void) return total_forks; } +__bpf_kfunc unsigned int bpf_nr_running(void) +{ + return nr_running(); +} + +__bpf_kfunc unsigned long long bpf_nr_context_switches(void) +{ + return nr_context_switches(); +} + +__bpf_kfunc unsigned int bpf_nr_iowait(void) +{ + return nr_iowait(); +} + BTF_SET8_START(bpf_common_kfuncs_ids) BTF_ID_FLAGS(func, bpf_si_memswinfo) BTF_ID_FLAGS(func, bpf_page_counter_read) BTF_ID_FLAGS(func, bpf_seq_file_append) BTF_ID_FLAGS(func, bpf_get_boottime_timens) BTF_ID_FLAGS(func, bpf_get_total_forks) +BTF_ID_FLAGS(func, bpf_nr_running) +BTF_ID_FLAGS(func, bpf_nr_context_switches) +BTF_ID_FLAGS(func, bpf_nr_iowait) BTF_SET8_END(bpf_common_kfuncs_ids) static const struct btf_kfunc_id_set bpf_common_kfuncs_set = { -- 2.25.1