Commit d4ff6d35 authored by Wei Yang's avatar Wei Yang Committed by Linus Torvalds

mm/slub: reset cpu_slab's pointer in deactivate_slab()

Each time a slab is deactivated, the page and freelist pointer should be
reset.

This patch just merges these two options into deactivate_slab().

Link: http://lkml.kernel.org/r/20170507031215.3130-2-richard.weiyang@gmail.comSigned-off-by: default avatarWei Yang <richard.weiyang@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 66fdbe52
...@@ -1993,7 +1993,7 @@ static void init_kmem_cache_cpus(struct kmem_cache *s) ...@@ -1993,7 +1993,7 @@ static void init_kmem_cache_cpus(struct kmem_cache *s)
* Remove the cpu slab * Remove the cpu slab
*/ */
static void deactivate_slab(struct kmem_cache *s, struct page *page, static void deactivate_slab(struct kmem_cache *s, struct page *page,
void *freelist) void *freelist, struct kmem_cache_cpu *c)
{ {
enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE }; enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE };
struct kmem_cache_node *n = get_node(s, page_to_nid(page)); struct kmem_cache_node *n = get_node(s, page_to_nid(page));
...@@ -2132,6 +2132,9 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page, ...@@ -2132,6 +2132,9 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page,
discard_slab(s, page); discard_slab(s, page);
stat(s, FREE_SLAB); stat(s, FREE_SLAB);
} }
c->page = NULL;
c->freelist = NULL;
} }
/* /*
...@@ -2266,11 +2269,9 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) ...@@ -2266,11 +2269,9 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
{ {
stat(s, CPUSLAB_FLUSH); stat(s, CPUSLAB_FLUSH);
deactivate_slab(s, c->page, c->freelist); deactivate_slab(s, c->page, c->freelist, c);
c->tid = next_tid(c->tid); c->tid = next_tid(c->tid);
c->page = NULL;
c->freelist = NULL;
} }
/* /*
...@@ -2521,9 +2522,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, ...@@ -2521,9 +2522,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
if (unlikely(!node_match(page, searchnode))) { if (unlikely(!node_match(page, searchnode))) {
stat(s, ALLOC_NODE_MISMATCH); stat(s, ALLOC_NODE_MISMATCH);
deactivate_slab(s, page, c->freelist); deactivate_slab(s, page, c->freelist, c);
c->page = NULL;
c->freelist = NULL;
goto new_slab; goto new_slab;
} }
} }
...@@ -2534,9 +2533,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, ...@@ -2534,9 +2533,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
* information when the page leaves the per-cpu allocator * information when the page leaves the per-cpu allocator
*/ */
if (unlikely(!pfmemalloc_match(page, gfpflags))) { if (unlikely(!pfmemalloc_match(page, gfpflags))) {
deactivate_slab(s, page, c->freelist); deactivate_slab(s, page, c->freelist, c);
c->page = NULL;
c->freelist = NULL;
goto new_slab; goto new_slab;
} }
...@@ -2591,9 +2588,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, ...@@ -2591,9 +2588,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
!alloc_debug_processing(s, page, freelist, addr)) !alloc_debug_processing(s, page, freelist, addr))
goto new_slab; /* Slab failed checks. Next slab needed */ goto new_slab; /* Slab failed checks. Next slab needed */
deactivate_slab(s, page, get_freepointer(s, freelist)); deactivate_slab(s, page, get_freepointer(s, freelist), c);
c->page = NULL;
c->freelist = NULL;
return freelist; return freelist;
} }
......
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