summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/cgroup_iter_memcg.h
diff options
context:
space:
mode:
authorJP Kobryn <inwardvessel@gmail.com>2025-12-22 20:41:55 -0800
committerAlexei Starovoitov <ast@kernel.org>2025-12-22 22:20:22 -0800
commit6bce6ddbe634bbc6d21672b5bfdbb5ad0409bd8d (patch)
tree164a4b3c8ebe6c51b23d8110125297273fda5db6 /tools/testing/selftests/bpf/cgroup_iter_memcg.h
parent99430ab8b804c26b8a0dec93fcbfe75469f3edc7 (diff)
downloadlinux-next-6bce6ddbe634bbc6d21672b5bfdbb5ad0409bd8d.tar.gz
linux-next-6bce6ddbe634bbc6d21672b5bfdbb5ad0409bd8d.zip
bpf: selftests: selftests for memcg stat kfuncs
Add test coverage for the kfuncs that fetch memcg stats. Using some common stats, test scenarios ensuring that the given stat increases by some arbitrary amount. The stats selected cover the three categories represented by the enums: node_stat_item, memcg_stat_item, vm_event_item. Since only a subset of all stats are queried, use a static struct made up of fields for each stat. Write to the struct with the fetched values when the bpf program is invoked and read the fields in the user mode program for verification. Signed-off-by: JP Kobryn <inwardvessel@gmail.com> Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev> Link: https://lore.kernel.org/r/20251223044156.208250-6-roman.gushchin@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/cgroup_iter_memcg.h')
-rw-r--r--tools/testing/selftests/bpf/cgroup_iter_memcg.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/cgroup_iter_memcg.h b/tools/testing/selftests/bpf/cgroup_iter_memcg.h
new file mode 100644
index 000000000000..3f59b127943b
--- /dev/null
+++ b/tools/testing/selftests/bpf/cgroup_iter_memcg.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
+#ifndef __CGROUP_ITER_MEMCG_H
+#define __CGROUP_ITER_MEMCG_H
+
+struct memcg_query {
+ /* some node_stat_item's */
+ unsigned long nr_anon_mapped;
+ unsigned long nr_shmem;
+ unsigned long nr_file_pages;
+ unsigned long nr_file_mapped;
+ /* some memcg_stat_item */
+ unsigned long memcg_kmem;
+ /* some vm_event_item */
+ unsigned long pgfault;
+};
+
+#endif /* __CGROUP_ITER_MEMCG_H */