Commit 8fc8d666 authored by Vlastimil Babka's avatar Vlastimil Babka Committed by Linus Torvalds

mm, slub: extend checks guarded by slub_debug static key

There are few more places in SLUB that could benefit from reduced overhead
of the static key introduced by a previous patch:

- setup_object_debug() called on each object in newly allocated slab page
- setup_page_debug() called on newly allocated slab page
- __free_slab() called on freed slab page
Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarRoman Gushchin <guro@fb.com>
Acked-by: default avatarChristoph Lameter <cl@linux.com>
Cc: Jann Horn <jannh@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Vijayanand Jitta <vjitta@codeaurora.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Pekka Enberg <penberg@kernel.org>
Link: http://lkml.kernel.org/r/20200610163135.17364-9-vbabka@suse.czSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 59052e89
...@@ -1131,7 +1131,7 @@ static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects) ...@@ -1131,7 +1131,7 @@ static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects)
static void setup_object_debug(struct kmem_cache *s, struct page *page, static void setup_object_debug(struct kmem_cache *s, struct page *page,
void *object) void *object)
{ {
if (!(s->flags & (SLAB_STORE_USER|SLAB_RED_ZONE|__OBJECT_POISON))) if (!kmem_cache_debug_flags(s, SLAB_STORE_USER|SLAB_RED_ZONE|__OBJECT_POISON))
return; return;
init_object(s, object, SLUB_RED_INACTIVE); init_object(s, object, SLUB_RED_INACTIVE);
...@@ -1141,7 +1141,7 @@ static void setup_object_debug(struct kmem_cache *s, struct page *page, ...@@ -1141,7 +1141,7 @@ static void setup_object_debug(struct kmem_cache *s, struct page *page,
static static
void setup_page_debug(struct kmem_cache *s, struct page *page, void *addr) void setup_page_debug(struct kmem_cache *s, struct page *page, void *addr)
{ {
if (!(s->flags & SLAB_POISON)) if (!kmem_cache_debug_flags(s, SLAB_POISON))
return; return;
metadata_access_enable(); metadata_access_enable();
...@@ -1853,7 +1853,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page) ...@@ -1853,7 +1853,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
int order = compound_order(page); int order = compound_order(page);
int pages = 1 << order; int pages = 1 << order;
if (s->flags & SLAB_CONSISTENCY_CHECKS) { if (kmem_cache_debug_flags(s, SLAB_CONSISTENCY_CHECKS)) {
void *p; void *p;
slab_pad_check(s, page); slab_pad_check(s, page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment