@@ -361,6 +361,11 @@ struct mem_cgroup {
extern struct mem_cgroup *root_mem_cgroup;
+static inline struct mem_cgroup *root_memcg(void)
+{
+ return root_mem_cgroup;
+}
+
enum page_memcg_data_flags {
/* page->memcg_data is a pointer to an objcgs vector */
MEMCG_DATA_OBJCGS = (1UL << 0),
@@ -1138,6 +1143,11 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
#define MEM_CGROUP_ID_SHIFT 0
#define MEM_CGROUP_ID_MAX 0
+static inline struct mem_cgroup *root_memcg(void)
+{
+ return NULL;
+}
+
static inline struct mem_cgroup *folio_memcg(struct folio *folio)
{
return NULL;
@@ -433,7 +433,7 @@ static struct mem_cgroup *bpf_map_get_memcg(const struct bpf_map *map)
if (map->objcg)
return get_mem_cgroup_from_objcg(map->objcg);
- return root_mem_cgroup;
+ return root_memcg();
}
void *bpf_map_kmalloc_node(const struct bpf_map *map, size_t size, gfp_t flags,
@@ -488,6 +488,11 @@ static void bpf_map_save_memcg(struct bpf_map *map)
static void bpf_map_release_memcg(struct bpf_map *map)
{
}
+
+static struct mem_cgroup *bpf_map_get_memcg(const struct bpf_map *map)
+{
+ return root_memcg();
+}
#endif
/*
Then we can use this helper when CONFIG_MEMCG_KMEM is not set. Signed-off-by: Yafang Shao <laoar.shao@gmail.com> --- include/linux/memcontrol.h | 10 ++++++++++ kernel/bpf/syscall.c | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-)