All of lore.kernel.org
 help / color / mirror / Atom feed
From: sxwjean@me.com
To: Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Xiongwei Song <xiongwei.song@windriver.com>
Subject: [PATCH] mm/slub: Simplify get_partial_node()
Date: Mon, 11 Mar 2024 21:27:20 +0800	[thread overview]
Message-ID: <20240311132720.37741-1-sxwjean@me.com> (raw)

From: Xiongwei Song <xiongwei.song@windriver.com>

Remove the check of !kmem_cache_has_cpu_partial() because it is always
false, we've known this by calling kmem_cache_debug() before calling
remove_partial(), so we can remove the check.

Meanwhile, redo filling cpu partial and add comment to improve the
readability.

Signed-off-by: Xiongwei Song <xiongwei.song@windriver.com>
---
 mm/slub.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index a3ab096c38c0..62388f2a0ac7 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2620,19 +2620,21 @@ static struct slab *get_partial_node(struct kmem_cache *s,
 		if (!partial) {
 			partial = slab;
 			stat(s, ALLOC_FROM_PARTIAL);
-		} else {
+
+			/* Fill cpu partial if needed from next iteration, or break */
+			if (IS_ENABLED(CONFIG_SLUB_CPU_PARTIAL))
+				continue;
+			else
+				break;
+		}
+
+		if (IS_ENABLED(CONFIG_SLUB_CPU_PARTIAL)) {
 			put_cpu_partial(s, slab, 0);
 			stat(s, CPU_PARTIAL_NODE);
-			partial_slabs++;
-		}
-#ifdef CONFIG_SLUB_CPU_PARTIAL
-		if (!kmem_cache_has_cpu_partial(s)
-			|| partial_slabs > s->cpu_partial_slabs / 2)
-			break;
-#else
-		break;
-#endif
 
+			if (++partial_slabs > s->cpu_partial_slabs/2)
+				break;
+		}
 	}
 	spin_unlock_irqrestore(&n->list_lock, flags);
 	return partial;
-- 
2.34.1


             reply	other threads:[~2024-03-11 13:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 13:27 sxwjean [this message]
2024-03-12  6:21 ` [PATCH] mm/slub: Simplify get_partial_node() Chengming Zhou
2024-03-12  6:53   ` Song, Xiongwei

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=20240311132720.37741-1-sxwjean@me.com \
    --to=sxwjean@me.com \
    --cc=42.hyeyoo@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=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    --cc=xiongwei.song@windriver.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.