diff options
| author | Harry Yoo <[email protected]> | 2025-11-11 12:53:31 +0000 |
|---|---|---|
| committer | Vlastimil Babka <[email protected]> | 2025-11-13 18:56:46 +0000 |
| commit | cbcff934fa7deb670d9545a3aad4d07e8f1e4f3c (patch) | |
| tree | af142ae6a12f456ed3bcc1b53cbe7d51f25028b4 /lib/mpi/mpi-mod.c | |
| parent | slab: prevent infinite loop in kmalloc_nolock() with debugging (diff) | |
| download | kernel-cbcff934fa7deb670d9545a3aad4d07e8f1e4f3c.tar.gz kernel-cbcff934fa7deb670d9545a3aad4d07e8f1e4f3c.zip | |
mm/slub: fix memory leak in free_to_pcs_bulk()
The commit 989b09b73978 ("slab: skip percpu sheaves for remote object
freeing") introduced the remote_objects array in free_to_pcs_bulk() to
skip sheaves when objects from a remote node are freed.
However, the array is flushed only when:
1) the array becomes full (++remote_nr >= PCS_BATCH_MAX), or
2) slab_free_hook() returns false and size becomes zero.
When neither of the conditions is met, objects in the array are leaked.
This resulted in a memory leak [1], where 82 GiB of memory was allocated
for the maple_node cache.
Flush the array after successfully freeing objects to sheaves
in the do_free: path.
In the meantime, move the snippet if (!size) goto flush_remote; outside
the while loop for readability. Let's say all objects in the array are
from a remote node: then we acquire s->cpu_sheaves->lock and try to free
an object even when size is zero. This doesn't appear to be harmful,
but isn't really readable.
Reported-by: Tytus Rogalewski <[email protected]>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220765 [1]
Closes: https://lore.kernel.org/linux-mm/[email protected]
Closes: https://lore.kernel.org/all/aRGDTwbt2EIz2CYn@hyeyoo
Fixes: 989b09b73978 ("slab: skip percpu sheaves for remote object freeing")
Signed-off-by: Harry Yoo <[email protected]>
Link: https://patch.msgid.link/[email protected]
Acked-by: Liam R. Howlett <[email protected]>
Tested-by: Darrick J. Wong <[email protected]>
Tested-by: Tytus Rogalewski <[email protected]>
Signed-off-by: Vlastimil Babka <[email protected]>
Diffstat (limited to 'lib/mpi/mpi-mod.c')
0 files changed, 0 insertions, 0 deletions
