On Wed, Apr 30, 2025 at 10:11:22PM +0900, Harry Yoo wrote: > A more general question: will either shattering or allocating > smaller slabs help free more memory anyway? In general, no. > It likely depends on > the spatial pattern of how the objects are reclaimed and remain > populated within a slab? Right - the pattern of inode/dentry residency in slab pages is defined by temporal access patterns of any given inode/dentry. If an application creates a new file and then holds it open, then that slab page is pinned in memory until the application closes that file. Hence if we mix short term file accesses (e.g. access once files (like updatedb) or short term temp files (like object files during a code build) with long term open files, the slabs get fragmented because of the few pinned long term objects in each slab page. IOWs, the moment we start mixing objects with different temporal access patterns within a single slab page during rapid cache growth, we will get fragmentation of the cache as reclaim only removes the short term objects during subsequent rapid cache shrinkage.... The unsolvable problem here is that we do not know (and cannot know) what the life time of the object is going to be at object instantiation time (i.e. path lookup). Hence the temporal access patterns of objects in the slab pages are going to be largely random. Experience tells me that even single page slabs (old skool SLAB cache) had these fragmentation problems (esp. with dentries) because even a 20:1 ratio of short:long term accesses will leave a single long term dentry per 4kB slab backing page... Hence using smaller slabs and/or shattering larger slabs isn't likely to have all that much impact on the fragmentation of the slabs because it doesn't do anything to solve the underlying object lifetime interleaving that causes the fragmentation in the first place... -Dave. -- Dave Chinner david@xxxxxxxxxxxxx