Re: [PATCH v6] mm/memblock: Add memblock_alloc_or_panic interface
Weikang Guo <[email protected]>
| Newsgroups | gmane.linux.ports.alpha,gmane.linux.kernel,gmane.linux.ports.arm.kernel,gmane.linux.ports.mips,gmane.linux.ports.parisc,gmane.linux.ports.ppc64.devel,gmane.linux.ports.riscv,gmane.linux.ports.sh.devel,gmane.linux.ports.sparc,gmane.linux.uml.devel,gmane.linux.acpi.devel,gmane.comp.emulators.xen.devel,gmane.linux.ports.arm.omap,gmane.linux.kernel.clk,gmane.linux.drivers.devicetree,gmane.linux.kernel.mm,gmane.linux.power-management.general |
|---|---|
| Message-ID | <CAOm6qn=L0GzX4z4Mak1LH6R4wD282dz6qafMFmA39ADaBuLJJQ@mail.gmail.com> |
Mike Rapoport <[email protected]> wrote on Sunday, 22 December 2024 18:06 > > On Sun, Dec 22, 2024 at 01:43:31PM +0800, Guo Weikang wrote: > > Before SLUB initialization, various subsystems used memblock_alloc to > > allocate memory. In most cases, when memory allocation fails, an immediate > > panic is required. To simplify this behavior and reduce repetitive checks, > > introduce `memblock_alloc_or_panic`. This function ensures that memory > > allocation failures result in a panic automatically, improving code > > readability and consistency across subsystems that require this behavior. > > > > Signed-off-by: Guo Weikang <[email protected]> > > --- > > ... > > > diff --git a/include/linux/memblock.h b/include/linux/memblock.h > > index 673d5cae7c81..73af7ca3fa1c 100644 > > --- a/include/linux/memblock.h > > +++ b/include/linux/memblock.h > > @@ -417,6 +417,12 @@ static __always_inline void *memblock_alloc(phys_addr_t size, phys_addr_t align) > > MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE); > > } > > > > +void *__memblock_alloc_or_panic(phys_addr_t size, phys_addr_t align, > > + const char *func); > > Please align this line with the first parameter to the function. > Other than that > > Acked-by: Mike Rapoport (Microsoft) <[email protected]> > Got it! Thanks for the feedback! > > + > > +#define memblock_alloc_or_panic(size, align) \ > > + __memblock_alloc_or_panic(size, align, __func__) > > + > > static inline void *memblock_alloc_raw(phys_addr_t size, > > phys_addr_t align) > > { > > > -- > Sincerely yours, > Mike. Best regards. Guo