linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jianfeng Wang <jianfeng.w.wang@oracle.com>
To: linux-mm@kvack.org
Cc: vbabka@suse.cz, cl@linux.com, rientjes@google.com,
	akpm@linux-foundation.org, jianfeng.w.wang@oracle.com
Subject: [PATCH v4 2/2] slub: use count_partial_free_approx() in slab_out_of_memory()
Date: Mon, 22 Apr 2024 21:55:54 -0700	[thread overview]
Message-ID: <20240423045554.15045-3-jianfeng.w.wang@oracle.com> (raw)
In-Reply-To: <20240423045554.15045-1-jianfeng.w.wang@oracle.com>

slab_out_of_memory() uses count_partial() to get the exact count
of free objects for each node. As it may get called in the slab
allocation path, count_partial_free_approx() can be used to avoid
the risk and overhead of traversing a long partial slab list.

At the same time, show_slab_objects() still uses count_partial().
Thus, slub users can still have the option to access the exact
count of objects via sysfs if the overhead is acceptable to them.

Signed-off-by: Jianfeng Wang <jianfeng.w.wang@oracle.com>
Acked-by: David Rientjes <rientjes@google.com>
---
 mm/slub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/slub.c b/mm/slub.c
index 6d8ecad07daf..5c112817160b 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3292,7 +3292,7 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
 		unsigned long nr_objs;
 		unsigned long nr_free;
 
-		nr_free  = count_partial(n, count_free);
+		nr_free  = count_partial_free_approx(n);
 		nr_slabs = node_nr_slabs(n);
 		nr_objs  = node_nr_objs(n);
 
-- 
2.42.1



  parent reply	other threads:[~2024-04-23  4:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23  4:55 [PATCH v4 0/2] slub: introduce count_partial_free_approx() Jianfeng Wang
2024-04-23  4:55 ` [PATCH v4 1/2] " Jianfeng Wang
2024-04-23 16:09   ` Christoph Lameter (Ampere)
2024-04-23  4:55 ` Jianfeng Wang [this message]
2024-04-23 11:22 ` [PATCH v4 0/2] " Vlastimil Babka

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=20240423045554.15045-3-jianfeng.w.wang@oracle.com \
    --to=jianfeng.w.wang@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=linux-mm@kvack.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