Re: [RFC 3/3] mm/slub: add all_objects implementation in debugfs

From: Vlastimil Babka
Date: Wed May 26 2021 - 10:26:52 EST

On 5/21/21 2:11 PM, glittao@xxxxxxxxx wrote:
> From: Oliver Glitta <glittao@xxxxxxxxx>
> Add all_objects implementation to debugfs to print information
> about all objects in slub cache.

An example listing of 1-2 objects would be useful in the changelog.

Also can you describe what are the guarantees (or limitations) of observing
really all objects if the cache is modified by concurrent allocation and free


> +static void *debugfs_all_objects_start(struct seq_file *m, loff_t *ppos)
> +{
> + struct slab_debug_private *priv = m->private;
> + struct kmem_cache *s = priv->inode->i_private;
> + struct page *page;
> +
> + priv->map = kmalloc(BITS_TO_LONGS(MAX_OBJS_PER_PAGE), GFP_KERNEL);

We can use bitmap_alloc/bitmap_free wrappers and allocate according to objects
per page in the actual kmem_cache, not the theoretical maximum, see: