
From: Gu Bowen <gubowen5@huawei.com> hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICA1GK -------------------------------- Add kfuncs to get info about committed pages of virtual memory. Co-developed-by: GONG Ruiqi <gongruiqi1@huawei.com> Signed-off-by: GONG Ruiqi <gongruiqi1@huawei.com> Signed-off-by: Gu Bowen <gubowen5@huawei.com> --- kernel/bpf-rvi/common_kfuncs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/bpf-rvi/common_kfuncs.c b/kernel/bpf-rvi/common_kfuncs.c index 717f186fbdd2..79d8009d1fb7 100644 --- a/kernel/bpf-rvi/common_kfuncs.c +++ b/kernel/bpf-rvi/common_kfuncs.c @@ -6,6 +6,7 @@ #include <linux/pid_namespace.h> #include <linux/sched.h> #include <linux/mm.h> +#include <linux/mman.h> #include <linux/swap.h> #include <linux/types.h> #include <linux/page_counter.h> @@ -239,6 +240,15 @@ __bpf_kfunc unsigned long bpf_mem_percpu(void) return pcpu_nr_pages(); } +__bpf_kfunc unsigned long bpf_mem_commit_limit(void) +{ + return vm_commit_limit(); +} +__bpf_kfunc unsigned long bpf_mem_committed(void) +{ + return vm_memory_committed(); +} + BTF_SET8_START(bpf_common_kfuncs_ids) BTF_ID_FLAGS(func, bpf_mem_cgroup_from_task, KF_RET_NULL | KF_RCU) BTF_ID_FLAGS(func, bpf_task_active_pid_ns, KF_TRUSTED_ARGS) @@ -263,6 +273,8 @@ BTF_ID_FLAGS(func, bpf_mem_freecma) BTF_ID_FLAGS(func, bpf_hugetlb_report_meminfo, KF_TRUSTED_ARGS) BTF_ID_FLAGS(func, bpf_mem_failure) BTF_ID_FLAGS(func, bpf_mem_percpu) +BTF_ID_FLAGS(func, bpf_mem_commit_limit) +BTF_ID_FLAGS(func, bpf_mem_committed) BTF_SET8_END(bpf_common_kfuncs_ids) static const struct btf_kfunc_id_set bpf_common_kfuncs_set = { -- 2.25.1