On Tue, Nov 21, 2023 at 09:46:57AM -0800, Linus Torvalds wrote: > On Tue, 21 Nov 2023 at 04:27, Kirill A. Shutemov > <kirill.shutemov@xxxxxxxxxxxxxxx> wrote: > > > > NR_PAGE_ORDERS defines the number of page orders supported by the page > > allocator, ranging from 0 to MAX_ORDER, MAX_ORDER + 1 in total. > > > > NR_PAGE_ORDERS assists in defining arrays of page orders and allows for > > more natural iteration over them. > > These two patches look much better to me, but I think you missed one area. > > Most of the Kconfig changes by commit 23baf831a32c ("mm, treewide: > redefine MAX_ORDER sanely") should also be basically reverted to use > this new NR_PAGE_ORDERS. I am not convinced. Some architectures make this option user-visible and, in my view, user cares more about the largest page size buddy allocator can provide than size of the array inside the allocator. > IOW, I think the ARCH_FORCE_MAX_ORDER #defines etc should also be done > in "number of page orders". I suspect from a documentation standpoint > that also makes more sense in places, eg I think that right now your > patch says > > amount of memory for normal system use. The maximum > - possible value is MAX_ORDER/2. Setting this parameter > + possible value is MAX_PAGE_ORDER/2. Setting this > > and that's actually nonsensical, because it's NR_PAGE_ORDERS that was > at least historically the boundary (and historically the one that was > an even number that can be halved cleanly). Maybe historically (I didn't check), but not now. It is all over the place. And it more even in MAX_PAGE_ORDER terms than in NR_PAGE_ORDERS: arch/arc/Kconfig:config ARCH_FORCE_MAX_ORDER arch/arc/Kconfig- int "Maximum zone order" arch/arc/Kconfig- default "11" if ARC_HUGEPAGE_16M arch/arc/Kconfig- default "10" -- arch/arm/Kconfig:config ARCH_FORCE_MAX_ORDER arch/arm/Kconfig- int "Order of maximal physically contiguous allocations" arch/arm/Kconfig- default "11" if SOC_AM33XX arch/arm/Kconfig- default "8" if SA1111 arch/arm/Kconfig- default "10" -- arch/arm64/Kconfig:config ARCH_FORCE_MAX_ORDER arch/arm64/Kconfig- int arch/arm64/Kconfig- default "13" if ARM64_64K_PAGES arch/arm64/Kconfig- default "11" if ARM64_16K_PAGES arch/arm64/Kconfig- default "10" -- arch/loongarch/Kconfig:config ARCH_FORCE_MAX_ORDER arch/loongarch/Kconfig- int "Maximum zone order" arch/loongarch/Kconfig- default "13" if PAGE_SIZE_64KB arch/loongarch/Kconfig- default "11" if PAGE_SIZE_16KB arch/loongarch/Kconfig- default "10" -- arch/m68k/Kconfig.cpu:config ARCH_FORCE_MAX_ORDER arch/m68k/Kconfig.cpu- int "Order of maximal physically contiguous allocations" if ADVANCED arch/m68k/Kconfig.cpu- depends on !SINGLE_MEMORY_CHUNK arch/m68k/Kconfig.cpu- default "10" -- arch/mips/Kconfig:config ARCH_FORCE_MAX_ORDER arch/mips/Kconfig- int "Maximum zone order" arch/mips/Kconfig- default "13" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB arch/mips/Kconfig- default "12" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB arch/mips/Kconfig- default "11" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB arch/mips/Kconfig- default "10" -- arch/nios2/Kconfig:config ARCH_FORCE_MAX_ORDER arch/nios2/Kconfig- int "Order of maximal physically contiguous allocations" arch/nios2/Kconfig- default "10" -- arch/powerpc/Kconfig:config ARCH_FORCE_MAX_ORDER arch/powerpc/Kconfig- int "Order of maximal physically contiguous allocations" arch/powerpc/Kconfig- range 7 8 if PPC64 && PPC_64K_PAGES arch/powerpc/Kconfig- default "8" if PPC64 && PPC_64K_PAGES arch/powerpc/Kconfig- range 12 12 if PPC64 && !PPC_64K_PAGES arch/powerpc/Kconfig- default "12" if PPC64 && !PPC_64K_PAGES arch/powerpc/Kconfig- range 8 10 if PPC32 && PPC_16K_PAGES arch/powerpc/Kconfig- default "8" if PPC32 && PPC_16K_PAGES arch/powerpc/Kconfig- range 6 10 if PPC32 && PPC_64K_PAGES arch/powerpc/Kconfig- default "6" if PPC32 && PPC_64K_PAGES arch/powerpc/Kconfig- range 4 10 if PPC32 && PPC_256K_PAGES -- arch/sh/mm/Kconfig:config ARCH_FORCE_MAX_ORDER arch/sh/mm/Kconfig- int "Order of maximal physically contiguous allocations" arch/sh/mm/Kconfig- default "8" if PAGE_SIZE_16KB arch/sh/mm/Kconfig- default "6" if PAGE_SIZE_64KB arch/sh/mm/Kconfig- default "13" if !MMU arch/sh/mm/Kconfig- default "10" -- arch/sparc/Kconfig:config ARCH_FORCE_MAX_ORDER arch/sparc/Kconfig- int "Order of maximal physically contiguous allocations" arch/sparc/Kconfig- default "12" -- arch/xtensa/Kconfig:config ARCH_FORCE_MAX_ORDER arch/xtensa/Kconfig- int "Order of maximal physically contiguous allocations" arch/xtensa/Kconfig- default "10" -- Kiryl Shutsemau / Kirill A. Shutemov