From: Yejune Deng <yejune.deng@gmail.com>
To: cl@linux.com, penberg@kernel.org, rientjes@google.com,
iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
vbabka@suse.cz
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Yejune Deng <yejune.deng@gmail.com>
Subject: [PATCH] mm/slab.c: use 'ac' from the caller
Date: Wed, 21 Apr 2021 10:25:17 +0800 [thread overview]
Message-ID: <20210421022518.67451-1-yejune.deng@gmail.com> (raw)
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@gmail.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
next reply other threads:[~2021-04-21 2:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-21 2:25 Yejune Deng [this message]
2021-04-21 3:10 ` [PATCH] mm/slab.c: use 'ac' from the caller Matthew Wilcox
2021-04-21 7:20 ` Christoph Lameter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210421022518.67451-1-yejune.deng@gmail.com \
--to=yejune.deng@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).