From: Jianfeng Wang Date: Tue, 23 Apr 2024 04:55:54 +0000 (-0700) Subject: slub: use count_partial_free_approx() in slab_out_of_memory() X-Git-Tag: v6.10-rc1~230^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b3d8a8e870144369fdbcbb1a78878ce98532265a;p=thirdparty%2Fkernel%2Flinux.git slub: use count_partial_free_approx() in slab_out_of_memory() 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 Acked-by: David Rientjes Signed-off-by: Vlastimil Babka --- diff --git a/mm/slub.c b/mm/slub.c index 7e2a208134c31..3aa12b9b323d9 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3301,7 +3301,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);