Re: [PATCH] init: do_mounts: use kmalloc() for allocations of temporary buffers
From: SeongJae Park
Date: Wed May 20 2026 - 20:49:37 EST
On Wed, 20 May 2026 11:16:51 +0300 "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx> wrote:
> Several places in init/do_mounts.c allocate temporary buffers for
> filesystem names or options using __get_free_page() or alloc_page().
>
> Usage of alloc_page() APIs is not required there and only creates
> unnecessary noise with castings or conversion from struct page to void *.
>
> kmalloc() is a better API for these uses and it also provides better
> scalability and more debugging possibilities.
>
> Replace use of __get_free_page() and alloc_page() with kmalloc().
Makes sense. I once wondered if kmalloc_objs() fits here, but kmalloc() also
looks good to me.
>
> While on it, add a check for -ENOMEM condition in mount_root_generic().
>
> Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@xxxxxxxxxx
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>
Thanks,
SJ
[...]