Merge branch 'for-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
[linux-2.6-microblaze.git] / mm / slab.h
index f9977d6..1a756a3 100644 (file)
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -204,7 +204,7 @@ ssize_t slabinfo_write(struct file *file, const char __user *buffer,
 void __kmem_cache_free_bulk(struct kmem_cache *, size_t, void **);
 int __kmem_cache_alloc_bulk(struct kmem_cache *, gfp_t, size_t, void **);
 
-static inline int cache_vmstat_idx(struct kmem_cache *s)
+static inline enum node_stat_item cache_vmstat_idx(struct kmem_cache *s)
 {
        return (s->flags & SLAB_RECLAIM_ACCOUNT) ?
                NR_SLAB_RECLAIMABLE_B : NR_SLAB_UNRECLAIMABLE_B;
@@ -239,30 +239,13 @@ static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t fla
 }
 
 #ifdef CONFIG_MEMCG_KMEM
-static inline struct obj_cgroup **page_obj_cgroups(struct page *page)
-{
-       /*
-        * page->mem_cgroup and page->obj_cgroups are sharing the same
-        * space. To distinguish between them in case we don't know for sure
-        * that the page is a slab page (e.g. page_cgroup_ino()), let's
-        * always set the lowest bit of obj_cgroups.
-        */
-       return (struct obj_cgroup **)
-               ((unsigned long)page->obj_cgroups & ~0x1UL);
-}
-
-static inline bool page_has_obj_cgroups(struct page *page)
-{
-       return ((unsigned long)page->obj_cgroups & 0x1UL);
-}
-
 int memcg_alloc_page_obj_cgroups(struct page *page, struct kmem_cache *s,
                                 gfp_t gfp);
 
 static inline void memcg_free_page_obj_cgroups(struct page *page)
 {
-       kfree(page_obj_cgroups(page));
-       page->obj_cgroups = NULL;
+       kfree(page_objcgs(page));
+       page->memcg_data = 0;
 }
 
 static inline size_t obj_full_size(struct kmem_cache *s)
@@ -304,7 +287,7 @@ static inline bool memcg_slab_pre_alloc_hook(struct kmem_cache *s,
 
 static inline void mod_objcg_state(struct obj_cgroup *objcg,
                                   struct pglist_data *pgdat,
-                                  int idx, int nr)
+                                  enum node_stat_item idx, int nr)
 {
        struct mem_cgroup *memcg;
        struct lruvec *lruvec;
@@ -333,7 +316,7 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s,
                if (likely(p[i])) {
                        page = virt_to_head_page(p[i]);
 
-                       if (!page_has_obj_cgroups(page) &&
+                       if (!page_objcgs(page) &&
                            memcg_alloc_page_obj_cgroups(page, s, flags)) {
                                obj_cgroup_uncharge(objcg, obj_full_size(s));
                                continue;
@@ -341,7 +324,7 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s,
 
                        off = obj_to_index(s, page, p[i]);
                        obj_cgroup_get(objcg);
-                       page_obj_cgroups(page)[off] = objcg;
+                       page_objcgs(page)[off] = objcg;
                        mod_objcg_state(objcg, page_pgdat(page),
                                        cache_vmstat_idx(s), obj_full_size(s));
                } else {
@@ -355,6 +338,7 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s_orig,
                                        void **p, int objects)
 {
        struct kmem_cache *s;
+       struct obj_cgroup **objcgs;
        struct obj_cgroup *objcg;
        struct page *page;
        unsigned int off;
@@ -368,7 +352,8 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s_orig,
                        continue;
 
                page = virt_to_head_page(p[i]);
-               if (!page_has_obj_cgroups(page))
+               objcgs = page_objcgs(page);
+               if (!objcgs)
                        continue;
 
                if (!s_orig)
@@ -377,11 +362,11 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s_orig,
                        s = s_orig;
 
                off = obj_to_index(s, page, p[i]);
-               objcg = page_obj_cgroups(page)[off];
+               objcg = objcgs[off];
                if (!objcg)
                        continue;
 
-               page_obj_cgroups(page)[off] = NULL;
+               objcgs[off] = NULL;
                obj_cgroup_uncharge(objcg, obj_full_size(s));
                mod_objcg_state(objcg, page_pgdat(page), cache_vmstat_idx(s),
                                -obj_full_size(s));
@@ -390,11 +375,6 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s_orig,
 }
 
 #else /* CONFIG_MEMCG_KMEM */
-static inline bool page_has_obj_cgroups(struct page *page)
-{
-       return false;
-}
-
 static inline struct mem_cgroup *memcg_from_slab_obj(void *ptr)
 {
        return NULL;
@@ -510,10 +490,7 @@ static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s,
 {
        flags &= gfp_allowed_mask;
 
-       fs_reclaim_acquire(flags);
-       fs_reclaim_release(flags);
-
-       might_sleep_if(gfpflags_allow_blocking(flags));
+       might_alloc(flags);
 
        if (should_failslab(s, flags))
                return NULL;