[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALzav=fmTVGDxAUcuqmcegAtd8gEW4F3Zp3AGMQBtXrCQgp+aA@mail.gmail.com>
Date: Mon, 27 Oct 2025 15:56:13 -0700
From: David Matlack <dmatlack@...gle.com>
To: Pasha Tatashin <pasha.tatashin@...een.com>
Cc: akpm@...ux-foundation.org, brauner@...nel.org, corbet@....net,
graf@...zon.com, jgg@...pe.ca, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-mm@...ck.org, masahiroy@...nel.org,
ojeda@...nel.org, pratyush@...nel.org, rdunlap@...radead.org, rppt@...nel.org,
tj@...nel.org, jasonmiu@...gle.com, skhawaja@...gle.com
Subject: Re: [PATCH v3 2/3] liveupdate: kho: Increase metadata bitmap size to PAGE_SIZE
On Mon, Oct 20, 2025 at 5:09 PM Pasha Tatashin
<pasha.tatashin@...een.com> wrote:
> -static void *xa_load_or_alloc(struct xarray *xa, unsigned long index, size_t sz)
> +static void *xa_load_or_alloc(struct xarray *xa, unsigned long index)
> {
> void *res = xa_load(xa, index);
>
> if (res)
> return res;
>
> - void *elm __free(kfree) = kzalloc(sz, GFP_KERNEL);
> + void *elm __free(kfree) = kzalloc(PAGE_SIZE, GFP_KERNEL);
>
> if (!elm)
> return ERR_PTR(-ENOMEM);
>
> - if (WARN_ON(kho_scratch_overlap(virt_to_phys(elm), sz)))
> + if (WARN_ON(kho_scratch_overlap(virt_to_phys(elm), PAGE_SIZE)))
> return ERR_PTR(-EINVAL);
Reading xa_load_or_alloc() is a bit confusing now.
It seems very generic (returns a void *) but now hard-codes a size
(PAGE_SIZE). You have to look at the caller to see it is allocating
for a struct kho_mem_phys_bits, and then at the definition of struct
kho_mem_phys_bits to see the static_assert() that this struct is
always PAGE_SIZE.
I would either keep letting the caller passing in size (if you think
this code is going to be re-used) or just commit to making
xa_load_or_alloc() specific to kho_mem_phys_bits. e.g. Change the
return type to struct kho_mem_phys_bits * and use sizeof() instead of
PAGE_SIZE.
Powered by blists - more mailing lists