Merge tag 'orphan-handling-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / mm / slab.h
index ecad9b5..076582f 100644 (file)
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -110,8 +110,7 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
                   slab_flags_t flags, void (*ctor)(void *));
 
 slab_flags_t kmem_cache_flags(unsigned int object_size,
-       slab_flags_t flags, const char *name,
-       void (*ctor)(void *));
+       slab_flags_t flags, const char *name);
 #else
 static inline struct kmem_cache *
 __kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
@@ -119,8 +118,7 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
 { return NULL; }
 
 static inline slab_flags_t kmem_cache_flags(unsigned int object_size,
-       slab_flags_t flags, const char *name,
-       void (*ctor)(void *))
+       slab_flags_t flags, const char *name)
 {
        return flags;
 }
@@ -240,7 +238,7 @@ static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t fla
 
 #ifdef CONFIG_MEMCG_KMEM
 int memcg_alloc_page_obj_cgroups(struct page *page, struct kmem_cache *s,
-                                gfp_t gfp);
+                                gfp_t gfp, bool new_page);
 
 static inline void memcg_free_page_obj_cgroups(struct page *page)
 {
@@ -317,7 +315,8 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s,
                        page = virt_to_head_page(p[i]);
 
                        if (!page_objcgs(page) &&
-                           memcg_alloc_page_obj_cgroups(page, s, flags)) {
+                           memcg_alloc_page_obj_cgroups(page, s, flags,
+                                                        false)) {
                                obj_cgroup_uncharge(objcg, obj_full_size(s));
                                continue;
                        }
@@ -381,7 +380,8 @@ static inline struct mem_cgroup *memcg_from_slab_obj(void *ptr)
 }
 
 static inline int memcg_alloc_page_obj_cgroups(struct page *page,
-                                              struct kmem_cache *s, gfp_t gfp)
+                                              struct kmem_cache *s, gfp_t gfp,
+                                              bool new_page)
 {
        return 0;
 }
@@ -422,8 +422,12 @@ static inline struct kmem_cache *virt_to_cache(const void *obj)
 }
 
 static __always_inline void account_slab_page(struct page *page, int order,
-                                             struct kmem_cache *s)
+                                             struct kmem_cache *s,
+                                             gfp_t gfp)
 {
+       if (memcg_kmem_enabled() && (s->flags & SLAB_ACCOUNT))
+               memcg_alloc_page_obj_cgroups(page, s, gfp, true);
+
        mod_node_page_state(page_pgdat(page), cache_vmstat_idx(s),
                            PAGE_SIZE << order);
 }