Skip to content

Commit bbd4e30

Browse files
qiwuchentorvalds
authored andcommitted
mm/slub.c: replace kmem_cache->cpu_partial with wrapped APIs
There are slub_cpu_partial() and slub_set_cpu_partial() APIs to wrap kmem_cache->cpu_partial. This patch will use the two APIs to replace kmem_cache->cpu_partial in slub code. Signed-off-by: chenqiwu <chenqiwu@xiaomi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> 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> Link: http://lkml.kernel.org/r/1582079562-17980-1-git-send-email-qiwuchen55@gmail.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4c7ba22 commit bbd4e30

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mm/slub.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
22822282
if (oldpage) {
22832283
pobjects = oldpage->pobjects;
22842284
pages = oldpage->pages;
2285-
if (drain && pobjects > s->cpu_partial) {
2285+
if (drain && pobjects > slub_cpu_partial(s)) {
22862286
unsigned long flags;
22872287
/*
22882288
* partial array is full. Move the existing
@@ -2307,7 +2307,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
23072307

23082308
} while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page)
23092309
!= oldpage);
2310-
if (unlikely(!s->cpu_partial)) {
2310+
if (unlikely(!slub_cpu_partial(s))) {
23112311
unsigned long flags;
23122312

23132313
local_irq_save(flags);
@@ -3512,15 +3512,15 @@ static void set_cpu_partial(struct kmem_cache *s)
35123512
* 50% to keep some capacity around for frees.
35133513
*/
35143514
if (!kmem_cache_has_cpu_partial(s))
3515-
s->cpu_partial = 0;
3515+
slub_set_cpu_partial(s, 0);
35163516
else if (s->size >= PAGE_SIZE)
3517-
s->cpu_partial = 2;
3517+
slub_set_cpu_partial(s, 2);
35183518
else if (s->size >= 1024)
3519-
s->cpu_partial = 6;
3519+
slub_set_cpu_partial(s, 6);
35203520
else if (s->size >= 256)
3521-
s->cpu_partial = 13;
3521+
slub_set_cpu_partial(s, 13);
35223522
else
3523-
s->cpu_partial = 30;
3523+
slub_set_cpu_partial(s, 30);
35243524
#endif
35253525
}
35263526

0 commit comments

Comments
 (0)