linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] slub: limit number of slabs to scan in count_partial()
@ 2024-04-17 18:59 Jianfeng Wang
  2024-04-17 18:59 ` [PATCH v2 1/1] " Jianfeng Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Jianfeng Wang @ 2024-04-17 18:59 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: akpm, cl, vbabka, penberg, rientjes, iamjoonsoo.kim, junxiao.bi

This patch fixes a known issue in get_slabinfo() which relies on
count_partial() to get the exact count of free objects in a
kmem_cache_node's partial list. For some slub caches, their per-node
partial list can be extremely long. The current version of
count_partial() traverses the partial list to get the exact count of
objects while holding the kmem_cache_node's spinlock. This process
may take a long time, during which slab allocations are blocked and
IRQs are disabled. In production workloads, even NMI watchdog can be
triggered due to this matter. Moreover, getting the exact count of
objects may not be useful as well: the count may change right after
the spinlock is released and re-captured by others.

The proposed fix is to limit the number of slabs to scan, and output
an approximated object count for a long partial list. The v1 patch
counts N slabs from the list's head and then uses it to approximate
the total object count in the list. As suggested by Vlastimil, an
alternative method, i.e., counting N/2 from both the list's head and
tail, produces a more accurate approximation after the partial list
is sorted by kmem_cache_shrink().

---
Changes since v1 [1]
 - Update the approximation method by counting from the list's head and tail
 - Cap the approximation by the total object count
 - Update the commit message to add benchmark results and explain the choice

[1] https://lore.kernel.org/linux-mm/20240411164023.99368-1-jianfeng.w.wang@oracle.com/

Thanks,
--Jianfeng

Jianfeng Wang (1):
  slub: limit number of slabs to scan in count_partial()

 mm/slub.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

-- 
2.42.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-18 22:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-17 18:59 [PATCH v2 0/1] slub: limit number of slabs to scan in count_partial() Jianfeng Wang
2024-04-17 18:59 ` [PATCH v2 1/1] " Jianfeng Wang
2024-04-18 10:01   ` Vlastimil Babka
2024-04-18 22:44     ` Jianfeng Wang

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).