On Sat, 30 Mar 2024, Chen Jun wrote:
When kmalloc_node() is called without __GFP_THISNODE and the target node
lacks sufficient memory, SLUB allocates a folio from a different node
other than the requested node, instead of taking a partial slab from it.
Hmmm... This would mean that we do not consult the partial lists of the
other nodes. That is something to be fixed in the allocator.
However, since the allocated folio does not belong to the requested
node, it is deactivated and added to the partial slab list of the node
it belongs to.
That should only occur if a request for an object for node X follows a
request for an object from node Y.
This behavior can result in excessive memory usage when the requested
node has insufficient memory, as SLUB will repeatedly allocate folios
from other nodes without reusing the previously allocated ones.
That is bad. Can we avoid that by verifying proper allocator behavior
during deactivation and ensuring that it searches remote partial objects
first before doing something drastic as going to the page allocator?
To prevent memory wastage,
when (node != NUMA_NO_NODE) && !(gfpflags & __GFP_THISNODE) is,
1) try to get a partial slab from target node with GFP_NOWAIT |
__GFP_THISNODE opportunistically.
Did we check the partial lists of that node first for available
objects before going to the page allocator?
get_any_partial() should do that. Maybe it is not called in the
kmalloc_node case.