On Mon, Nov 21, 2022 at 06:11:59PM +0100, Vlastimil Babka wrote: > In the following patch we want to introduce CONFIG_SLUB_TINY allocation > paths that don't use the percpu slab. To prepare, refactor the > allocation functions: > > Split out __slab_alloc_node() from slab_alloc_node() where the former > does the actual allocation and the latter calls the pre/post hooks. > > Analogically, split out __kmem_cache_alloc_bulk() from > kmem_cache_alloc_bulk(). > > Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx> > --- > mm/slub.c | 127 +++++++++++++++++++++++++++++++++--------------------- > 1 file changed, 77 insertions(+), 50 deletions(-) [...] > + > +/* Note that interrupts must be enabled when calling this function. */ > +int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, > + void **p) > +{ > + int i; > + struct obj_cgroup *objcg = NULL; > + > + /* memcg and kmem_cache debug support */ > + s = slab_pre_alloc_hook(s, NULL, &objcg, size, flags); > + if (unlikely(!s)) > + return false; > + > + i = __kmem_cache_alloc_bulk(s, flags, size, p, objcg); > + > + /* > + * memcg and kmem_cache debug support and memory initialization. > + * Done outside of the IRQ disabled fastpath loop. > + */ > + if (i != 0) > + slab_post_alloc_hook(s, objcg, flags, size, p, > + slab_want_init_on_alloc(flags, s)); This patch looks mostly good but wondering what happens if someone calls it with size == 0 so it does not call slab_post_alloc_hook()? > + return i; > } > EXPORT_SYMBOL(kmem_cache_alloc_bulk); > > -- > 2.38.1 > -- Thanks, Hyeonggon