[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231021144317.3400916-5-chengming.zhou@linux.dev>
Date: Sat, 21 Oct 2023 14:43:15 +0000
From: chengming.zhou@...ux.dev
To: cl@...ux.com, penberg@...nel.org
Cc: rientjes@...gle.com, iamjoonsoo.kim@....com,
akpm@...ux-foundation.org, vbabka@...e.cz,
roman.gushchin@...ux.dev, 42.hyeyoo@...il.com, willy@...radead.org,
pcc@...gle.com, tytso@....edu, maz@...nel.org,
ruansy.fnst@...itsu.com, vishal.moola@...il.com,
lrh2000@....edu.cn, hughd@...gle.com, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, chengming.zhou@...ux.dev,
Chengming Zhou <zhouchengming@...edance.com>
Subject: [RFC PATCH v2 4/6] slub: Simplify acquire_slab()
From: Chengming Zhou <zhouchengming@...edance.com>
Now the object == NULL is always true, simplify acquire_slab().
Signed-off-by: Chengming Zhou <zhouchengming@...edance.com>
---
mm/slub.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 61ee82ea21b6..9f0b80fefc70 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2222,8 +2222,7 @@ static void *alloc_single_from_new_slab(struct kmem_cache *s,
* Returns a list of objects or NULL if it fails.
*/
static inline void *acquire_slab(struct kmem_cache *s,
- struct kmem_cache_node *n, struct slab *slab,
- int mode)
+ struct kmem_cache_node *n, struct slab *slab)
{
void *freelist;
unsigned long counters;
@@ -2239,12 +2238,8 @@ static inline void *acquire_slab(struct kmem_cache *s,
freelist = slab->freelist;
counters = slab->counters;
new.counters = counters;
- if (mode) {
- new.inuse = slab->objects;
- new.freelist = NULL;
- } else {
- new.freelist = freelist;
- }
+ new.inuse = slab->objects;
+ new.freelist = NULL;
VM_BUG_ON(new.frozen);
new.frozen = 1;
@@ -2306,7 +2301,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n,
}
if (!object) {
- t = acquire_slab(s, n, slab, object == NULL);
+ t = acquire_slab(s, n, slab);
if (t) {
*pc->slab = slab;
stat(s, ALLOC_FROM_PARTIAL);
--
2.20.1
Powered by blists - more mailing lists