Re: [PATCH v3 1/2] x86/mm: Handle alloc failure in phys_*_init()
From: Dave Hansen
Date: Tue Jun 10 2025 - 10:55:51 EST
On 6/10/25 03:16, Em Sharnoff wrote:
> + if (!pmd)
> + return (unsigned long)ERR_PTR(-ENOMEM);
All of this casting isn't great to look at. Just about every line of
code that this patch touches also introduces has a cast.
Could you please find a way to reduce the number of casts?
> + /*
> + * We might have IS_ERR(paddr_last) if allocation failed, but we should
> + * still update pud before bailing, so that subsequent retries can pick
> + * up on progress (here and in phys_pmd_init) without leaking pmd.
> + */
Please write everything in imperative voice. No "we's", please.
> - for (i = 0; i < nr_range; i++)
> + for (i = 0; i < nr_range; i++) {
> ret = kernel_physical_mapping_init(mr[i].start, mr[i].end,
> mr[i].page_size_mask,
> prot);
> + if (IS_ERR((void *)ret))
> + return ret;
> + }
Are there any _actual_ users of 'paddr_last'? I see a lot of setting it
and passing it around, but I _think_ this is the only place it actually
gets used. Here, the fact that it's an address doesn't even matter.