[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y4NB5i4WBvLr1GGZ@hyeyoo>
Date: Sun, 27 Nov 2022 19:54:30 +0900
From: Hyeonggon Yoo <42.hyeyoo@...il.com>
To: Vlastimil Babka <vbabka@...e.cz>
Cc: Christoph Lameter <cl@...ux.com>,
David Rientjes <rientjes@...gle.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Pekka Enberg <penberg@...nel.org>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Matthew Wilcox <willy@...radead.org>, patches@...ts.linux.dev,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 09/12] mm, slub: split out allocations from pre/post hooks
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@...e.cz>
> ---
> 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
Powered by blists - more mailing lists