NFC: llcp: integer underflow in nfc_llcp_set_remote_gb()
[linux-2.6-block.git] / mm / slab.h
index 43d8a38b534f18fc09c3c4973974ca4f21b00ec6..34a98d642196f5e57e2bc2a1d94f7333b3ab7c48 100644 (file)
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -138,6 +138,30 @@ static inline bool slab_equal_or_root(struct kmem_cache *s,
        return (p == s) ||
                (s->memcg_params && (p == s->memcg_params->root_cache));
 }
+
+/*
+ * We use suffixes to the name in memcg because we can't have caches
+ * created in the system with the same name. But when we print them
+ * locally, better refer to them with the base name
+ */
+static inline const char *cache_name(struct kmem_cache *s)
+{
+       if (!is_root_cache(s))
+               return s->memcg_params->root_cache->name;
+       return s->name;
+}
+
+static inline struct kmem_cache *cache_from_memcg(struct kmem_cache *s, int idx)
+{
+       return s->memcg_params->memcg_caches[idx];
+}
+
+static inline struct kmem_cache *memcg_root_cache(struct kmem_cache *s)
+{
+       if (is_root_cache(s))
+               return s;
+       return s->memcg_params->root_cache;
+}
 #else
 static inline bool is_root_cache(struct kmem_cache *s)
 {
@@ -163,6 +187,21 @@ static inline bool slab_equal_or_root(struct kmem_cache *s,
 {
        return true;
 }
+
+static inline const char *cache_name(struct kmem_cache *s)
+{
+       return s->name;
+}
+
+static inline struct kmem_cache *cache_from_memcg(struct kmem_cache *s, int idx)
+{
+       return NULL;
+}
+
+static inline struct kmem_cache *memcg_root_cache(struct kmem_cache *s)
+{
+       return s;
+}
 #endif
 
 static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)