]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - mm/slub.c
checkpatch: improve --git <commit-count> shortcut
[karo-tx-linux.git] / mm / slub.c
index 6c91324f9370663749877fa2e8ea8d9c87c1df73..825ff4505336e0a067a0ec297be96108cf6eaf23 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -254,11 +254,10 @@ static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)
 {
        void *p;
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
+       if (!debug_pagealloc_enabled())
+               return get_freepointer(s, object);
+
        probe_kernel_read(&p, (void **)(object + s->offset), sizeof(p));
-#else
-       p = get_freepointer(s, object);
-#endif
        return p;
 }
 
@@ -330,8 +329,8 @@ static inline void set_page_slub_counters(struct page *page, unsigned long count
        tmp.counters = counters_new;
        /*
         * page->counters can cover frozen/inuse/objects as well
-        * as page->_count.  If we assign to ->counters directly
-        * we run the risk of losing updates to page->_count, so
+        * as page->_refcount.  If we assign to ->counters directly
+        * we run the risk of losing updates to page->_refcount, so
         * be careful and only assign to the fields we need.
         */
        page->frozen  = tmp.frozen;
@@ -951,14 +950,14 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search)
                max_objects = MAX_OBJS_PER_PAGE;
 
        if (page->objects != max_objects) {
-               slab_err(s, page, "Wrong number of objects. Found %d but "
-                       "should be %d", page->objects, max_objects);
+               slab_err(s, page, "Wrong number of objects. Found %d but should be %d",
+                        page->objects, max_objects);
                page->objects = max_objects;
                slab_fix(s, "Number of objects adjusted.");
        }
        if (page->inuse != page->objects - nr) {
-               slab_err(s, page, "Wrong object count. Counter is %d but "
-                       "counted were %d", page->inuse, page->objects - nr);
+               slab_err(s, page, "Wrong object count. Counter is %d but counted were %d",
+                        page->inuse, page->objects - nr);
                page->inuse = page->objects - nr;
                slab_fix(s, "Object count adjusted.");
        }
@@ -1118,8 +1117,8 @@ static inline int free_consistency_checks(struct kmem_cache *s,
 
        if (unlikely(s != page->slab_cache)) {
                if (!PageSlab(page)) {
-                       slab_err(s, page, "Attempt to free object(0x%p) "
-                               "outside of slab", object);
+                       slab_err(s, page, "Attempt to free object(0x%p) outside of slab",
+                                object);
                } else if (!page->slab_cache) {
                        pr_err("SLUB <none>: no slab for object 0x%p.\n",
                               object);
@@ -1314,7 +1313,7 @@ static inline void dec_slabs_node(struct kmem_cache *s, int node,
 static inline void kmalloc_large_node_hook(void *ptr, size_t size, gfp_t flags)
 {
        kmemleak_alloc(ptr, size, 1, flags);
-       kasan_kmalloc_large(ptr, size);
+       kasan_kmalloc_large(ptr, size, flags);
 }
 
 static inline void kfree_hook(const void *x)
@@ -1427,7 +1426,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
         */
        alloc_gfp = (flags | __GFP_NOWARN | __GFP_NORETRY) & ~__GFP_NOFAIL;
        if ((alloc_gfp & __GFP_DIRECT_RECLAIM) && oo_order(oo) > oo_order(s->min))
-               alloc_gfp = (alloc_gfp | __GFP_NOMEMALLOC) & ~__GFP_DIRECT_RECLAIM;
+               alloc_gfp = (alloc_gfp | __GFP_NOMEMALLOC) & ~(__GFP_RECLAIM|__GFP_NOFAIL);
 
        page = alloc_slab_page(s, alloc_gfp, node, oo);
        if (unlikely(!page)) {
@@ -1540,7 +1539,8 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
        page_mapcount_reset(page);
        if (current->reclaim_state)
                current->reclaim_state->reclaimed_slab += pages;
-       __free_kmem_pages(page, order);
+       memcg_uncharge_slab(page, order, s);
+       __free_pages(page, order);
 }
 
 #define need_reserve_slab_rcu                                          \
@@ -1735,11 +1735,11 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
         * may return off node objects because partial slabs are obtained
         * from other nodes and filled up.
         *
-        * If /sys/kernel/slab/xx/defrag_ratio is set to 100 (which makes
-        * defrag_ratio = 1000) then every (well almost) allocation will
-        * first attempt to defrag slab caches on other nodes. This means
-        * scanning over all nodes to look for partial slabs which may be
-        * expensive if we do it every time we are trying to find a slab
+        * If /sys/kernel/slab/xx/remote_node_defrag_ratio is set to 100
+        * (which makes defrag_ratio = 1000) then every (well almost)
+        * allocation will first attempt to defrag slab caches on other nodes.
+        * This means scanning over all nodes to look for partial slabs which
+        * may be expensive if we do it every time we are trying to find a slab
         * with available objects.
         */
        if (!s->remote_node_defrag_ratio ||
@@ -2596,7 +2596,7 @@ void *kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size)
 {
        void *ret = slab_alloc(s, gfpflags, _RET_IP_);
        trace_kmalloc(_RET_IP_, ret, size, s->size, gfpflags);
-       kasan_kmalloc(s, ret, size);
+       kasan_kmalloc(s, ret, size, gfpflags);
        return ret;
 }
 EXPORT_SYMBOL(kmem_cache_alloc_trace);
@@ -2624,7 +2624,7 @@ void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
        trace_kmalloc_node(_RET_IP_, ret,
                           size, s->size, gfpflags, node);
 
-       kasan_kmalloc(s, ret, size);
+       kasan_kmalloc(s, ret, size, gfpflags);
        return ret;
 }
 EXPORT_SYMBOL(kmem_cache_alloc_node_trace);
@@ -3182,7 +3182,8 @@ static void early_kmem_cache_node_alloc(int node)
        init_object(kmem_cache_node, n, SLUB_RED_ACTIVE);
        init_tracking(kmem_cache_node, n);
 #endif
-       kasan_kmalloc(kmem_cache_node, n, sizeof(struct kmem_cache_node));
+       kasan_kmalloc(kmem_cache_node, n, sizeof(struct kmem_cache_node),
+                     GFP_KERNEL);
        init_kmem_cache_node(n);
        inc_slabs_node(kmem_cache_node, node, page->objects);
 
@@ -3439,10 +3440,9 @@ static int kmem_cache_open(struct kmem_cache *s, unsigned long flags)
        free_kmem_cache_nodes(s);
 error:
        if (flags & SLAB_PANIC)
-               panic("Cannot create slab %s size=%lu realsize=%u "
-                       "order=%u offset=%u flags=%lx\n",
-                       s->name, (unsigned long)s->size, s->size,
-                       oo_order(s->oo), s->offset, flags);
+               panic("Cannot create slab %s size=%lu realsize=%u order=%u offset=%u flags=%lx\n",
+                     s->name, (unsigned long)s->size, s->size,
+                     oo_order(s->oo), s->offset, flags);
        return -EINVAL;
 }
 
@@ -3562,7 +3562,7 @@ void *__kmalloc(size_t size, gfp_t flags)
 
        trace_kmalloc(_RET_IP_, ret, size, s->size, flags);
 
-       kasan_kmalloc(s, ret, size);
+       kasan_kmalloc(s, ret, size, flags);
 
        return ret;
 }
@@ -3607,7 +3607,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
 
        trace_kmalloc_node(_RET_IP_, ret, size, s->size, flags, node);
 
-       kasan_kmalloc(s, ret, size);
+       kasan_kmalloc(s, ret, size, flags);
 
        return ret;
 }
@@ -3635,8 +3635,9 @@ size_t ksize(const void *object)
 {
        size_t size = __ksize(object);
        /* We assume that ksize callers could use whole allocated area,
-          so we need unpoison this area. */
-       kasan_krealloc(object, size);
+        * so we need to unpoison this area.
+        */
+       kasan_unpoison_shadow(object, size);
        return size;
 }
 EXPORT_SYMBOL(ksize);
@@ -3697,7 +3698,7 @@ int __kmem_cache_shrink(struct kmem_cache *s, bool deactivate)
                 * s->cpu_partial is checked locklessly (see put_cpu_partial),
                 * so we have to make sure the change is visible.
                 */
-               kick_all_cpus_sync();
+               synchronize_sched();
        }
 
        flush_all(s);