
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICA1GK -------------------------------- Add the following three kfuncs: - bpf_show_all_irqs - bpf_get_boottime_timens - bpf_get_total_forks Which are only used by /proc/stat interface. Signed-off-by: GONG Ruiqi <gongruiqi1@huawei.com> --- fs/proc/stat.c | 6 ++++++ kernel/bpf-rvi/common_kfuncs.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 9b58e9ded6bf..1d8699285e02 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -231,9 +231,15 @@ __bpf_kfunc u64 bpf_get_iowait_time(struct kernel_cpustat *kcs, int cpu) return get_iowait_time(kcs, cpu); } +__bpf_kfunc void bpf_show_all_irqs(struct seq_file *p) +{ + show_all_irqs(p); +} + BTF_SET8_START(bpf_proc_stat_kfunc_ids) BTF_ID_FLAGS(func, bpf_get_idle_time) BTF_ID_FLAGS(func, bpf_get_iowait_time) +BTF_ID_FLAGS(func, bpf_show_all_irqs) BTF_SET8_END(bpf_proc_stat_kfunc_ids) static const struct btf_kfunc_id_set bpf_proc_stat_kfunc_set = { diff --git a/kernel/bpf-rvi/common_kfuncs.c b/kernel/bpf-rvi/common_kfuncs.c index c8c47f72e7fd..abcfb4515372 100644 --- a/kernel/bpf-rvi/common_kfuncs.c +++ b/kernel/bpf-rvi/common_kfuncs.c @@ -6,6 +6,10 @@ #include <linux/types.h> #include <linux/page_counter.h> #include <linux/seq_file.h> +#include <linux/sched/stat.h> +#include <linux/time64.h> +#include <linux/timekeeping.h> +#include <linux/time_namespace.h> #include <linux/btf_ids.h> #include <linux/bpf.h> @@ -59,10 +63,23 @@ __bpf_kfunc void bpf_seq_file_append(struct seq_file *dst, struct seq_file *src) } } +__bpf_kfunc void bpf_get_boottime_timens(struct task_struct *tsk, struct timespec64 *boottime) +{ + getboottime64(boottime); + *boottime = timespec64_sub(*boottime, tsk->nsproxy->time_ns->offsets.boottime); +} + +__bpf_kfunc unsigned long bpf_get_total_forks(void) +{ + return total_forks; +} + 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_SET8_END(bpf_common_kfuncs_ids) static const struct btf_kfunc_id_set bpf_common_kfuncs_set = { -- 2.25.1