[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210421022518.67451-1-yejune.deng@gmail.com>
Date: Wed, 21 Apr 2021 10:25:17 +0800
From: Yejune Deng <yejune.deng@...il.com>
To: cl@...ux.com, penberg@...nel.org, rientjes@...gle.com,
iamjoonsoo.kim@....com, akpm@...ux-foundation.org, vbabka@...e.cz
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Yejune Deng <yejune.deng@...il.com>
Subject: [PATCH] mm/slab.c: use 'ac' from the caller
It can use 'ac' from ____cache_alloc() in cache_alloc_refill().
This saves call cpu_cache_get() twice.
Signed-off-by: Yejune Deng <yejune.deng@...il.com>
---
mm/slab.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index d0f725637663..4b2dc8f8cc37 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2896,11 +2896,11 @@ static __always_inline int alloc_block(struct kmem_cache *cachep,
return batchcount;
}
-static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags)
+static void *cache_alloc_refill(struct kmem_cache *cachep, struct array_cache *ac, gfp_t flags)
{
int batchcount;
struct kmem_cache_node *n;
- struct array_cache *ac, *shared;
+ struct array_cache *shared;
int node;
void *list = NULL;
struct page *page;
@@ -2908,7 +2908,6 @@ static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags)
check_irq_off();
node = numa_mem_id();
- ac = cpu_cache_get(cachep);
batchcount = ac->batchcount;
if (!ac->touched && batchcount > BATCHREFILL_LIMIT) {
/*
@@ -3045,12 +3044,7 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
}
STATS_INC_ALLOCMISS(cachep);
- objp = cache_alloc_refill(cachep, flags);
- /*
- * the 'ac' may be updated by cache_alloc_refill(),
- * and kmemleak_erase() requires its correct value.
- */
- ac = cpu_cache_get(cachep);
+ objp = cache_alloc_refill(cachep, ac, flags);
out:
/*
--
2.29.0
Powered by blists - more mailing lists