The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.16
------>
commit 96beb3ff688667036170e120abb912465dae3d61
Author: Vladimir Davydov <[email protected]>
Date:   Mon May 2 18:06:01 2016 +0400

    ms/slab: add SLAB_ACCOUNT flag
    
    Currently, if we want to account all objects of a particular kmem cache,
    we have to pass __GFP_ACCOUNT to each kmem_cache_alloc call, which is
    inconvenient.  This patch introduces SLAB_ACCOUNT flag which if passed
    to kmem_cache_create will force accounting for every allocation from
    this cache even if __GFP_ACCOUNT is not passed.
    
    This patch does not make any of the existing caches use this flag - it
    will be done later in the series.
    
    Note, a cache with SLAB_ACCOUNT cannot be merged with a cache w/o
    SLAB_ACCOUNT, because merged caches share the same kmem_cache struct and
    hence cannot have different sets of SLAB_* flags.  Thus using this flag
    will probably reduce the number of merged slabs even if kmem accounting
    is not used (only compiled in).
    
    Signed-off-by: Vladimir Davydov <[email protected]>
    
    Suggested-by: Tejun Heo <[email protected]>
    Acked-by: Johannes Weiner <[email protected]>
    Acked-by: Michal Hocko <[email protected]>
    Cc: Greg Thelen <[email protected]>
    Cc: Christoph Lameter <[email protected]>
    Cc: Pekka Enberg <[email protected]>
    Cc: David Rientjes <[email protected]>
    Cc: Joonsoo Kim <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Linus Torvalds <[email protected]>
    (cherry picked from commit 230e9fc2860450fbb1f33bdcf9093d92d7d91f5b)
    Signed-off-by: Vladimir Davydov <[email protected]>
    
    Conflicts:
        include/linux/memcontrol.h
        mm/memcontrol.c
        mm/slab_common.c
---
 include/linux/memcontrol.h | 2 --
 include/linux/slab.h       | 5 +++++
 mm/memcontrol.c            | 6 ++++++
 mm/slab.h                  | 5 +++--
 mm/slub.c                  | 4 +++-
 5 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index c21f78b..743fb0b 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -638,8 +638,6 @@ memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)
 {
        if (!memcg_kmem_enabled())
                return cachep;
-       if (!(gfp & __GFP_ACCOUNT))
-               return cachep;
        if (gfp & __GFP_NOFAIL)
                return cachep;
        if (in_interrupt() || (!current->mm) || (current->flags & PF_KTHREAD))
diff --git a/include/linux/slab.h b/include/linux/slab.h
index ef8760b..f454fcd 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -79,6 +79,11 @@
 #else
 # define SLAB_FAILSLAB         0x00000000UL
 #endif
+#ifdef CONFIG_MEMCG_KMEM
+# define SLAB_ACCOUNT          0x04000000UL    /* Account to memcg */
+#else
+# define SLAB_ACCOUNT          0x00000000UL
+#endif
 
 /* The following flags affect the page allocator grouping pages by mobility */
 #define SLAB_RECLAIM_ACCOUNT   0x00020000UL            /* Objects are 
reclaimable */
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7061864..2a6c1f7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3453,6 +3453,12 @@ struct kmem_cache *__memcg_kmem_get_cache(struct 
kmem_cache *cachep,
 
        VM_BUG_ON(!is_root_cache(cachep));
 
+       if (cachep->flags & SLAB_ACCOUNT)
+               gfp |= __GFP_ACCOUNT;
+
+       if (!(gfp & __GFP_ACCOUNT))
+               return cachep;
+
        if (!current->mm || current->memcg_kmem_skip_account)
                return cachep;
 
diff --git a/mm/slab.h b/mm/slab.h
index 57de63f..66257a4 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -114,10 +114,11 @@ __kmem_cache_alias(const char *name, size_t size, size_t 
align,
 
 #if defined(CONFIG_SLAB)
 #define SLAB_CACHE_FLAGS (SLAB_MEM_SPREAD | SLAB_NOLEAKTRACE | \
-                         SLAB_RECLAIM_ACCOUNT | SLAB_TEMPORARY | SLAB_NOTRACK)
+                         SLAB_RECLAIM_ACCOUNT | SLAB_TEMPORARY | \
+                         SLAB_NOTRACK | SLAB_ACCOUNT)
 #elif defined(CONFIG_SLUB)
 #define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \
-                         SLAB_TEMPORARY | SLAB_NOTRACK)
+                         SLAB_TEMPORARY | SLAB_NOTRACK | SLAB_ACCOUNT)
 #else
 #define SLAB_CACHE_FLAGS (0)
 #endif
diff --git a/mm/slub.c b/mm/slub.c
index 80c7b79..c62e381 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -169,7 +169,7 @@ static inline int kmem_cache_debug(struct kmem_cache *s)
                SLAB_FAILSLAB)
 
 #define SLUB_MERGE_SAME (SLAB_DEBUG_FREE | SLAB_RECLAIM_ACCOUNT | \
-               SLAB_CACHE_DMA | SLAB_NOTRACK)
+               SLAB_CACHE_DMA | SLAB_NOTRACK | SLAB_ACCOUNT)
 
 #define OO_SHIFT       16
 #define OO_MASK                ((1 << OO_SHIFT) - 1)
@@ -5228,6 +5228,8 @@ static char *create_unique_id(struct kmem_cache *s)
                *p++ = 'F';
        if (!(s->flags & SLAB_NOTRACK))
                *p++ = 't';
+       if (s->flags & SLAB_ACCOUNT)
+               *p++ = 'A';
        if (p != name + 1)
                *p++ = '-';
        p += sprintf(p, "%07d", s->size);
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to