aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Yang <richard.weiyang@gmail.com>2017-07-06 18:36:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-06 19:24:30 -0400
commitd4ff6d35f618023f7b2edc5ce1a2f84362f1e7fe (patch)
treecb4e877feda5ff87970bc765ff121a3d149817c1
parent66fdbe520315ee2ec0dbc8da5af4003d3911c534 (diff)
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.com Signed-off-by: Wei 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/slub.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/mm/slub.c b/mm/slub.c
index b6b637503d77..7234e0e03bdc 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1993,7 +1993,7 @@ static void init_kmem_cache_cpus(struct kmem_cache *s)
1993 * Remove the cpu slab 1993 * Remove the cpu slab
1994 */ 1994 */
1995static void deactivate_slab(struct kmem_cache *s, struct page *page, 1995static void deactivate_slab(struct kmem_cache *s, struct page *page,
1996 void *freelist) 1996 void *freelist, struct kmem_cache_cpu *c)
1997{ 1997{
1998 enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE }; 1998 enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE };
1999 struct kmem_cache_node *n = get_node(s, page_to_nid(page)); 1999 struct kmem_cache_node *n = get_node(s, page_to_nid(page));
@@ -2132,6 +2132,9 @@ redo:
2132 discard_slab(s, page); 2132 discard_slab(s, page);
2133 stat(s, FREE_SLAB); 2133 stat(s, FREE_SLAB);
2134 } 2134 }
2135
2136 c->page = NULL;
2137 c->freelist = NULL;
2135} 2138}
2136 2139
2137/* 2140/*
@@ -2266,11 +2269,9 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
2266static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) 2269static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
2267{ 2270{
2268 stat(s, CPUSLAB_FLUSH); 2271 stat(s, CPUSLAB_FLUSH);
2269 deactivate_slab(s, c->page, c->freelist); 2272 deactivate_slab(s, c->page, c->freelist, c);
2270 2273
2271 c->tid = next_tid(c->tid); 2274 c->tid = next_tid(c->tid);
2272 c->page = NULL;
2273 c->freelist = NULL;
2274} 2275}
2275 2276
2276/* 2277/*
@@ -2521,9 +2522,7 @@ redo:
2521 2522
2522 if (unlikely(!node_match(page, searchnode))) { 2523 if (unlikely(!node_match(page, searchnode))) {
2523 stat(s, ALLOC_NODE_MISMATCH); 2524 stat(s, ALLOC_NODE_MISMATCH);
2524 deactivate_slab(s, page, c->freelist); 2525 deactivate_slab(s, page, c->freelist, c);
2525 c->page = NULL;
2526 c->freelist = NULL;
2527 goto new_slab; 2526 goto new_slab;
2528 } 2527 }
2529 } 2528 }
@@ -2534,9 +2533,7 @@ redo:
2534 * information when the page leaves the per-cpu allocator 2533 * information when the page leaves the per-cpu allocator
2535 */ 2534 */
2536 if (unlikely(!pfmemalloc_match(page, gfpflags))) { 2535 if (unlikely(!pfmemalloc_match(page, gfpflags))) {
2537 deactivate_slab(s, page, c->freelist); 2536 deactivate_slab(s, page, c->freelist, c);
2538 c->page = NULL;
2539 c->freelist = NULL;
2540 goto new_slab; 2537 goto new_slab;
2541 } 2538 }
2542 2539
@@ -2591,9 +2588,7 @@ new_slab:
2591 !alloc_debug_processing(s, page, freelist, addr)) 2588 !alloc_debug_processing(s, page, freelist, addr))
2592 goto new_slab; /* Slab failed checks. Next slab needed */ 2589 goto new_slab; /* Slab failed checks. Next slab needed */
2593 2590
2594 deactivate_slab(s, page, get_freepointer(s, freelist)); 2591 deactivate_slab(s, page, get_freepointer(s, freelist), c);
2595 c->page = NULL;
2596 c->freelist = NULL;
2597 return freelist; 2592 return freelist;
2598} 2593}
2599 2594