Fix confusion around MAX_ORDER
Subsystems (66)
cover Fix confusion around MAX_ORDER
MAX_ORDER currently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.
This definition is counter-intuitive and lead to number of bugs all over the kernel.
Fix the bugs and then change the definition of MAX_ORDER to be
inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.
Kirill A. Shutemov (10):
sparc/mm: Fix MAX_ORDER usage in tsb_grow()
um: Fix MAX_ORDER usage in linux_main()
floppy: Fix MAX_ORDER usage
drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
genwqe: Fix MAX_ORDER usage
perf/core: Fix MAX_ORDER usage in rb_alloc_aux_page() mm/page_reporting: Fix MAX_ORDER usage in page_reporting_register() mm/slub: Fix MAX_ORDER usage in calculate_order()
iommu: Fix MAX_ORDER usage in __iommu_dma_alloc_pages() mm, treewide: Redefine MAX_ORDER sanely
.../admin-guide/kdump/vmcoreinfo.rst | 2 +- .../admin-guide/kernel-parameters.txt | 2 +- arch/arc/Kconfig | 4 +- arch/arm/Kconfig | 9 ++--- arch/arm/configs/imx_v6_v7_defconfig | 2 +- arch/arm/configs/milbeaut_m10v_defconfig | 2 +- arch/arm/configs/oxnas_v6_defconfig | 2 +- arch/arm/configs/pxa_defconfig | 2 +- arch/arm/configs/sama7_defconfig | 2 +- arch/arm/configs/sp7021_defconfig | 2 +- arch/arm64/Kconfig | 27 ++++++------- arch/arm64/include/asm/sparsemem.h | 2 +- arch/arm64/kvm/hyp/include/nvhe/gfp.h | 2 +- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 10 ++--- arch/csky/Kconfig | 2 +- arch/ia64/Kconfig | 8 ++-- arch/ia64/include/asm/sparsemem.h | 4 +- arch/ia64/mm/hugetlbpage.c | 2 +- arch/loongarch/Kconfig | 15 +++----- arch/m68k/Kconfig.cpu | 5 +-- arch/mips/Kconfig | 19 ++++------ arch/nios2/Kconfig | 7 +--- arch/powerpc/Kconfig | 27 ++++++------- arch/powerpc/configs/85xx/ge_imp3a_defconfig | 2 +- arch/powerpc/configs/fsl-emb-nonhw.config | 2 +- arch/powerpc/mm/book3s64/iommu_api.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 2 +- arch/sh/configs/ecovec24_defconfig | 2 +- arch/sh/mm/Kconfig | 17 ++++----- arch/sparc/Kconfig | 5 +-- arch/sparc/kernel/pci_sun4v.c | 2 +- arch/sparc/kernel/traps_64.c | 2 +- arch/sparc/mm/tsb.c | 4 +- arch/xtensa/Kconfig | 5 +-- drivers/base/regmap/regmap-debugfs.c | 8 ++-- drivers/block/floppy.c | 2 +- drivers/crypto/ccp/sev-dev.c | 2 +- drivers/crypto/hisilicon/sgl.c | 6 +-- .../gpu/drm/i915/gem/selftests/huge_pages.c | 2 +- drivers/gpu/drm/ttm/ttm_pool.c | 22 +++++------ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 +- drivers/iommu/dma-iommu.c | 4 +- drivers/irqchip/irq-gic-v3-its.c | 4 +- drivers/md/dm-bufio.c | 2 +- drivers/misc/genwqe/card_utils.c | 2 +- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- drivers/net/ethernet/ibm/ibmvnic.h | 2 +- drivers/video/fbdev/hyperv_fb.c | 4 +- drivers/video/fbdev/vermilion/vermilion.c | 2 +- drivers/virtio/virtio_balloon.c | 2 +- drivers/virtio/virtio_mem.c | 12 +++--- fs/ramfs/file-nommu.c | 2 +- include/drm/ttm/ttm_pool.h | 2 +- include/linux/hugetlb.h | 2 +- include/linux/mmzone.h | 10 ++--- include/linux/pageblock-flags.h | 4 +- include/linux/slab.h | 6 +-- kernel/crash_core.c | 2 +- kernel/dma/pool.c | 6 +-- mm/Kconfig | 6 +-- mm/compaction.c | 8 ++-- mm/debug_vm_pgtable.c | 4 +- mm/huge_memory.c | 2 +- mm/hugetlb.c | 4 +- mm/kmsan/init.c | 6 +-- mm/memblock.c | 2 +- mm/memory_hotplug.c | 4 +- mm/page_alloc.c | 38 +++++++++---------- mm/page_isolation.c | 12 +++--- mm/page_owner.c | 6 +-- mm/page_reporting.c | 4 +- mm/shuffle.h | 2 +- mm/slab.c | 2 +- mm/slub.c | 4 +- mm/vmscan.c | 2 +- mm/vmstat.c | 14 +++---- net/smc/smc_ib.c | 2 +- security/integrity/ima/ima_crypto.c | 2 +- tools/testing/memblock/linux/mmzone.h | 6 +-- 80 files changed, 210 insertions(+), 240 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/10 sparc/mm: Fix MAX_ORDER usage in tsb_grow()
MAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in tsb_grow().
--- arch/sparc/mm/tsb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sparc/mm/tsb.c +2 -2
@@ -402,8 +402,8 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss)unsigned long new_rss_limit;gfp_t gfp_flags; -if (max_tsb_size > (PAGE_SIZE <<MAX_ORDER )) - max_tsb_size = (PAGE_SIZE <<MAX_ORDER ); +if (max_tsb_size > (PAGE_SIZE << (MAX_ORDER -1 ))) + max_tsb_size = (PAGE_SIZE << (MAX_ORDER -1 )); new_cache_index =0 ;for (new_size =8192 ; new_size < max_tsb_size; new_size <<=1UL ) {
Signature · 1 line
2.39.2
Re: [PATCH 01/10] sparc/mm: Fix MAX_ORDER usage in tsb_grow()
Quoted 18 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage intsb_grow().Signed-off-by Kirill A. Shutemov <[email protected]>Cc David Miller <[email protected]>--- arch/sparc/mm/tsb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sparc/mm/tsb.c +0
-0
arch/sparc/mm/tsb.c void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss) · line 409
Quoted 10 lines
arch/sparc/mm/tsb.c +2
-2@@ -402,8 +402,8 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss)unsigned long new_rss_limit;gfp_t gfp_flags; -if (max_tsb_size > (PAGE_SIZE <<MAX_ORDER )) - max_tsb_size = (PAGE_SIZE <<MAX_ORDER ); +if (max_tsb_size > (PAGE_SIZE << (MAX_ORDER -1 ))) + max_tsb_size = (PAGE_SIZE << (MAX_ORDER -1 )); new_cache_index =0 ;for (new_size =8192 ; new_size < max_tsb_size; new_size <<=1UL ) {
Fortunately, I think this only comes into play if MAX_ORDER <= 7.
Signature · 1 line
Mike Kravetz
Mike Rapoport
maintainerRe: [PATCH 01/10] sparc/mm: Fix MAX_ORDER usage in tsb_grow()
Quoted 26 lines · Mike Kravetz
Quoted 25 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage intsb_grow().Signed-off-by Kirill A. Shutemov <[email protected]>Cc David Miller <[email protected]>--- arch/sparc/mm/tsb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sparc/mm/tsb.c +2
-2@@ -402,8 +402,8 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss)unsigned long new_rss_limit;gfp_t gfp_flags; -if (max_tsb_size > (PAGE_SIZE <<MAX_ORDER )) - max_tsb_size = (PAGE_SIZE <<MAX_ORDER ); +if (max_tsb_size > (PAGE_SIZE << (MAX_ORDER -1 ))) + max_tsb_size = (PAGE_SIZE << (MAX_ORDER -1 ));
Quoted 5 lines
arch/sparc/mm/tsb.c void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss) · line 409
Quoted 3 lines
arch/sparc/mm/tsb.c +0
-0new_cache_index =0 ;for (new_size =8192 ; new_size < max_tsb_size; new_size <<=1UL ) {Fortunately, I think this only comes into play if
MAX_ORDER<= 7.
I think it's unlikely that such low ARCH_FORCE_MAX_ORDER is ever used.
Judging by c88c545bf320 ("sparc64: Add FORCE_MAX_ZONEORDER and default to 13") log the option to override MAX_ORDER was added to "request large (32M) contiguous memory during boot for creating IOTSB backing store", so it was about to increase MAX_ORDER.
Generally, we may restrict sparc::ARCH_FORCE_MAX_ORDER to be above 7 and drop this check entirely
Quoted 4 lines
Reviewed-by Mike Kravetz <[email protected]>Signature · 1 line
Mike Kravetz
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 01/10] sparc/mm: Fix MAX_ORDER usage in tsb_grow()
In reply to Kirill A. ShutemovQuoted 8 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage intsb_grow().Signed-off-by Kirill A. Shutemov <[email protected]>Cc David Miller <[email protected]>
Quoted 22 lines
--- arch/sparc/mm/tsb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sparc/mm/tsb.c +2
-2@@ -402,8 +402,8 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss)unsigned long new_rss_limit;gfp_t gfp_flags; -if (max_tsb_size > (PAGE_SIZE <<MAX_ORDER )) - max_tsb_size = (PAGE_SIZE <<MAX_ORDER ); +if (max_tsb_size > (PAGE_SIZE << (MAX_ORDER -1 ))) + max_tsb_size = (PAGE_SIZE << (MAX_ORDER -1 )); new_cache_index =0 ;for (new_size =8192 ; new_size < max_tsb_size; new_size <<=1UL ) {Signature · 1 line
2.39.2
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 01/10] sparc/mm: Fix MAX_ORDER usage in tsb_grow()
In reply to Kirill A. ShutemovQuoted 6 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage intsb_grow().Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 21 lines
Cc David Miller <[email protected]>--- arch/sparc/mm/tsb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sparc/mm/tsb.c +2
-2@@ -402,8 +402,8 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss)unsigned long new_rss_limit;gfp_t gfp_flags; -if (max_tsb_size > (PAGE_SIZE <<MAX_ORDER )) - max_tsb_size = (PAGE_SIZE <<MAX_ORDER ); +if (max_tsb_size > (PAGE_SIZE << (MAX_ORDER -1 ))) + max_tsb_size = (PAGE_SIZE << (MAX_ORDER -1 )); new_cache_index =0 ;for (new_size =8192 ; new_size < max_tsb_size; new_size <<=1UL ) {
PATCH 2/10 um: Fix MAX_ORDER usage in linux_main()
In reply to Kirill A. ShutemovMAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in linux_main().
--- arch/um/kernel/um_arch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/um/kernel/um_arch.c +2 -2
@@ -368,10 +368,10 @@ int __init linux_main(int argc, char **argv) max_physmem =TASK_SIZE - uml_physmem - iomem_size -MIN_VMALLOC ;/* -* Zones have to begin on a 1 << MAX_ORDER page boundary, +* Zones have to begin on a 1 << MAX_ORDER-1 page boundary, * so this makes sure that's true for highmem */ - max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER )) -1 ); + max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER -1 )) -1 );if (physmem_size + iomem_size > max_physmem) { highmem = physmem_size + iomem_size - max_physmem; physmem_size -= highmem;
Signature · 1 line
2.39.2
Re: [PATCH 02/10] um: Fix MAX_ORDER usage in linux_main()
Quoted 9 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage inlinux_main().Signed-off-by Kirill A. Shutemov <[email protected]>Cc Richard Weinberger <[email protected]>Cc Anton Ivanov <[email protected]>Cc Johannes Berg <[email protected]>
Quoted 24 lines
--- arch/um/kernel/um_arch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/kernel/um_arch.c +2
-2@@ -368,10 +368,10 @@ int __init linux_main(int argc, char **argv) max_physmem =TASK_SIZE - uml_physmem - iomem_size -MIN_VMALLOC ;/* -* Zones have to begin on a 1 << MAX_ORDER page boundary, +* Zones have to begin on a 1 << MAX_ORDER-1 page boundary, * so this makes sure that's true for highmem */ - max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER )) -1 ); + max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER -1 )) -1 );if (physmem_size + iomem_size > max_physmem) { highmem = physmem_size + iomem_size - max_physmem; physmem_size -= highmem;Signature · 1 line
2.39.2
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 02/10] um: Fix MAX_ORDER usage in linux_main()
In reply to Kirill A. ShutemovQuoted 6 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage inlinux_main().Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 24 lines
Cc Richard Weinberger <[email protected]>Cc Anton Ivanov <[email protected]>Cc Johannes Berg <[email protected]>--- arch/um/kernel/um_arch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/kernel/um_arch.c +2
-2@@ -368,10 +368,10 @@ int __init linux_main(int argc, char **argv) max_physmem =TASK_SIZE - uml_physmem - iomem_size -MIN_VMALLOC ;/* -* Zones have to begin on a 1 << MAX_ORDER page boundary, +* Zones have to begin on a 1 << MAX_ORDER-1 page boundary, * so this makes sure that's true for highmem */ - max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER )) -1 ); + max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER -1 )) -1 );if (physmem_size + iomem_size > max_physmem) { highmem = physmem_size + iomem_size - max_physmem; physmem_size -= highmem;
PATCH 3/10 floppy: Fix MAX_ORDER usage
In reply to Kirill A. ShutemovMAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in floppy code.
Also allocation buffer exactly PAGE_SIZE << MAX_ORDER bytes is okay. Fix MAX_LEN check.
--- drivers/block/floppy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/floppy.c +2 -2
@@ -3079,7 +3079,7 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) } } -#define MAX_LEN (1UL << MAX_ORDER << PAGE_SHIFT) +#define MAX_LEN (1UL << (MAX_ORDER - 1) << PAGE_SHIFT)static int raw_cmd_copyin (int cmd,void __user *param,struct floppy_raw_cmd **rcmd)
@@ -3108,7 +3108,7 @@ static int raw_cmd_copyin(int cmd, void __user *param, ptr->resultcode =0 ;if (ptr->flags & (FD_RAW_READ |FD_RAW_WRITE )) { -if (ptr->length <=0 || ptr->length >=MAX_LEN ) +if (ptr->length <=0 || ptr->length >MAX_LEN )return -EINVAL ; ptr->kernel_data = (char *)fd_dma_mem_alloc (ptr->length);fallback_on_nodma_alloc (&ptr->kernel_data, ptr->length);
Signature · 1 line
2.39.2
Re: [PATCH 03/10] floppy: Fix MAX_ORDER usage
Quoted 10 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage in floppy code.Also allocation buffer exactly
PAGE_SIZE<<MAX_ORDERbytes is okay. FixMAX_LENcheck.Signed-off-by Kirill A. Shutemov <[email protected]>Cc Denis Efremov <[email protected]>
Quoted 29 lines
--- drivers/block/floppy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/block/floppy.c +2
-2@@ -3079,7 +3079,7 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) } } -#define MAX_LEN (1UL << MAX_ORDER << PAGE_SHIFT) +#define MAX_LEN (1UL << (MAX_ORDER - 1) << PAGE_SHIFT)static int raw_cmd_copyin (int cmd,void __user *param,struct floppy_raw_cmd **rcmd)@@ -3108,7 +3108,7 @@ static int raw_cmd_copyin(int cmd, void __user *param, ptr->resultcode =0 ;if (ptr->flags & (FD_RAW_READ |FD_RAW_WRITE )) { -if (ptr->length <=0 || ptr->length >=MAX_LEN ) +if (ptr->length <=0 || ptr->length >MAX_LEN )return -EINVAL ; ptr->kernel_data = (char *)fd_dma_mem_alloc (ptr->length);fallback_on_nodma_alloc (&ptr->kernel_data, ptr->length);Signature · 1 line
2.39.2
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 03/10] floppy: Fix MAX_ORDER usage
In reply to Kirill A. ShutemovQuoted 9 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage in floppy code.Also allocation buffer exactly
PAGE_SIZE<<MAX_ORDERbytes is okay. FixMAX_LENcheck.Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 27 lines
Cc Denis Efremov <[email protected]>--- drivers/block/floppy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/block/floppy.c +2
-2@@ -3079,7 +3079,7 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) } } -#define MAX_LEN (1UL << MAX_ORDER << PAGE_SHIFT) +#define MAX_LEN (1UL << (MAX_ORDER - 1) << PAGE_SHIFT)static int raw_cmd_copyin (int cmd,void __user *param,struct floppy_raw_cmd **rcmd)@@ -3108,7 +3108,7 @@ static int raw_cmd_copyin(int cmd, void __user *param, ptr->resultcode =0 ;if (ptr->flags & (FD_RAW_READ |FD_RAW_WRITE )) { -if (ptr->length <=0 || ptr->length >=MAX_LEN ) +if (ptr->length <=0 || ptr->length >MAX_LEN )return -EINVAL ; ptr->kernel_data = (char *)fd_dma_mem_alloc (ptr->length);fallback_on_nodma_alloc (&ptr->kernel_data, ptr->length);
PATCH 4/10 drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
In reply to Kirill A. ShutemovMAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in i915_gem_object_get_pages_internal().
--- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_internal.c +1 -1
@@ -36,7 +36,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)struct sg_table *st;struct scatterlist *sg;unsigned int npages;/* restricted by sg_alloc_table */ -int max_order =MAX_ORDER ; +int max_order =MAX_ORDER -1 ;unsigned int max_segment;gfp_t gfp;
Signature · 1 line
2.39.2
Re: [PATCH 04/10] drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
Quoted 2 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
This looks to be true on inspection:
__alloc_pages():
..
if (WARN_ON_ONCE_GFP(order >= MAX_ORDER, gfp))
So a bit of a misleading name "max".. For the i915 patch:
I don't however see the whole series to understand the context, or how you want to handle the individual patches. Is it a tree wide cleanup of the same mistake?
Regards,
Tvrtko
Quoted 24 lines
Fix
MAX_ORDERusage ini915_gem_object_get_pages_internal().Signed-off-by Kirill A. Shutemov <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/gem/i915_gem_internal.c +1
-1@@ -36,7 +36,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)struct sg_table *st;struct scatterlist *sg;unsigned int npages;/* restricted by sg_alloc_table */ -int max_order =MAX_ORDER ; +int max_order =MAX_ORDER -1 ;unsigned int max_segment;gfp_t gfp;
Re: [PATCH 04/10] drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
Quoted 11 lines · Tvrtko Ursulin
Quoted 2 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.This looks to be true on inspection:
__alloc_pages():
..
if (WARN_ON_ONCE_GFP(order >= MAX_ORDER, gfp))
Quoted 7 lines
So a bit of a misleading name "max".. For the i915 patch:
Acked-by Tvrtko Ursulin <[email protected]>I don't however see the whole series to understand the context, or how you want to handle the individual patches. Is it a tree wide cleanup of the same mistake?
The whole patchset can be seen here:
https://lore.kernel.org/all/[email protected]/
The idea is to fix all MAX_ORDER bugs first and then re-define MAX_ORDER more sensibly.
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Re: [PATCH 04/10] drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
Quoted 20 lines · Kirill A. Shutemov
Quoted 11 lines · Tvrtko Ursulin
Quoted 2 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.This looks to be true on inspection:
__alloc_pages():
..
if (WARN_ON_ONCE_GFP(order >= MAX_ORDER, gfp))Quoted 7 lines
So a bit of a misleading name "max".. For the i915 patch:
Acked-by Tvrtko Ursulin <[email protected]>I don't however see the whole series to understand the context, or how you want to handle the individual patches. Is it a tree wide cleanup of the same mistake?
Quoted 6 lines
The whole patchset can be seen here:
https://lore.kernel.org/all/[email protected]/
The idea is to fix all
MAX_ORDERbugs first and then re-defineMAX_ORDERmore sensibly.
Sounds good.
Would you like i915 to take this patch or you will be bringing the whole lot via some other route? Former is okay and latter should also be fine for i915 since I don't envisage any conflicts here.
Regards,
Tvrtko
Re: [PATCH 04/10] drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
Quoted 26 lines · Tvrtko Ursulin
Quoted 24 lines · Kirill A. Shutemov
Quoted 11 lines · Tvrtko Ursulin
Quoted 2 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.This looks to be true on inspection:
__alloc_pages():
..
if (WARN_ON_ONCE_GFP(order >= MAX_ORDER, gfp))Quoted 7 lines
So a bit of a misleading name "max".. For the i915 patch:
Acked-by Tvrtko Ursulin <[email protected]>I don't however see the whole series to understand the context, or how you want to handle the individual patches. Is it a tree wide cleanup of the same mistake?
The whole patchset can be seen here:
Quoted 8 lines
Quoted 2 lines
The idea is to fix all
MAX_ORDERbugs first and then re-defineMAX_ORDERmore sensibly.Sounds good.
Would you like i915 to take this patch or you will be bringing the whole lot via some other route? Former is okay and latter should also be fine for i915 since I don't envisage any conflicts here.
I think would be better to get it via mm tree.
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Re: [PATCH 04/10] drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
Quoted 30 lines · Kirill A. Shutemov
Quoted 29 lines · Tvrtko Ursulin
Quoted 26 lines · Kirill A. Shutemov
Quoted 11 lines · Tvrtko Ursulin
Quoted 2 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.This looks to be true on inspection:
__alloc_pages():
..
if (WARN_ON_ONCE_GFP(order >= MAX_ORDER, gfp))Quoted 7 lines
So a bit of a misleading name "max".. For the i915 patch:
Acked-by Tvrtko Ursulin <[email protected]>I don't however see the whole series to understand the context, or how you want to handle the individual patches. Is it a tree wide cleanup of the same mistake?
The whole patchset can be seen here:
https://lore.kernel.org/all/[email protected]/
The idea is to fix all
MAX_ORDERbugs first and then re-defineMAX_ORDERmore sensibly.
Quoted 7 lines
Quoted 5 lines
Sounds good.
Would you like i915 to take this patch or you will be bringing the whole lot via some other route? Former is okay and latter should also be fine for i915 since I don't envisage any conflicts here.
I think would be better to get it via mm tree.
Ack for that. But as I saw that by the end of the series you also change this back as you redefine MAX_ORDER to be inclusive you could even simplify things and just not do anything for i915. I am pretty sure we never call this helper for > 4M allocations otherwise we would have seen this warn.
Regards,
Tvrtko
Re: [PATCH 04/10] drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
Quoted 38 lines · Tvrtko Ursulin
Quoted 36 lines · Kirill A. Shutemov
Quoted 34 lines · Tvrtko Ursulin
Quoted 20 lines · Kirill A. Shutemov
Quoted 11 lines · Tvrtko Ursulin
Quoted 2 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.This looks to be true on inspection:
__alloc_pages():
..
if (WARN_ON_ONCE_GFP(order >= MAX_ORDER, gfp))Quoted 7 lines
So a bit of a misleading name "max".. For the i915 patch:
Acked-by Tvrtko Ursulin <[email protected]>I don't however see the whole series to understand the context, or how you want to handle the individual patches. Is it a tree wide cleanup of the same mistake?
Quoted 6 lines
The whole patchset can be seen here:
https://lore.kernel.org/all/[email protected]/
The idea is to fix all
MAX_ORDERbugs first and then re-defineMAX_ORDERmore sensibly.Sounds good.
Would you like i915 to take this patch or you will be bringing the whole lot via some other route? Former is okay and latter should also be fine for i915 since I don't envisage any conflicts here.
Quoted 7 lines
Quoted 1 line
I think would be better to get it via mm tree.
Ack for that. But as I saw that by the end of the series you also change this back as you redefine
MAX_ORDERto be inclusive you could even simplify things and just not do anything for i915. I am pretty sure we never call this helper for > 4M allocations otherwise we would have seen this warn.
I think it's better the Kirill's way as the redefinition patch then isn't also a silent bugfix. In case some of the bugfixes would need to be backported to stable (maybe you don't seen the warn, but something else will change and start seeing it?), it's better if they are separate.
Quoted 4 lines
Regards,
Tvrtko
Re: [PATCH 04/10] drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal()
In reply to Kirill A. ShutemovQuoted 6 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage ini915_gem_object_get_pages_internal().Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 21 lines
Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Tvrtko Ursulin <[email protected]>--- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/gem/i915_gem_internal.c +1
-1@@ -36,7 +36,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)struct sg_table *st;struct scatterlist *sg;unsigned int npages;/* restricted by sg_alloc_table */ -int max_order =MAX_ORDER ; +int max_order =MAX_ORDER -1 ;unsigned int max_segment;gfp_t gfp;
PATCH 5/10 genwqe: Fix MAX_ORDER usage
In reply to Kirill A. ShutemovMAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in genwqe driver.
--- drivers/misc/genwqe/card_dev.c | 2 +- drivers/misc/genwqe/card_utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/misc/genwqe/card_dev.c +1 -1
@@ -443,7 +443,7 @@ static int genwqe_mmap(struct file *filp, struct vm_area_struct *vma)if (vsize ==0 )return -EINVAL ; -if (get_order (vsize) >MAX_ORDER ) +if (get_order (vsize) >=MAX_ORDER )return -ENOMEM ; dma_map =kzalloc (sizeof (struct dma_mapping ),GFP_KERNEL );
drivers/misc/genwqe/card_utils.c +1 -1
@@ -308,7 +308,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, sgl->write = write; sgl->sgl_size =genwqe_sgl_size (sgl->nr_pages); -if (get_order (sgl->sgl_size) >MAX_ORDER ) { +if (get_order (sgl->sgl_size) >=MAX_ORDER ) {dev_err (&pci_dev->dev,"[%s] err: too much memory requested!\n" , __func__);return ret;
Signature · 1 line
2.39.2
Re: [PATCH 05/10] genwqe: Fix MAX_ORDER usage
Quoted 6 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage in genwqe driver.Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 32 lines
Cc Frank Haverkamp <[email protected]>--- drivers/misc/genwqe/card_dev.c | 2 +- drivers/misc/genwqe/card_utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/misc/genwqe/card_dev.c +1
-1@@ -443,7 +443,7 @@ static int genwqe_mmap(struct file *filp, struct vm_area_struct *vma)if (vsize ==0 )return -EINVAL ; -if (get_order (vsize) >MAX_ORDER ) +if (get_order (vsize) >=MAX_ORDER )return -ENOMEM ; dma_map =kzalloc (sizeof (struct dma_mapping ),GFP_KERNEL );drivers/misc/genwqe/card_utils.c +1
-1@@ -308,7 +308,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, sgl->write = write; sgl->sgl_size =genwqe_sgl_size (sgl->nr_pages); -if (get_order (sgl->sgl_size) >MAX_ORDER ) { +if (get_order (sgl->sgl_size) >=MAX_ORDER ) {dev_err (&pci_dev->dev,"[%s] err: too much memory requested!\n" , __func__);return ret;
PATCH 6/10 perf/core: Fix MAX_ORDER usage in rb_alloc_aux_page()
In reply to Kirill A. ShutemovMAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in rb_alloc_aux_page().
--- kernel/events/ring_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/ring_buffer.c +2 -2
@@ -609,8 +609,8 @@ static struct page *rb_alloc_aux_page(int node, int order) {struct page *page; -if (order >MAX_ORDER ) - order =MAX_ORDER ; +if (order >=MAX_ORDER ) + order =MAX_ORDER -1 ; do { page = alloc_pages_node(node, PERF_AUX_GFP, order);
Signature · 1 line
2.39.2
Re: [PATCH 06/10] perf/core: Fix MAX_ORDER usage in rb_alloc_aux_page()
Quoted 6 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage inrb_alloc_aux_page().Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 28 lines
Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Mark Rutland <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Ian Rogers <[email protected]>Cc Adrian Hunter <[email protected]>--- kernel/events/ring_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/events/ring_buffer.c +2
-2@@ -609,8 +609,8 @@ static struct page *rb_alloc_aux_page(int node, int order) {struct page *page; -if (order >MAX_ORDER ) - order =MAX_ORDER ; +if (order >=MAX_ORDER ) + order =MAX_ORDER -1 ; do { page = alloc_pages_node(node, PERF_AUX_GFP, order);
PATCH 7/10 mm/page_reporting: Fix MAX_ORDER usage in page_reporting_register()
In reply to Kirill A. ShutemovMAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in page_reporting_register().
--- mm/page_reporting.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +1 -1
@@ -370,7 +370,7 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)*/ if (page_reporting_order ==-1 ) { -if (prdev->order >0 && prdev->order <=MAX_ORDER ) +if (prdev->order >0 && prdev->order <MAX_ORDER ) page_reporting_order = prdev->order;else page_reporting_order = pageblock_order;
Signature · 1 line
2.39.2
Re: [PATCH 07/10] mm/page_reporting: Fix MAX_ORDER usage in page_reporting_register()
Quoted 6 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage inpage_reporting_register().Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 18 lines
Cc Alexander Duyck <[email protected]>--- mm/page_reporting.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/page_reporting.c +1
-1@@ -370,7 +370,7 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)*/ if (page_reporting_order ==-1 ) { -if (prdev->order >0 && prdev->order <=MAX_ORDER ) +if (prdev->order >0 && prdev->order <MAX_ORDER ) page_reporting_order = prdev->order;else page_reporting_order = pageblock_order;
PATCH 8/10 mm/slub: Fix MAX_ORDER usage in calculate_order()
In reply to Kirill A. ShutemovMAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in calculate_order().
--- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slub.c +1 -1
@@ -4171,7 +4171,7 @@ static inline int calculate_order(unsigned int size)/* * Doh this slab cannot be placed using slub_max_order. */ - order =calc_slab_order (size,1 ,MAX_ORDER ,1 ); + order =calc_slab_order (size,1 ,MAX_ORDER -1 ,1 );if (order <MAX_ORDER )return order;return -ENOSYS ;
Signature · 1 line
2.39.2
Re: [PATCH 08/10] mm/slub: Fix MAX_ORDER usage in calculate_order()
Quoted 9 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage incalculate_order().Signed-off-by Kirill A. Shutemov <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Christoph Lameter <[email protected]>Cc Pekka Enberg <[email protected]>
Quoted 17 lines
--- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/slub.c +1
-1@@ -4171,7 +4171,7 @@ static inline int calculate_order(unsigned int size)/* * Doh this slab cannot be placed using slub_max_order. */ - order =calc_slab_order (size,1 ,MAX_ORDER ,1 ); + order =calc_slab_order (size,1 ,MAX_ORDER -1 ,1 );if (order <MAX_ORDER )return order;return -ENOSYS ;
PATCH 9/10 iommu: Fix MAX_ORDER usage in __iommu_dma_alloc_pages()
In reply to Kirill A. ShutemovMAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.
Fix MAX_ORDER usage in __iommu_dma_alloc_pages().
Also use GENMASK() instead of hard to read "(2U << order) - 1" magic.
--- drivers/iommu/dma-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/dma-iommu.c +2 -2
@@ -736,7 +736,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,struct page **pages;unsigned int i =0 , nid =dev_to_node (dev); - order_mask &= (2U <<MAX_ORDER ) -1 ; + order_mask &=GENMASK (MAX_ORDER -1 ,0 );if (!order_mask)return NULL ;
@@ -756,7 +756,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,* than a necessity, hence using __GFP_NORETRY until * falling back to minimum-order allocations. */ -for (order_mask &= (2U <<__fls (count)) -1 ; +for (order_mask &=GENMASK (__fls (count),0 ); order_mask; order_mask &= ~order_size) {unsigned int order =__fls (order_mask);gfp_t alloc_flags = gfp;
Signature · 1 line
2.39.2
Re: [PATCH 09/10] iommu: Fix MAX_ORDER usage in __iommu_dma_alloc_pages()
Quoted 4 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage in__iommu_dma_alloc_pages().
Technically this isn't a major issue - all it means is that if we did happen to have a suitable page size which lined up with MAX_ORDER, we'd unsuccessfully try the allocation once before falling back to the order of the next-smallest page size anyway. Semantically you're correct though, and I probably did still misunderstand MAX_ORDER 7 years ago :)
Quoted 1 line
Also use
GENMASK()instead of hard to read "(2U << order) - 1" magic.
ISTR that GENMASK() had a habit of generating pretty terrible code for non-constant arguments, but a GCC9 build for arm64 looks fine - in fact if anything it seems to be able to optimise out more of the __fls() this way and save a couple more instructions, which is nice, so:
I'm guessing you probably want to take this through the mm tree - that should be fine since I don't expect any conflicting changes in the IOMMU tree for now (cc'ing Joerg just as a heads-up).
Cheers,
Robin.
Quoted 29 lines
Signed-off-by Kirill A. Shutemov <[email protected]>Cc Robin Murphy <[email protected]>Cc Jacob Pan <[email protected]>--- drivers/iommu/dma-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iommu/dma-iommu.c +2
-2@@ -736,7 +736,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,struct page **pages;unsigned int i =0 , nid =dev_to_node (dev); - order_mask &= (2U <<MAX_ORDER ) -1 ; + order_mask &=GENMASK (MAX_ORDER -1 ,0 );if (!order_mask)return NULL ;@@ -756,7 +756,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,* than a necessity, hence using __GFP_NORETRY until * falling back to minimum-order allocations. */ -for (order_mask &= (2U <<__fls (count)) -1 ; +for (order_mask &=GENMASK (__fls (count),0 ); order_mask; order_mask &= ~order_size) {unsigned int order =__fls (order_mask);gfp_t alloc_flags = gfp;
Re: [PATCH 09/10] iommu: Fix MAX_ORDER usage in __iommu_dma_alloc_pages()
Quoted 3 lines · Robin Murphy
I'm guessing you probably want to take this through the mm tree - that should be fine since I don't expect any conflicting changes in the IOMMU tree for now (cc'ing Joerg just as a heads-up).
Yes, mm tree is fine for this:
Re: [PATCH 09/10] iommu: Fix MAX_ORDER usage in __iommu_dma_alloc_pages()
In reply to Kirill A. ShutemovHi Kirill,
Quoted 36 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage in__iommu_dma_alloc_pages().Also use
GENMASK()instead of hard to read "(2U << order) - 1" magic.Signed-off-by Kirill A. Shutemov <[email protected]>Cc Robin Murphy <[email protected]>Cc Jacob Pan <[email protected]>--- drivers/iommu/dma-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iommu/dma-iommu.c +2
-2@@ -736,7 +736,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev, struct page **pages;unsigned int i =0 , nid =dev_to_node (dev); - order_mask &= (2U <<MAX_ORDER ) -1 ; + order_mask &=GENMASK (MAX_ORDER -1 ,0 );if (!order_mask)return NULL ;@@ -756,7 +756,7 @@ static struct page **__iommu_dma_alloc_pages(structdevice *dev, * than a necessity, hence using __GFP_NORETRY until * falling back to minimum-order allocations. */ -for (order_mask &= (2U <<__fls (count)) -1 ; +for (order_mask &=GENMASK (__fls (count),0 ); order_mask; order_mask &= ~order_size) {unsigned int order =__fls (order_mask);
Quoted 1 line
gfp_talloc_flags= gfp;
(For VT-d part, there is no functional impact at all. We only have 2M and 1G page sizes, no SZ_8M page)
Thanks,
Jacob
Re: [PATCH 09/10] iommu: Fix MAX_ORDER usage in __iommu_dma_alloc_pages()
In reply to Kirill A. ShutemovQuoted 8 lines · Kirill A. Shutemov
MAX_ORDERis not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1.Fix
MAX_ORDERusage in__iommu_dma_alloc_pages().Also use
GENMASK()instead of hard to read "(2U << order) - 1" magic.Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 28 lines
Cc Robin Murphy <[email protected]>Cc Jacob Pan <[email protected]>--- drivers/iommu/dma-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iommu/dma-iommu.c +2
-2@@ -736,7 +736,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,struct page **pages;unsigned int i =0 , nid =dev_to_node (dev); - order_mask &= (2U <<MAX_ORDER ) -1 ; + order_mask &=GENMASK (MAX_ORDER -1 ,0 );if (!order_mask)return NULL ;@@ -756,7 +756,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,* than a necessity, hence using __GFP_NORETRY until * falling back to minimum-order allocations. */ -for (order_mask &= (2U <<__fls (count)) -1 ; +for (order_mask &=GENMASK (__fls (count),0 ); order_mask; order_mask &= ~order_size) {unsigned int order =__fls (order_mask);gfp_t alloc_flags = gfp;
PATCH 10/10 mm, treewide: Redefine MAX_ORDER sanely
In reply to Kirill A. ShutemovMAX_ORDER currently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.
This definition is counter-intuitive and lead to number of bugs all over the kernel.
Change the definition of MAX_ORDER to be inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.
--- .../admin-guide/kdump/vmcoreinfo.rst | 2 +- .../admin-guide/kernel-parameters.txt | 2 +- arch/arc/Kconfig | 4 +- arch/arm/Kconfig | 9 ++--- arch/arm/configs/imx_v6_v7_defconfig | 2 +- arch/arm/configs/milbeaut_m10v_defconfig | 2 +- arch/arm/configs/oxnas_v6_defconfig | 2 +- arch/arm/configs/pxa_defconfig | 2 +- arch/arm/configs/sama7_defconfig | 2 +- arch/arm/configs/sp7021_defconfig | 2 +- arch/arm64/Kconfig | 27 ++++++------- arch/arm64/include/asm/sparsemem.h | 2 +- arch/arm64/kvm/hyp/include/nvhe/gfp.h | 2 +- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 10 ++--- arch/csky/Kconfig | 2 +- arch/ia64/Kconfig | 8 ++-- arch/ia64/include/asm/sparsemem.h | 4 +- arch/ia64/mm/hugetlbpage.c | 2 +- arch/loongarch/Kconfig | 15 +++----- arch/m68k/Kconfig.cpu | 5 +-- arch/mips/Kconfig | 19 ++++------ arch/nios2/Kconfig | 7 +--- arch/powerpc/Kconfig | 27 ++++++------- arch/powerpc/configs/85xx/ge_imp3a_defconfig | 2 +- arch/powerpc/configs/fsl-emb-nonhw.config | 2 +- arch/powerpc/mm/book3s64/iommu_api.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 2 +- arch/sh/configs/ecovec24_defconfig | 2 +- arch/sh/mm/Kconfig | 17 ++++----- arch/sparc/Kconfig | 5 +-- arch/sparc/kernel/pci_sun4v.c | 2 +- arch/sparc/kernel/traps_64.c | 2 +- arch/sparc/mm/tsb.c | 4 +- arch/um/kernel/um_arch.c | 4 +- arch/xtensa/Kconfig | 5 +-- drivers/base/regmap/regmap-debugfs.c | 8 ++-- drivers/block/floppy.c | 2 +- drivers/crypto/ccp/sev-dev.c | 2 +- drivers/crypto/hisilicon/sgl.c | 6 +-- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- .../gpu/drm/i915/gem/selftests/huge_pages.c | 2 +- drivers/gpu/drm/ttm/ttm_pool.c | 22 +++++------ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 +- drivers/iommu/dma-iommu.c | 2 +- drivers/irqchip/irq-gic-v3-its.c | 4 +- drivers/md/dm-bufio.c | 2 +- drivers/misc/genwqe/card_dev.c | 2 +- drivers/misc/genwqe/card_utils.c | 4 +- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- drivers/net/ethernet/ibm/ibmvnic.h | 2 +- drivers/video/fbdev/hyperv_fb.c | 4 +- drivers/video/fbdev/vermilion/vermilion.c | 2 +- drivers/virtio/virtio_balloon.c | 2 +- drivers/virtio/virtio_mem.c | 12 +++--- fs/ramfs/file-nommu.c | 2 +- include/drm/ttm/ttm_pool.h | 2 +- include/linux/hugetlb.h | 2 +- include/linux/mmzone.h | 10 ++--- include/linux/pageblock-flags.h | 4 +- include/linux/slab.h | 6 +-- kernel/crash_core.c | 2 +- kernel/dma/pool.c | 6 +-- kernel/events/ring_buffer.c | 4 +- mm/Kconfig | 6 +-- mm/compaction.c | 8 ++-- mm/debug_vm_pgtable.c | 4 +- mm/huge_memory.c | 2 +- mm/hugetlb.c | 4 +- mm/kmsan/init.c | 6 +-- mm/memblock.c | 2 +- mm/memory_hotplug.c | 4 +- mm/page_alloc.c | 38 +++++++++---------- mm/page_isolation.c | 12 +++--- mm/page_owner.c | 6 +-- mm/page_reporting.c | 6 +-- mm/shuffle.h | 2 +- mm/slab.c | 2 +- mm/slub.c | 6 +-- mm/vmscan.c | 2 +- mm/vmstat.c | 14 +++---- net/smc/smc_ib.c | 2 +- security/integrity/ima/ima_crypto.c | 2 +- tools/testing/memblock/linux/mmzone.h | 6 +-- 84 files changed, 218 insertions(+), 248 deletions(-)
Documentation/admin-guide/kdump/vmcoreinfo.rst +1 -1
@@ -172,7 +172,7 @@ variables. Offset of the free_list's member. This value is used to compute the number of free pages. -Each zone has a free_area structure array called free_area[MAX_ORDER]. +Each zone has a free_area structure array called free_area[MAX_ORDER + 1]. The free_list represents a linked list of free page blocks. (list_head, next|prev)
Documentation/admin-guide/kernel-parameters.txt +1 -1
@@ -3969,7 +3969,7 @@ [KNL] Minimal page reporting order Format: <integer> Adjust the minimal page reporting order. The page - reporting is disabled when it exceeds (MAX_ORDER-1). + reporting is disabled when it exceeds MAX_ORDER. panic= [KNL] Kernel behaviour on panic: delay <timeout> timeout > 0: seconds before rebooting
arch/arc/Kconfig +2 -2
@@ -556,7 +556,7 @@ endmenu # "ARC Architecture Configuration" config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "12" if ARC_HUGEPAGE_16M - default "11" + default "11" if ARC_HUGEPAGE_16M + default "10" source "kernel/power/Kconfig"
arch/arm/Kconfig +3 -6
@@ -1355,9 +1355,9 @@ config ARM_MODULE_PLTS config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "12" if SOC_AM33XX - default "9" if SA1111 - default "11" + default "11" if SOC_AM33XX + default "8" if SA1111 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -1366,9 +1366,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - config ALIGNMENT_TRAP def_bool CPU_CP15_MMU select HAVE_PROC_CPU if PROC_FS
arch/arm/configs/imx_v6_v7_defconfig +1 -1
@@ -31,7 +31,7 @@ CONFIG_SOC_VF610=y CONFIG_SMP=y CONFIG_ARM_PSCI=y CONFIG_HIGHMEM=y -CONFIG_ARCH_FORCE_MAX_ORDER=14 +CONFIG_ARCH_FORCE_MAX_ORDER=13 CONFIG_CMDLINE="noinitrd console=ttymxc0,115200" CONFIG_KEXEC=y CONFIG_CPU_FREQ=y
arch/arm/configs/milbeaut_m10v_defconfig +1 -1
@@ -26,7 +26,7 @@ CONFIG_THUMB2_KERNEL=y # CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11 is not set # CONFIG_ARM_PATCH_IDIV is not set CONFIG_HIGHMEM=y -CONFIG_ARCH_FORCE_MAX_ORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=11 CONFIG_SECCOMP=y CONFIG_KEXEC=y CONFIG_EFI=y
arch/arm/configs/oxnas_v6_defconfig +1 -1
@@ -12,7 +12,7 @@ CONFIG_ARCH_OXNAS=y CONFIG_MACH_OX820=y CONFIG_SMP=y CONFIG_NR_CPUS=16 -CONFIG_ARCH_FORCE_MAX_ORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=11 CONFIG_SECCOMP=y CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_ATAG_DTB_COMPAT=y
arch/arm/configs/pxa_defconfig +1 -1
@@ -20,7 +20,7 @@ CONFIG_PXA_SHARPSL=y CONFIG_MACH_AKITA=y CONFIG_MACH_BORZOI=y CONFIG_AEABI=y -CONFIG_ARCH_FORCE_MAX_ORDER=9 +CONFIG_ARCH_FORCE_MAX_ORDER=8 CONFIG_CMDLINE="root=/dev/ram0 ro" CONFIG_KEXEC=y CONFIG_CPU_FREQ=y
arch/arm/configs/sama7_defconfig +1 -1
@@ -19,7 +19,7 @@ CONFIG_ATMEL_CLOCKSOURCE_TCB=y # CONFIG_CACHE_L2X0 is not set # CONFIG_ARM_PATCH_IDIV is not set # CONFIG_CPU_SW_DOMAIN_PAN is not set -CONFIG_ARCH_FORCE_MAX_ORDER=15 +CONFIG_ARCH_FORCE_MAX_ORDER=14 CONFIG_UACCESS_WITH_MEMCPY=y # CONFIG_ATAGS is not set CONFIG_CMDLINE="console=ttyS0,115200 earlyprintk ignore_loglevel"
arch/arm/configs/sp7021_defconfig +1 -1
@@ -17,7 +17,7 @@ CONFIG_ARCH_SUNPLUS=y # CONFIG_VDSO is not set CONFIG_SMP=y CONFIG_THUMB2_KERNEL=y -CONFIG_ARCH_FORCE_MAX_ORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=11 CONFIG_VFP=y CONFIG_NEON=y CONFIG_MODULES=y
arch/arm64/Kconfig +12 -15
@@ -1476,22 +1476,22 @@ config XEN # include/linux/mmzone.h requires the following to be true: # -# MAX_ORDER - 1 + PAGE_SHIFT <= SECTION_SIZE_BITS +# MAX_ORDER + PAGE_SHIFT <= SECTION_SIZE_BITS # -# so the maximum value of MAX_ORDER is SECTION_SIZE_BITS + 1 - PAGE_SHIFT: +# so the maximum value of MAX_ORDER is SECTION_SIZE_BITS - PAGE_SHIFT: # # | SECTION_SIZE_BITS | PAGE_SHIFT | max MAX_ORDER | default MAX_ORDER | # ----+-------------------+--------------+-----------------+--------------------+ -# 4K | 27 | 12 | 16 | 11 | -# 16K | 27 | 14 | 14 | 12 | -# 64K | 29 | 16 | 14 | 14 | +# 4K | 27 | 12 | 15 | 10 | +# 16K | 27 | 14 | 13 | 11 | +# 64K | 29 | 16 | 13 | 13 | config ARCH_FORCE_MAX_ORDER int "Maximum zone order" if ARM64_4K_PAGES || ARM64_16K_PAGES - default "14" if ARM64_64K_PAGES - range 12 14 if ARM64_16K_PAGES - default "12" if ARM64_16K_PAGES - range 11 16 if ARM64_4K_PAGES - default "11" + default "13" if ARM64_64K_PAGES + range 11 13 if ARM64_16K_PAGES + default "11" if ARM64_16K_PAGES + range 10 15 if ARM64_4K_PAGES + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -1500,14 +1500,11 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - We make sure that we can allocate up to a HugePage size for each configuration. Hence we have : - MAX_ORDER = (PMD_SHIFT - PAGE_SHIFT) + 1 => PAGE_SHIFT - 2 + MAX_ORDER = PMD_SHIFT - PAGE_SHIFT => PAGE_SHIFT - 3 - However for 4K, we choose a higher default value, 11 as opposed to 10, giving us + However for 4K, we choose a higher default value, 10 as opposed to 9, giving us 4M allocations matching the default size used by generic code. config UNMAP_KERNEL_AT_EL0
arch/arm64/include/asm/sparsemem.h +1 -1
@@ -10,7 +10,7 @@/* * Section size must be at least 512MB for 64K base * page size config. Otherwise it will be less than -* (MAX_ORDER - 1) and the build process will fail. +* MAX_ORDER and the build process will fail. */ #ifdef CONFIG_ARM64_64K_PAGES #define SECTION_SIZE_BITS 29
arch/arm64/kvm/hyp/include/nvhe/gfp.h +1 -1
@@ -16,7 +16,7 @@ struct hyp_pool {* API at EL2. */ hyp_spinlock_t lock; -struct list_head free_area[MAX_ORDER ]; +struct list_head free_area[MAX_ORDER +1 ];phys_addr_t range_start;phys_addr_t range_end;unsigned short max_order;
arch/arm64/kvm/hyp/nvhe/page_alloc.c +5 -5
@@ -110,7 +110,7 @@ static void __hyp_attach_page(struct hyp_pool *pool,* after coalescing, so make sure to mark it HYP_NO_ORDER proactively. */ p->order =HYP_NO_ORDER ; -for (; (order +1 ) < pool->max_order; order++) { +for (; (order +1 ) <= pool->max_order; order++) { buddy =__find_buddy_avail (pool, p, order);if (!buddy)break ;
@@ -203,9 +203,9 @@ void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order)hyp_spin_lock (&pool->lock);/* Look for a high-enough-order page */ -while (i < pool->max_order &&list_empty (&pool->free_area[i])) +while (i <= pool->max_order &&list_empty (&pool->free_area[i])) i++; -if (i >= pool->max_order) { +if (i > pool->max_order) {hyp_spin_unlock (&pool->lock);return NULL ; }
@@ -228,8 +228,8 @@ int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages,int i;hyp_spin_lock_init (&pool->lock); - pool->max_order =min (MAX_ORDER ,get_order ((nr_pages +1 ) <<PAGE_SHIFT )); -for (i =0 ; i < pool->max_order; i++) + pool->max_order =min (MAX_ORDER ,get_order (nr_pages <<PAGE_SHIFT )); +for (i =0 ; i <= pool->max_order; i++)INIT_LIST_HEAD (&pool->free_area[i]); pool->range_start = phys; pool->range_end = phys + (nr_pages <<PAGE_SHIFT );
arch/csky/Kconfig +1 -1
@@ -334,7 +334,7 @@ config HIGHMEM config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "11" + default "10" config DRAM_BASE hex "DRAM start addr (the same with memory-section in dts)"
arch/ia64/Kconfig +4 -4
@@ -202,10 +202,10 @@ config IA64_CYCLONE If you're unsure, answer N. config ARCH_FORCE_MAX_ORDER - int "MAX_ORDER (11 - 17)" if !HUGETLB_PAGE - range 11 17 if !HUGETLB_PAGE - default "17" if HUGETLB_PAGE - default "11" + int "MAX_ORDER (10 - 16)" if !HUGETLB_PAGE + range 10 16 if !HUGETLB_PAGE + default "16" if HUGETLB_PAGE + default "10" config SMP bool "Symmetric multi-processing support"
arch/ia64/include/asm/sparsemem.h +2 -2
@@ -12,9 +12,9 @@#define SECTION_SIZE_BITS (30)#define MAX_PHYSMEM_BITS (50)#ifdef CONFIG_ARCH_FORCE_MAX_ORDER -#if ((CONFIG_ARCH_FORCE_MAX_ORDER -1 +PAGE_SHIFT ) >SECTION_SIZE_BITS ) +#if (CONFIG_ARCH_FORCE_MAX_ORDER +PAGE_SHIFT >SECTION_SIZE_BITS )#undef SECTION_SIZE_BITS -#define SECTION_SIZE_BITS (CONFIG_ARCH_FORCE_MAX_ORDER - 1 + PAGE_SHIFT) +#define SECTION_SIZE_BITS (CONFIG_ARCH_FORCE_MAX_ORDER + PAGE_SHIFT)#endif #endif
arch/ia64/mm/hugetlbpage.c +1 -1
@@ -170,7 +170,7 @@ static int __init hugetlb_setup_sz(char *str) size =memparse (str, &str);if (*str || !is_power_of_2 (size) || !(tr_pages & size) || size <=PAGE_SIZE || - size >= (1UL <<PAGE_SHIFT <<MAX_ORDER )) { + size > (1UL <<PAGE_SHIFT <<MAX_ORDER )) {printk (KERN_WARNING "Invalid huge page size specified\n" );return 1 ; }
arch/loongarch/Kconfig +6 -9
@@ -420,12 +420,12 @@ config NODES_SHIFT config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 14 64 if PAGE_SIZE_64KB - default "14" if PAGE_SIZE_64KB - range 12 64 if PAGE_SIZE_16KB - default "12" if PAGE_SIZE_16KB - range 11 64 - default "11" + range 13 63 if PAGE_SIZE_64KB + default "13" if PAGE_SIZE_64KB + range 11 63 if PAGE_SIZE_16KB + default "11" if PAGE_SIZE_16KB + range 10 63 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -434,9 +434,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - The page size is not necessarily 4KB. Keep this in mind when choosing a value for this option.
arch/m68k/Kconfig.cpu +1 -4
@@ -400,7 +400,7 @@ config SINGLE_MEMORY_CHUNK config ARCH_FORCE_MAX_ORDER int "Maximum zone order" if ADVANCED depends on !SINGLE_MEMORY_CHUNK - default "11" + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -413,9 +413,6 @@ config ARCH_FORCE_MAX_ORDER value also defines the minimal size of the hole that allows freeing unused memory map. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - config 060_WRITETHROUGH bool "Use write-through caching for 68060 supervisor accesses" depends on ADVANCED && M68060
arch/mips/Kconfig +8 -11
@@ -2137,14 +2137,14 @@ endchoice config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 14 64 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB - default "14" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB - range 13 64 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB - default "13" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB - range 12 64 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB - default "12" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB - range 0 64 - default "11" + range 13 63 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB + default "13" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB + range 12 63 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB + default "12" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB + range 11 63 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB + default "11" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB + range 0 63 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -2153,9 +2153,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - The page size is not necessarily 4KB. Keep this in mind when choosing a value for this option.
arch/nios2/Kconfig +2 -5
@@ -46,8 +46,8 @@ source "kernel/Kconfig.hz" config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 9 20 - default "11" + range 8 19 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -56,9 +56,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - endmenu source "arch/nios2/platform/Kconfig.platform"
arch/powerpc/Kconfig +12 -15
@@ -896,18 +896,18 @@ config DATA_SHIFT config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 8 9 if PPC64 && PPC_64K_PAGES - default "9" if PPC64 && PPC_64K_PAGES - range 13 13 if PPC64 && !PPC_64K_PAGES - default "13" if PPC64 && !PPC_64K_PAGES - range 9 64 if PPC32 && PPC_16K_PAGES - default "9" if PPC32 && PPC_16K_PAGES - range 7 64 if PPC32 && PPC_64K_PAGES - default "7" if PPC32 && PPC_64K_PAGES - range 5 64 if PPC32 && PPC_256K_PAGES - default "5" if PPC32 && PPC_256K_PAGES - range 11 64 - default "11" + range 7 8 if PPC64 && PPC_64K_PAGES + default "8" if PPC64 && PPC_64K_PAGES + range 12 12 if PPC64 && !PPC_64K_PAGES + default "12" if PPC64 && !PPC_64K_PAGES + range 8 63 if PPC32 && PPC_16K_PAGES + default "8" if PPC32 && PPC_16K_PAGES + range 6 63 if PPC32 && PPC_64K_PAGES + default "6" if PPC32 && PPC_64K_PAGES + range 4 63 if PPC32 && PPC_256K_PAGES + default "4" if PPC32 && PPC_256K_PAGES + range 10 63 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -916,9 +916,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - The page size is not necessarily 4KB. For example, on 64-bit systems, 64KB pages can be enabled via CONFIG_PPC_64K_PAGES. Keep this in mind when choosing a value for this option.
arch/powerpc/configs/85xx/ge_imp3a_defconfig +1 -1
@@ -30,7 +30,7 @@ CONFIG_PREEMPT=y # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set CONFIG_BINFMT_MISC=m CONFIG_MATH_EMULATION=y -CONFIG_ARCH_FORCE_MAX_ORDER=17 +CONFIG_ARCH_FORCE_MAX_ORDER=16 CONFIG_PCI=y CONFIG_PCIEPORTBUS=y CONFIG_PCI_MSI=y
arch/powerpc/configs/fsl-emb-nonhw.config +1 -1
@@ -41,7 +41,7 @@ CONFIG_FIXED_PHY=y CONFIG_FONT_8x16=y CONFIG_FONT_8x8=y CONFIG_FONTS=y -CONFIG_ARCH_FORCE_MAX_ORDER=13 +CONFIG_ARCH_FORCE_MAX_ORDER=12 CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FRAME_WARN=1024 CONFIG_FTL=y
arch/powerpc/mm/book3s64/iommu_api.c +1 -1
@@ -97,7 +97,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua, }mmap_read_lock (mm); - chunk = (1UL << (PAGE_SHIFT +MAX_ORDER -1 )) / + chunk = (1UL << (PAGE_SHIFT +MAX_ORDER )) /sizeof (struct vm_area_struct *); chunk =min (chunk, entries);for (entry =0 ; entry < entries; entry += chunk) {
arch/powerpc/mm/hugetlbpage.c +1 -1
@@ -615,7 +615,7 @@ void __init gigantic_hugetlb_cma_reserve(void) order =mmu_psize_to_shift (MMU_PAGE_16G ) -PAGE_SHIFT ;if (order) { -VM_WARN_ON (order <MAX_ORDER ); +VM_WARN_ON (order <=MAX_ORDER );hugetlb_cma_reserve (order); } }
arch/powerpc/platforms/powernv/pci-ioda.c +1 -1
@@ -1740,7 +1740,7 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe)* DMA window can be larger than available memory, which will * cause errors later. */ -const u64 maxblock =1UL << (PAGE_SHIFT +MAX_ORDER -1 ); +const u64 maxblock =1UL << (PAGE_SHIFT +MAX_ORDER );/* * We create the default window as big as we can. The constraint is
arch/sh/configs/ecovec24_defconfig +1 -1
@@ -8,7 +8,7 @@ CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y # CONFIG_BLK_DEV_BSG is not set CONFIG_CPU_SUBTYPE_SH7724=y -CONFIG_ARCH_FORCE_MAX_ORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=11 CONFIG_MEMORY_SIZE=0x10000000 CONFIG_FLATMEM_MANUAL=y CONFIG_SH_ECOVEC=y
arch/sh/mm/Kconfig +7 -10
@@ -20,13 +20,13 @@ config PAGE_OFFSET config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 9 64 if PAGE_SIZE_16KB - default "9" if PAGE_SIZE_16KB - range 7 64 if PAGE_SIZE_64KB - default "7" if PAGE_SIZE_64KB - range 11 64 - default "14" if !MMU - default "11" + range 8 63 if PAGE_SIZE_16KB + default "8" if PAGE_SIZE_16KB + range 6 63 if PAGE_SIZE_64KB + default "6" if PAGE_SIZE_64KB + range 10 63 + default "13" if !MMU + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -35,9 +35,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - The page size is not necessarily 4KB. Keep this in mind when choosing a value for this option.
arch/sparc/Kconfig +1 -4
@@ -271,7 +271,7 @@ config ARCH_SPARSEMEM_DEFAULT config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "13" + default "12" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -280,9 +280,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 13 means that the largest free memory block is 2^12 pages. - if SPARC64 || COMPILE_TEST source "kernel/power/Kconfig" endif
arch/sparc/kernel/pci_sun4v.c +1 -1
@@ -193,7 +193,7 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size, size =IO_PAGE_ALIGN (size); order =get_order (size); -if (unlikely (order >=MAX_ORDER )) +if (unlikely (order >MAX_ORDER ))return NULL ; npages = size >>IO_PAGE_SHIFT ;
arch/sparc/kernel/traps_64.c +1 -1
@@ -897,7 +897,7 @@ void __init cheetah_ecache_flush_init(void)/* Now allocate error trap reporting scoreboard. */ sz =NR_CPUS * (2 *sizeof (struct cheetah_err_info )); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {if ((PAGE_SIZE << order) >= sz)break ; }
arch/sparc/mm/tsb.c +2 -2
@@ -402,8 +402,8 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss)unsigned long new_rss_limit;gfp_t gfp_flags; -if (max_tsb_size > (PAGE_SIZE << (MAX_ORDER -1 ))) - max_tsb_size = (PAGE_SIZE << (MAX_ORDER -1 )); +if (max_tsb_size >PAGE_SIZE <<MAX_ORDER ) + max_tsb_size =PAGE_SIZE <<MAX_ORDER ; new_cache_index =0 ;for (new_size =8192 ; new_size < max_tsb_size; new_size <<=1UL ) {
arch/um/kernel/um_arch.c +2 -2
@@ -368,10 +368,10 @@ int __init linux_main(int argc, char **argv) max_physmem =TASK_SIZE - uml_physmem - iomem_size -MIN_VMALLOC ;/* -* Zones have to begin on a 1 << MAX_ORDER-1 page boundary, +* Zones have to begin on a 1 << MAX_ORDER page boundary, * so this makes sure that's true for highmem */ - max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER -1 )) -1 ); + max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER )) -1 );if (physmem_size + iomem_size > max_physmem) { highmem = physmem_size + iomem_size - max_physmem; physmem_size -= highmem;
arch/xtensa/Kconfig +1 -4
@@ -773,7 +773,7 @@ config HIGHMEM config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "11" + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of
@@ -782,9 +782,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - endmenu menu "Power management options"
drivers/base/regmap/regmap-debugfs.c +4 -4
@@ -226,8 +226,8 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,if (*ppos <0 || !count)return -EINVAL ; -if (count > (PAGE_SIZE << (MAX_ORDER -1 ))) - count =PAGE_SIZE << (MAX_ORDER -1 ); +if (count > (PAGE_SIZE <<MAX_ORDER )) + count =PAGE_SIZE <<MAX_ORDER ; buf =kmalloc (count,GFP_KERNEL );if (!buf)
@@ -373,8 +373,8 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,if (*ppos <0 || !count)return -EINVAL ; -if (count > (PAGE_SIZE << (MAX_ORDER -1 ))) - count =PAGE_SIZE << (MAX_ORDER -1 ); +if (count > (PAGE_SIZE <<MAX_ORDER )) + count =PAGE_SIZE <<MAX_ORDER ; buf =kmalloc (count,GFP_KERNEL );if (!buf)
drivers/block/floppy.c +1 -1
@@ -3079,7 +3079,7 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) } } -#define MAX_LEN (1UL << (MAX_ORDER - 1) << PAGE_SHIFT) +#define MAX_LEN (1UL << MAX_ORDER << PAGE_SHIFT)static int raw_cmd_copyin (int cmd,void __user *param,struct floppy_raw_cmd **rcmd)
drivers/crypto/ccp/sev-dev.c +1 -1
@@ -886,7 +886,7 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)/* * The length of the ID shouldn't be assumed by software since * it may change in the future. The allocation size is limited -* to 1 << (PAGE_SHIFT + MAX_ORDER - 1) by the page allocator. +* to 1 << (PAGE_SHIFT + MAX_ORDER) by the page allocator. * If the allocation fails, simply return ENOMEM rather than * warning in the kernel log. */
drivers/crypto/hisilicon/sgl.c +3 -3
@@ -70,11 +70,11 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev, HISI_ACC_SGL_ALIGN_SIZE);/* -* the pool may allocate a block of memory of size PAGE_SIZE * 2^(MAX_ORDER - 1), +* the pool may allocate a block of memory of size PAGE_SIZE * 2^MAX_ORDER, * block size may exceed 2^31 on ia64, so the max of block size is 2^31 */ - block_size =1 << (PAGE_SHIFT +MAX_ORDER <=32 ? -PAGE_SHIFT +MAX_ORDER -1 :31 ); + block_size =1 << (PAGE_SHIFT +MAX_ORDER <32 ? +PAGE_SHIFT +MAX_ORDER :31 ); sgl_num_per_block = block_size / sgl_size; block_num = count / sgl_num_per_block; remain_sgl = count % sgl_num_per_block;
drivers/gpu/drm/i915/gem/i915_gem_internal.c +1 -1
@@ -36,7 +36,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)struct sg_table *st;struct scatterlist *sg;unsigned int npages;/* restricted by sg_alloc_table */ -int max_order =MAX_ORDER -1 ; +int max_order =MAX_ORDER ;unsigned int max_segment;gfp_t gfp;
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
@@ -115,7 +115,7 @@ static int get_huge_pages(struct drm_i915_gem_object *obj) do { struct page *page; - GEM_BUG_ON(order >= MAX_ORDER); + GEM_BUG_ON(order > MAX_ORDER); page = alloc_pages(GFP | __GFP_ZERO, order); if (!page) goto err;
drivers/gpu/drm/ttm/ttm_pool.c +11 -11
@@ -65,11 +65,11 @@ module_param(page_pool_size, ulong, 0644);static atomic_long_t allocated_pages; -static struct ttm_pool_type global_write_combined[MAX_ORDER ]; -static struct ttm_pool_type global_uncached[MAX_ORDER ]; +static struct ttm_pool_type global_write_combined[MAX_ORDER +1 ]; +static struct ttm_pool_type global_uncached[MAX_ORDER +1 ]; -static struct ttm_pool_type global_dma32_write_combined[MAX_ORDER ]; -static struct ttm_pool_type global_dma32_uncached[MAX_ORDER ]; +static struct ttm_pool_type global_dma32_write_combined[MAX_ORDER +1 ]; +static struct ttm_pool_type global_dma32_uncached[MAX_ORDER +1 ];static spinlock_t shrinker_lock;static struct list_head shrinker_list;
@@ -405,7 +405,7 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,else gfp_flags |=GFP_HIGHUSER ; - for (order = min_t(unsigned int, MAX_ORDER - 1, __fls(num_pages)); + for (order = min_t(unsigned int, MAX_ORDER, __fls(num_pages)); num_pages; order = min_t(unsigned int, order, __fls(num_pages))) {struct ttm_pool_type *pt;
@@ -542,7 +542,7 @@ void ttm_pool_init(struct ttm_pool *pool, struct device *dev,if (use_dma_alloc) {for (i =0 ; i <TTM_NUM_CACHING_TYPES ; ++i) -for (j =0 ; j <MAX_ORDER ; ++j) +for (j =0 ; j <=MAX_ORDER ; ++j)ttm_pool_type_init (&pool->caching[i].orders[j], pool, i, j); }
@@ -562,7 +562,7 @@ void ttm_pool_fini(struct ttm_pool *pool)if (pool->use_dma_alloc) {for (i =0 ; i <TTM_NUM_CACHING_TYPES ; ++i) -for (j =0 ; j <MAX_ORDER ; ++j) +for (j =0 ; j <=MAX_ORDER ; ++j)ttm_pool_type_fini (&pool->caching[i].orders[j]); }
@@ -616,7 +616,7 @@ static void ttm_pool_debugfs_header(struct seq_file *m)unsigned int i;seq_puts (m,"\t " ); -for (i =0 ; i <MAX_ORDER ; ++i) +for (i =0 ; i <=MAX_ORDER ; ++i)seq_printf (m," ---%2u---" , i);seq_puts (m,"\n" ); }
@@ -627,7 +627,7 @@ static void ttm_pool_debugfs_orders(struct ttm_pool_type *pt, {unsigned int i; -for (i =0 ; i <MAX_ORDER ; ++i) +for (i =0 ; i <=MAX_ORDER ; ++i)seq_printf (m," %8u" ,ttm_pool_type_count (&pt[i]));seq_puts (m,"\n" ); }
@@ -736,7 +736,7 @@ int ttm_pool_mgr_init(unsigned long num_pages)spin_lock_init (&shrinker_lock);INIT_LIST_HEAD (&shrinker_list); -for (i =0 ; i <MAX_ORDER ; ++i) { +for (i =0 ; i <=MAX_ORDER ; ++i) {ttm_pool_type_init (&global_write_combined[i],NULL , ttm_write_combined, i);ttm_pool_type_init (&global_uncached[i],NULL , ttm_uncached, i);
@@ -769,7 +769,7 @@ void ttm_pool_mgr_fini(void) {unsigned int i; -for (i =0 ; i <MAX_ORDER ; ++i) { +for (i =0 ; i <=MAX_ORDER ; ++i) {ttm_pool_type_fini (&global_write_combined[i]);ttm_pool_type_fini (&global_uncached[i]);
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +1 -1
@@ -182,7 +182,7 @@#ifdef CONFIG_CMA_ALIGNMENT #define Q_MAX_SZ_SHIFT (PAGE_SHIFT + CONFIG_CMA_ALIGNMENT)#else -#define Q_MAX_SZ_SHIFT (PAGE_SHIFT + MAX_ORDER - 1) +#define Q_MAX_SZ_SHIFT (PAGE_SHIFT + MAX_ORDER)#endif /*
drivers/iommu/dma-iommu.c +1 -1
@@ -736,7 +736,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,struct page **pages;unsigned int i =0 , nid =dev_to_node (dev); - order_mask &=GENMASK (MAX_ORDER -1 ,0 ); + order_mask &=GENMASK (MAX_ORDER ,0 );if (!order_mask)return NULL ;
drivers/irqchip/irq-gic-v3-its.c +2 -2
@@ -2440,8 +2440,8 @@ static bool its_parse_indirect_baser(struct its_node *its,* feature is not supported by hardware. */ new_order =max_t (u32,get_order (esz << ids), new_order); -if (new_order >=MAX_ORDER ) { - new_order =MAX_ORDER -1 ; +if (new_order >MAX_ORDER ) { + new_order =MAX_ORDER ; ids =ilog2 (PAGE_ORDER_TO_SIZE (new_order) / (int )esz); pr_warn("ITS@%pa: %s Table too large, reduce ids %llu->%u\n", &its->phys_base, its_base_type_string[type],
drivers/md/dm-bufio.c +1 -1
@@ -408,7 +408,7 @@ static void __cache_size_refresh(void)* If the allocation may fail we use __get_free_pages. Memory fragmentation * won't have a fatal effect here, but it just causes flushes of some other * buffers and more I/O will be performed. Don't use __get_free_pages if it -* always fails (i.e. order >= MAX_ORDER). +* always fails (i.e. order > MAX_ORDER). * * If the allocation shouldn't fail we use __vmalloc. This is only for the * initial reserve allocation, so there's no risk of wasting all vmalloc
drivers/misc/genwqe/card_dev.c +1 -1
@@ -443,7 +443,7 @@ static int genwqe_mmap(struct file *filp, struct vm_area_struct *vma)if (vsize ==0 )return -EINVAL ; -if (get_order (vsize) >=MAX_ORDER ) +if (get_order (vsize) >MAX_ORDER )return -ENOMEM ; dma_map =kzalloc (sizeof (struct dma_mapping ),GFP_KERNEL );
drivers/misc/genwqe/card_utils.c +2 -2
@@ -210,7 +210,7 @@ u32 genwqe_crc32(u8 *buff, size_t len, u32 init)void *__genwqe_alloc_consistent (struct genwqe_dev *cd,size_t size,dma_addr_t *dma_handle) { -if (get_order (size) >=MAX_ORDER ) +if (get_order (size) >MAX_ORDER )return NULL ; return dma_alloc_coherent(&cd->pci_dev->dev, size, dma_handle,
@@ -308,7 +308,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, sgl->write = write; sgl->sgl_size =genwqe_sgl_size (sgl->nr_pages); -if (get_order (sgl->sgl_size) >=MAX_ORDER ) { +if (get_order (sgl->sgl_size) >MAX_ORDER ) {dev_err (&pci_dev->dev,"[%s] err: too much memory requested!\n" , __func__);return ret;
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +1 -1
@@ -1041,7 +1041,7 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)return ; order =get_order (alloc_size); -if (order >=MAX_ORDER ) { +if (order >MAX_ORDER ) {if (net_ratelimit ())dev_warn (ring_to_dev (ring),"failed to allocate tx spare buffer, exceed to max order\n" );return ;
drivers/net/ethernet/ibm/ibmvnic.h +1 -1
@@ -75,7 +75,7 @@* pool for the 4MB. Thus the 16 Rx and Tx queues require 32 * 5 = 160 * plus 16 for the TSO pools for a total of 176 LTB mappings per VNIC. */ -#define IBMVNIC_ONE_LTB_MAX ((u32)((1 << (MAX_ORDER - 1)) * PAGE_SIZE)) +#define IBMVNIC_ONE_LTB_MAX ((u32)((1 << MAX_ORDER) * PAGE_SIZE))#define IBMVNIC_ONE_LTB_SIZE min((u32)(8 << 20), IBMVNIC_ONE_LTB_MAX)#define IBMVNIC_LTB_SET_SIZE (38 << 20)
drivers/video/fbdev/hyperv_fb.c +2 -2
@@ -946,7 +946,7 @@ static phys_addr_t hvfb_get_phymem(struct hv_device *hdev,if (request_size ==0 )return -1 ; -if (order <MAX_ORDER ) { +if (order <=MAX_ORDER ) {/* Call alloc_pages if the size is less than 2^MAX_ORDER */ page =alloc_pages (GFP_KERNEL | __GFP_ZERO, order);if (!page)
@@ -977,7 +977,7 @@ static void hvfb_release_phymem(struct hv_device *hdev, {unsigned int order =get_order (size); -if (order <MAX_ORDER ) +if (order <=MAX_ORDER )__free_pages (pfn_to_page (paddr >>PAGE_SHIFT ), order);else dma_free_coherent(&hdev->device,
drivers/video/fbdev/vermilion/vermilion.c +1 -1
@@ -197,7 +197,7 @@ static int vmlfb_alloc_vram(struct vml_info *vinfo, va = &vinfo->vram[i]; order =0 ; -while (requested > (PAGE_SIZE << order) && order <MAX_ORDER ) +while (requested > (PAGE_SIZE << order) && order <=MAX_ORDER ) order++; err =vmlfb_alloc_vram_area (va, order,0 );
drivers/virtio/virtio_balloon.c +1 -1
@@ -33,7 +33,7 @@#define VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG (__GFP_NORETRY | __GFP_NOWARN | \ __GFP_NOMEMALLOC)/* The order of free page blocks to report to host */ -#define VIRTIO_BALLOON_HINT_BLOCK_ORDER (MAX_ORDER - 1) +#define VIRTIO_BALLOON_HINT_BLOCK_ORDER MAX_ORDER/* The size of a free page block in bytes */ #define VIRTIO_BALLOON_HINT_BLOCK_BYTES \ (1 << (VIRTIO_BALLOON_HINT_BLOCK_ORDER + PAGE_SHIFT))
drivers/virtio/virtio_mem.c +6 -6
@@ -1120,13 +1120,13 @@ static void virtio_mem_clear_fake_offline(unsigned long pfn,*/ static void virtio_mem_fake_online (unsigned long pfn,unsigned long nr_pages) { -unsigned long order =MAX_ORDER -1 ; +unsigned long order =MAX_ORDER ;unsigned long i;/* * We might get called for ranges that don't cover properly aligned -* MAX_ORDER - 1 pages; however, we can only online properly aligned -* pages with an order of MAX_ORDER - 1 at maximum. +* MAX_ORDER pages; however, we can only online properly aligned +* pages with an order of MAX_ORDER at maximum. */ while (!IS_ALIGNED (pfn | nr_pages,1 << order)) order--;
@@ -1237,9 +1237,9 @@ static void virtio_mem_online_page(struct virtio_mem *vm,bool do_online;/* -* We can get called with any order up to MAX_ORDER - 1. If our -* subblock size is smaller than that and we have a mixture of plugged -* and unplugged subblocks within such a page, we have to process in +* We can get called with any order up to MAX_ORDER. If our subblock +* size is smaller than that and we have a mixture of plugged and +* unplugged subblocks within such a page, we have to process in * smaller granularity. In that case we'll adjust the order exactly once * within the loop. */
fs/ramfs/file-nommu.c +1 -1
@@ -70,7 +70,7 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)/* make various checks */ order =get_order (newsize); -if (unlikely (order >=MAX_ORDER )) +if (unlikely (order >MAX_ORDER ))return -EFBIG ; ret =inode_newsize_ok (inode, newsize);
include/drm/ttm/ttm_pool.h +1 -1
@@ -72,7 +72,7 @@ struct ttm_pool {bool use_dma32;struct { -struct ttm_pool_type orders[MAX_ORDER ]; +struct ttm_pool_type orders[MAX_ORDER +1 ]; } caching[TTM_NUM_CACHING_TYPES ]; };
include/linux/hugetlb.h +1 -1
@@ -818,7 +818,7 @@ static inline unsigned huge_page_shift(struct hstate *h)static inline bool hstate_is_gigantic (struct hstate *h) { -return huge_page_order (h) >=MAX_ORDER ; +return huge_page_order (h) >MAX_ORDER ; }static inline unsigned int pages_per_huge_page (const struct hstate *h)
include/linux/mmzone.h +5 -5
@@ -26,11 +26,11 @@/* Free memory management - zoned buddy allocator. */ #ifndef CONFIG_ARCH_FORCE_MAX_ORDER -#define MAX_ORDER 11 +#define MAX_ORDER 10#else #define MAX_ORDER CONFIG_ARCH_FORCE_MAX_ORDER#endif -#define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1)) +#define MAX_ORDER_NR_PAGES (1 << MAX_ORDER)/* * PAGE_ALLOC_COSTLY_ORDER is the order at which allocations are deemed
@@ -93,7 +93,7 @@ static inline bool migratetype_is_mergeable(int mt) }#define for_each_migratetype_order (order, type) \ - for (order = 0; order < MAX_ORDER; order++) \ + for (order = 0; order <= MAX_ORDER; order++) \ for (type = 0; type < MIGRATE_TYPES; type++)extern int page_group_by_mobility_disabled;
@@ -922,7 +922,7 @@ struct zone {CACHELINE_PADDING (_pad1_);/* free areas of different sizes */ -struct free_area free_area[MAX_ORDER ]; +struct free_area free_area[MAX_ORDER +1 ];/* zone flags, see below */ unsigned long flags;
@@ -1745,7 +1745,7 @@ static inline bool movable_only_nodes(nodemask_t *nodes)#define SECTION_BLOCKFLAGS_BITS \ ((1UL << (PFN_SECTION_SHIFT - pageblock_order)) * NR_PAGEBLOCK_BITS) -#if (MAX_ORDER -1 +PAGE_SHIFT ) >SECTION_SIZE_BITS +#if (MAX_ORDER +PAGE_SHIFT ) >SECTION_SIZE_BITS #error Allocator MAX_ORDER exceeds SECTION_SIZE#endif
include/linux/pageblock-flags.h +2 -2
@@ -41,14 +41,14 @@ extern unsigned int pageblock_order;* Huge pages are a constant size, but don't exceed the maximum allocation * granularity. */ -#define pageblock_order min_t(unsigned int, HUGETLB_PAGE_ORDER, MAX_ORDER - 1) +#define pageblock_order min_t(unsigned int, HUGETLB_PAGE_ORDER, MAX_ORDER)#endif /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */ #else /* CONFIG_HUGETLB_PAGE */ /* If huge pages are not used, group by MAX_ORDER_NR_PAGES */ -#define pageblock_order (MAX_ORDER-1) +#define pageblock_order MAX_ORDER#endif /* CONFIG_HUGETLB_PAGE */
include/linux/slab.h +3 -3
@@ -284,7 +284,7 @@ static inline unsigned int arch_slab_minalign(void)* (PAGE_SIZE*2). Larger requests are passed to the page allocator. */ #define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1) -#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) +#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT)#ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 5#endif
@@ -292,7 +292,7 @@ static inline unsigned int arch_slab_minalign(void)#ifdef CONFIG_SLUB #define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1) -#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) +#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT)#ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 3#endif
@@ -305,7 +305,7 @@ static inline unsigned int arch_slab_minalign(void)* be allocated from the same page. */ #define KMALLOC_SHIFT_HIGH PAGE_SHIFT -#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) +#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT)#ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 3#endif
kernel/crash_core.c +1 -1
@@ -474,7 +474,7 @@ static int __init crash_save_vmcoreinfo_init(void)VMCOREINFO_OFFSET (list_head, prev);VMCOREINFO_OFFSET (vmap_area, va_start);VMCOREINFO_OFFSET (vmap_area, list); -VMCOREINFO_LENGTH (zone.free_area,MAX_ORDER ); +VMCOREINFO_LENGTH (zone.free_area,MAX_ORDER +1 );log_buf_vmcoreinfo_setup ();VMCOREINFO_LENGTH (free_area.free_list,MIGRATE_TYPES );VMCOREINFO_NUMBER (NR_FREE_PAGES );
kernel/dma/pool.c +3 -3
@@ -84,8 +84,8 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,void *addr;int ret = -ENOMEM ; -/* Cannot allocate larger than MAX_ORDER-1 */ - order =min (get_order (pool_size),MAX_ORDER -1 ); +/* Cannot allocate larger than MAX_ORDER */ + order =min (get_order (pool_size),MAX_ORDER ); do { pool_size = 1 << (PAGE_SHIFT + order);
@@ -190,7 +190,7 @@ static int __init dma_atomic_pool_init(void)/* * If coherent_pool was not used on the command line, default the pool -* sizes to 128KB per 1GB of memory, min 128KB, max MAX_ORDER-1. +* sizes to 128KB per 1GB of memory, min 128KB, max MAX_ORDER. */ if (!atomic_pool_size) {unsigned long pages =totalram_pages () / (SZ_1G /SZ_128K );
kernel/events/ring_buffer.c +2 -2
@@ -609,8 +609,8 @@ static struct page *rb_alloc_aux_page(int node, int order) {struct page *page; -if (order >=MAX_ORDER ) - order =MAX_ORDER -1 ; +if (order >MAX_ORDER ) + order =MAX_ORDER ; do { page = alloc_pages_node(node, PERF_AUX_GFP, order);
mm/Kconfig +3 -3
@@ -346,9 +346,9 @@ config SHUFFLE_PAGE_ALLOCATOR the presence of a memory-side-cache. There are also incidental security benefits as it reduces the predictability of page allocations to compliment SLAB_FREELIST_RANDOM, but the - default granularity of shuffling on the "MAX_ORDER - 1" i.e, - 10th order of pages is selected based on cache utilization - benefits on x86. + default granularity of shuffling on the MAX_ORDER i.e, 10th + order of pages is selected based on cache utilization benefits + on x86. While the randomization improves cache utilization it may negatively impact workloads on platforms without a cache. For
mm/compaction.c +4 -4
@@ -583,7 +583,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,if (PageCompound (page)) {const unsigned int order =compound_order (page); -if (likely (order <MAX_ORDER )) { +if (likely (order <=MAX_ORDER )) { blockpfn += (1UL << order) -1 ; cursor += (1UL << order) -1 ; }
@@ -938,7 +938,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,* a valid page order. Consider only values in the * valid order range to prevent low_pfn overflow. */ -if (freepage_order >0 && freepage_order <MAX_ORDER ) +if (freepage_order >0 && freepage_order <=MAX_ORDER ) low_pfn += (1UL << freepage_order) -1 ;continue ; }
@@ -954,7 +954,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,if (PageCompound (page) && !cc->alloc_contig) {const unsigned int order =compound_order (page); -if (likely (order <MAX_ORDER )) +if (likely (order <=MAX_ORDER )) low_pfn += (1UL << order) -1 ; goto isolate_fail; }
@@ -2124,7 +2124,7 @@ static enum compact_result __compact_finished(struct compact_control *cc)/* Direct compactor: Is a suitable page free? */ ret =COMPACT_NO_SUITABLE_PAGE ; -for (order = cc->order; order <MAX_ORDER ; order++) { +for (order = cc->order; order <=MAX_ORDER ; order++) {struct free_area *area = &cc->zone->free_area[order];bool can_steal;
mm/debug_vm_pgtable.c +2 -2
@@ -1086,7 +1086,7 @@ debug_vm_pgtable_alloc_huge_page(struct pgtable_debug_args *args, int order)struct page *page =NULL ;#ifdef CONFIG_CONTIG_ALLOC -if (order >=MAX_ORDER ) { +if (order >MAX_ORDER ) { page =alloc_contig_pages ((1 << order),GFP_KERNEL , first_online_node,NULL );if (page) {
@@ -1096,7 +1096,7 @@ debug_vm_pgtable_alloc_huge_page(struct pgtable_debug_args *args, int order) }#endif -if (order <MAX_ORDER ) +if (order <=MAX_ORDER ) page =alloc_pages (GFP_KERNEL , order);return page;
mm/huge_memory.c +1 -1
@@ -471,7 +471,7 @@ static int __init hugepage_init(void)/* * hugepages can't be allocated by the buddy allocator */ -MAYBE_BUILD_BUG_ON (HPAGE_PMD_ORDER >=MAX_ORDER ); +MAYBE_BUILD_BUG_ON (HPAGE_PMD_ORDER >MAX_ORDER );/* * we use page->mapping and page->index in second tail page * as list_head: assuming THP order >= 2
mm/hugetlb.c +2 -2
@@ -2090,7 +2090,7 @@ pgoff_t hugetlb_basepage_index(struct page *page)pgoff_t index =page_index (page_head);unsigned long compound_idx; -if (compound_order (page_head) >=MAX_ORDER ) +if (compound_order (page_head) >MAX_ORDER ) compound_idx =page_to_pfn (page) -page_to_pfn (page_head);else compound_idx = page - page_head;
@@ -4497,7 +4497,7 @@ static int __init default_hugepagesz_setup(char *s)* The number of default huge pages (for this size) could have been * specified as the first hugetlb parameter: hugepages=X. If so, * then default_hstate_max_huge_pages is set. If the default huge -* page size is gigantic (>= MAX_ORDER), then the pages must be +* page size is gigantic (> MAX_ORDER), then the pages must be * allocated here from bootmem allocator. */ if (default_hstate_max_huge_pages) {
mm/kmsan/init.c +3 -3
@@ -96,7 +96,7 @@ void __init kmsan_init_shadow(void)struct metadata_page_pair {struct page *shadow, *origin; }; -static struct metadata_page_pair held_back[MAX_ORDER ]__initdata ; +static struct metadata_page_pair held_back[MAX_ORDER +1 ]__initdata ;/* * Eager metadata allocation. When the memblock allocator is freeing pages to
@@ -211,8 +211,8 @@ static void kmsan_memblock_discard(void)* order=N-1, * - repeat. */ - collect.order =MAX_ORDER -1 ; -for (int i =MAX_ORDER -1 ; i >=0 ; i--) { + collect.order =MAX_ORDER ; +for (int i =MAX_ORDER ; i >=0 ; i--) {if (held_back[i].shadow)smallstack_push (&collect, held_back[i].shadow);if (held_back[i].origin)
mm/memblock.c +1 -1
@@ -2043,7 +2043,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)int order;while (start < end) { - order =min (MAX_ORDER -1UL ,__ffs (start)); + order =min (MAX_ORDER ,__ffs (start));while (start + (1UL << order) > end) order--;
mm/memory_hotplug.c +2 -2
@@ -596,7 +596,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)unsigned long pfn;/* -* Online the pages in MAX_ORDER - 1 aligned chunks. The callback might +* Online the pages in MAX_ORDER aligned chunks. The callback might * decide to not expose all pages to the buddy (e.g., expose them * later). We account all pages as being online and belonging to this * zone ("present").
@@ -605,7 +605,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)* this and the first chunk to online will be pageblock_nr_pages. */ for (pfn = start_pfn; pfn < end_pfn;) { -int order =min (MAX_ORDER -1UL ,__ffs (pfn)); +int order =min (MAX_ORDER ,__ffs (pfn)); (*online_page_callback)(pfn_to_page (pfn), order); pfn += (1UL << order);
mm/page_alloc.c +19 -19
@@ -1059,7 +1059,7 @@ buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn,unsigned long higher_page_pfn;struct page *higher_page; -if (order >=MAX_ORDER -2 ) +if (order >=MAX_ORDER -1 )return false; higher_page_pfn = buddy_pfn & pfn;
@@ -1114,7 +1114,7 @@ static inline void __free_one_page(struct page *page,VM_BUG_ON_PAGE (pfn & ((1 << order) -1 ), page);VM_BUG_ON_PAGE (bad_range (zone, page), page); -while (order <MAX_ORDER -1 ) { +while (order <MAX_ORDER ) {if (compaction_capture (capc, page, order, migratetype)) {__mod_zone_freepage_state (zone, -(1 << order), migratetype);
@@ -2579,7 +2579,7 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order,struct page *page;/* Find a page of the appropriate size in the preferred list */ -for (current_order = order; current_order <MAX_ORDER ; ++current_order) { +for (current_order = order; current_order <=MAX_ORDER ; ++current_order) { area = &(zone->free_area[current_order]); page =get_page_from_free_area (area, migratetype);if (!page)
@@ -2951,7 +2951,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,continue ;spin_lock_irqsave (&zone->lock, flags); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {struct free_area *area = &(zone->free_area[order]); page =get_page_from_free_area (area,MIGRATE_HIGHATOMIC );
@@ -3035,7 +3035,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype,* approximates finding the pageblock with the most free pages, which * would be too costly to do exactly. */ -for (current_order =MAX_ORDER -1 ; current_order >= min_order; +for (current_order =MAX_ORDER ; current_order >= min_order; --current_order) { area = &(zone->free_area[current_order]); fallback_mt = find_suitable_fallback(area, current_order,
@@ -3061,7 +3061,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype,return false; find_smallest: -for (current_order = order; current_order <MAX_ORDER ; +for (current_order = order; current_order <=MAX_ORDER ; current_order++) { area = &(zone->free_area[current_order]); fallback_mt = find_suitable_fallback(area, current_order,
@@ -3074,7 +3074,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype,* This should not happen - we already found a suitable fallback * when looking for the largest page. */ -VM_BUG_ON (current_order ==MAX_ORDER ); +VM_BUG_ON (current_order >MAX_ORDER ); do_steal: page =get_page_from_free_area (area, fallback_mt);
@@ -4044,7 +4044,7 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,return true;/* For a high-order request, check at least one suitable page is free */ -for (o = order; o <MAX_ORDER ; o++) { +for (o = order; o <=MAX_ORDER ; o++) {struct free_area *area = &z->free_area[o];int mt;
@@ -5564,7 +5564,7 @@ struct page *__alloc_pages(gfp_t gfp, unsigned int order, int preferred_nid,* There are several places where we assume that the order value is sane * so bail out early if the request is out of bound. */ -if (WARN_ON_ONCE_GFP (order >=MAX_ORDER , gfp)) +if (WARN_ON_ONCE_GFP (order >MAX_ORDER , gfp))return NULL ; gfp &= gfp_allowed_mask;
@@ -6294,8 +6294,8 @@ void __show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_ifor_each_populated_zone (zone) {unsigned int order; -unsigned long nr[MAX_ORDER ], flags, total =0 ; -unsigned char types[MAX_ORDER ]; +unsigned long nr[MAX_ORDER +1 ], flags, total =0 ; +unsigned char types[MAX_ORDER +1 ];if (zone_idx (zone) > max_zone_idx)continue ;
@@ -6305,7 +6305,7 @@ void __show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_iprintk (KERN_CONT "%s: " , zone->name);spin_lock_irqsave (&zone->lock, flags); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {struct free_area *area = &zone->free_area[order];int type;
@@ -6319,7 +6319,7 @@ void __show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_i } }spin_unlock_irqrestore (&zone->lock, flags); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {printk (KERN_CONT "%lu*%lukB " , nr[order],K (1UL ) << order);if (nr[order])
@@ -7670,7 +7670,7 @@ static inline void setup_usemap(struct zone *zone) {}/* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ void __init set_pageblock_order (void ) { -unsigned int order =MAX_ORDER -1 ; +unsigned int order =MAX_ORDER ;/* Check that pageblock_nr_pages has not already been setup */ if (pageblock_order)
@@ -9165,7 +9165,7 @@ void *__init alloc_large_system_hash(const char *tablename,else table =memblock_alloc_raw (size,SMP_CACHE_BYTES ); - }else if (get_order (size) >=MAX_ORDER || hashdist) { + }else if (get_order (size) >MAX_ORDER || hashdist) { table =vmalloc_huge (size, gfp_flags); virt = true;if (table)
@@ -9379,7 +9379,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, order =0 ; outer_start = start;while (!PageBuddy (pfn_to_page (outer_start))) { -if (++order >=MAX_ORDER ) { +if (++order >MAX_ORDER ) { outer_start = start;break ; }
@@ -9629,7 +9629,7 @@ bool is_free_buddy_page(struct page *page)unsigned long pfn =page_to_pfn (page);unsigned int order; -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {struct page *page_head = page - (pfn & ((1 << order) -1 )); if (PageBuddy(page_head) &&
@@ -9637,7 +9637,7 @@ bool is_free_buddy_page(struct page *page)break ; } -return order <MAX_ORDER ; +return order <=MAX_ORDER ; }EXPORT_SYMBOL (is_free_buddy_page);
@@ -9688,7 +9688,7 @@ bool take_page_off_buddy(struct page *page)bool ret = false;spin_lock_irqsave (&zone->lock, flags); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {struct page *page_head = page - (pfn & ((1 << order) -1 ));int page_order =buddy_order (page_head);
mm/page_isolation.c +6 -6
@@ -226,7 +226,7 @@ static void unset_migratetype_isolate(struct page *page, int migratetype)*/ if (PageBuddy (page)) { order =buddy_order (page); -if (order >= pageblock_order && order <MAX_ORDER -1 ) { +if (order >= pageblock_order && order <MAX_ORDER ) { buddy =find_buddy_page_pfn (page,page_to_pfn (page), order,NULL );if (buddy && !is_migrate_isolate_page (buddy)) {
@@ -290,11 +290,11 @@ __first_valid_page(unsigned long pfn, unsigned long nr_pages)* isolate_single_pageblock() * @migratetype: migrate type to set in error recovery. * -* Free and in-use pages can be as big as MAX_ORDER-1 and contain more than one +* Free and in-use pages can be as big as MAX_ORDER and contain more than one * pageblock. When not all pageblocks within a page are isolated at the same * time, free page accounting can go wrong. For example, in the case of -* MAX_ORDER-1 = pageblock_order + 1, a MAX_ORDER-1 page has two pagelbocks. -* [ MAX_ORDER-1 ] +* MAX_ORDER = pageblock_order + 1, a MAX_ORDER page has two pagelbocks. +* [ MAX_ORDER ] * [ pageblock0 | pageblock1 ] * When either pageblock is isolated, if it is a free page, the page is not * split into separate migratetype lists, which is supposed to; if it is an
@@ -451,7 +451,7 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags,* the free page to the right migratetype list. * * head_pfn is not used here as a hugetlb page order -* can be bigger than MAX_ORDER-1, but after it is +* can be bigger than MAX_ORDER, but after it is * freed, the free page order is not. Use pfn within * the range to find the head of the free page. */
@@ -459,7 +459,7 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, outer_pfn = pfn;while (!PageBuddy (pfn_to_page (outer_pfn))) {/* stop if we cannot find the free page */ -if (++order >=MAX_ORDER ) +if (++order >MAX_ORDER ) goto failed; outer_pfn &= ~0UL << order; }
mm/page_owner.c +3 -3
@@ -315,7 +315,7 @@ void pagetypeinfo_showmixedcount_print(struct seq_file *m,unsigned long freepage_order; freepage_order =buddy_order_unsafe (page); -if (freepage_order <MAX_ORDER ) +if (freepage_order <=MAX_ORDER ) pfn += (1UL << freepage_order) -1 ;continue ; }
@@ -549,7 +549,7 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)if (PageBuddy (page)) {unsigned long freepage_order =buddy_order_unsafe (page); -if (freepage_order <MAX_ORDER ) +if (freepage_order <=MAX_ORDER ) pfn += (1UL << freepage_order) -1 ;continue ; }
@@ -657,7 +657,7 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)if (PageBuddy (page)) {unsigned long order =buddy_order_unsafe (page); -if (order >0 && order <MAX_ORDER ) +if (order >0 && order <=MAX_ORDER ) pfn += (1UL << order) -1 ;continue ; }
mm/page_reporting.c +3 -3
@@ -20,7 +20,7 @@ static int page_order_update_notify(const char *val, const struct kernel_param ** If param is set beyond this limit, order is set to default * pageblock_order value */ -return param_set_uint_minmax (val, kp,0 ,MAX_ORDER -1 ); +return param_set_uint_minmax (val, kp,0 ,MAX_ORDER ); }static const struct kernel_param_ops page_reporting_param_ops = {
@@ -276,7 +276,7 @@ page_reporting_process_zone(struct page_reporting_dev_info *prdev,return err;/* Process each free list starting from lowest order/mt */ -for (order = page_reporting_order; order <MAX_ORDER ; order++) { +for (order = page_reporting_order; order <=MAX_ORDER ; order++) {for (mt =0 ; mt <MIGRATE_TYPES ; mt++) {/* We do not pull pages from the isolate free list */ if (is_migrate_isolate (mt))
@@ -370,7 +370,7 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)*/ if (page_reporting_order ==-1 ) { -if (prdev->order >0 && prdev->order <MAX_ORDER ) +if (prdev->order >0 && prdev->order <=MAX_ORDER ) page_reporting_order = prdev->order;else page_reporting_order = pageblock_order;
mm/shuffle.h +1 -1
@@ -4,7 +4,7 @@#define _MM_SHUFFLE_H#include <linux/jump_label.h> -#define SHUFFLE_ORDER (MAX_ORDER-1) +#define SHUFFLE_ORDER MAX_ORDER#ifdef CONFIG_SHUFFLE_PAGE_ALLOCATOR DECLARE_STATIC_KEY_FALSE (page_alloc_shuffle_key);
mm/slab.c +1 -1
@@ -465,7 +465,7 @@ static int __init slab_max_order_setup(char *str) {get_option (&str, &slab_max_order); slab_max_order = slab_max_order <0 ?0 : -min (slab_max_order,MAX_ORDER -1 ); +min (slab_max_order,MAX_ORDER ); slab_max_order_set = true;return 1 ;
mm/slub.c +3 -3
@@ -4171,8 +4171,8 @@ static inline int calculate_order(unsigned int size)/* * Doh this slab cannot be placed using slub_max_order. */ - order =calc_slab_order (size,1 ,MAX_ORDER -1 ,1 ); -if (order <MAX_ORDER ) + order =calc_slab_order (size,1 ,MAX_ORDER ,1 ); +if (order <=MAX_ORDER )return order;return -ENOSYS ; }
@@ -4697,7 +4697,7 @@ __setup("slub_min_order=", setup_slub_min_order);static int __init setup_slub_max_order (char *str) {get_option (&str, (int *)&slub_max_order); - slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER -1 ); + slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER );return 1 ; }
mm/vmscan.c +1 -1
@@ -6990,7 +6990,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,* scan_control uses s8 fields for order, priority, and reclaim_idx. * Confirm they are large enough for max values. */ -BUILD_BUG_ON (MAX_ORDER >S8_MAX ); +BUILD_BUG_ON (MAX_ORDER >=S8_MAX );BUILD_BUG_ON (DEF_PRIORITY >S8_MAX );BUILD_BUG_ON (MAX_NR_ZONES >S8_MAX );
mm/vmstat.c +7 -7
@@ -1055,7 +1055,7 @@ static void fill_contig_page_info(struct zone *zone, info->free_blocks_total =0 ; info->free_blocks_suitable =0 ; -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {unsigned long blocks;/*
@@ -1088,7 +1088,7 @@ static int __fragmentation_index(unsigned int order, struct contig_page_info *in {unsigned long requested =1UL << order; -if (WARN_ON_ONCE (order >=MAX_ORDER )) +if (WARN_ON_ONCE (order >MAX_ORDER ))return 0 ;if (!info->free_blocks_total)
@@ -1462,7 +1462,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,int order;seq_printf (m,"Node %d, zone %8s " , pgdat->node_id, zone->name); -for (order =0 ; order <MAX_ORDER ; ++order) +for (order =0 ; order <=MAX_ORDER ; ++order)/* * Access to nr_free is lockless as nr_free is used only for * printing purposes. Use data_race to avoid KCSAN warning.
@@ -1491,7 +1491,7 @@ static void pagetypeinfo_showfree_print(struct seq_file *m, pgdat->node_id, zone->name, migratetype_names[mtype]); -for (order =0 ; order <MAX_ORDER ; ++order) { +for (order =0 ; order <=MAX_ORDER ; ++order) {unsigned long freecount =0 ;struct free_area *area;struct list_head *curr;
@@ -1531,7 +1531,7 @@ static void pagetypeinfo_showfree(struct seq_file *m, void *arg)/* Print header */ seq_printf (m,"%-43s " ,"Free pages count per migrate type at order" ); -for (order =0 ; order <MAX_ORDER ; ++order) +for (order =0 ; order <=MAX_ORDER ; ++order)seq_printf (m,"%6d " , order);seq_putc (m,'\n' );
@@ -2153,7 +2153,7 @@ static void unusable_show_print(struct seq_file *m,seq_printf (m,"Node %d, zone %8s " , pgdat->node_id, zone->name); -for (order =0 ; order <MAX_ORDER ; ++order) { +for (order =0 ; order <=MAX_ORDER ; ++order) {fill_contig_page_info (zone, order, &info); index =unusable_free_index (order, &info);seq_printf (m,"%d.%03d " , index /1000 , index %1000 );
@@ -2205,7 +2205,7 @@ static void extfrag_show_print(struct seq_file *m,seq_printf (m,"Node %d, zone %8s " , pgdat->node_id, zone->name); -for (order =0 ; order <MAX_ORDER ; ++order) { +for (order =0 ; order <=MAX_ORDER ; ++order) {fill_contig_page_info (zone, order, &info); index =__fragmentation_index (order, &info);seq_printf (m,"%2d.%03d " , index /1000 , index %1000 );
net/smc/smc_ib.c +1 -1
@@ -843,7 +843,7 @@ long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev) goto out;/* the calculated number of cq entries fits to mlx5 cq allocation */ cqe_size_order =cache_line_size () ==128 ?7 :6 ; - smc_order =MAX_ORDER - cqe_size_order -1 ; + smc_order =MAX_ORDER - cqe_size_order;if (SMC_MAX_CQE +2 > (0x00000001 << smc_order) *PAGE_SIZE ) cqattr.cqe = (0x00000001 << smc_order) *PAGE_SIZE -2 ; smcibdev->roce_cq_send = ib_create_cq(smcibdev->ibdev,
security/integrity/ima/ima_crypto.c +1 -1
@@ -38,7 +38,7 @@ static int param_set_bufsize(const char *val, const struct kernel_param *kp) size =memparse (val,NULL ); order =get_order (size); -if (order >=MAX_ORDER ) +if (order >MAX_ORDER )return -EINVAL ; ima_maxorder = order; ima_bufsize =PAGE_SIZE << order;
tools/testing/memblock/linux/mmzone.h +3 -3
@@ -17,10 +17,10 @@ enum zone_type { };#define MAX_NR_ZONES __MAX_NR_ZONES -#define MAX_ORDER 11 -#define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1)) +#define MAX_ORDER 10 +#define MAX_ORDER_NR_PAGES (1 << MAX_ORDER) -#define pageblock_order (MAX_ORDER - 1) +#define pageblock_order MAX_ORDER#define pageblock_nr_pages BIT(pageblock_order)#define pageblock_align (pfn) ALIGN((pfn), pageblock_nr_pages)#define pageblock_start_pfn (pfn) ALIGN_DOWN((pfn), pageblock_nr_pages)
Signature · 1 line
2.39.2
kernel test robot
build botRe: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
Thank you for the patch! Yet something to improve:
Hi Kirill,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on powerpc/next powerpc/fixes linus/master v6.3-rc2 next-20230315] [cannot apply to davem-sparc/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Kirill-A-Shutemov/sparc-mm-Fix-MAX_ORDER-usage-in-tsb_grow/20230315-193254 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20230315113133.11326-11-kirill.shutemov%40linux.intel.com patch subject: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely config: mips-randconfig-r015-20230313 (https://download.01.org/0day-ci/archive/20230315/[email protected]/config) compiler: mips64el-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ccefb5df94c3c6c966f6f583d60c9d9c832b7a34
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Kirill-A-Shutemov/sparc-mm-Fix-MAX_ORDER-usage-in-tsb_grow/20230315-193254 git checkout ccefb5df94c3c6c966f6f583d60c9d9c832b7a34
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips prepare
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/gfp.h:7,
from include/linux/xarray.h:15,
from include/linux/list_lru.h:14,
from include/linux/fs.h:13,
from include/linux/compat.h:17,
from arch/mips/kernel/asm-offsets.c:12:
>> include/linux/mmzone.h:1749:2: error: #error Allocator MAX_ORDER exceeds SECTION_SIZE 1749 | #error Allocator MAX_ORDER exceeds SECTION_SIZE
| ^~~~~
arch/mips/kernel/asm-offsets.c:26:6: warning: no previous prototype for 'output_ptreg_defines' [-Wmissing-prototypes]
26 | void output_ptreg_defines(void)
| ^~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:78:6: warning: no previous prototype for 'output_task_defines' [-Wmissing-prototypes]
78 | void output_task_defines(void)
| ^~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:92:6: warning: no previous prototype for 'output_thread_info_defines' [-Wmissing-prototypes]
92 | void output_thread_info_defines(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:108:6: warning: no previous prototype for 'output_thread_defines' [-Wmissing-prototypes]
108 | void output_thread_defines(void)
| ^~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:136:6: warning: no previous prototype for 'output_thread_fpu_defines' [-Wmissing-prototypes]
136 | void output_thread_fpu_defines(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:179:6: warning: no previous prototype for 'output_mm_defines' [-Wmissing-prototypes]
179 | void output_mm_defines(void)
| ^~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:235:6: warning: no previous prototype for 'output_sc_defines' [-Wmissing-prototypes]
235 | void output_sc_defines(void)
| ^~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:248:6: warning: no previous prototype for 'output_signal_defined' [-Wmissing-prototypes]
248 | void output_signal_defined(void)
| ^~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/asm-offsets.c:341:6: warning: no previous prototype for 'output_kvm_defines' [-Wmissing-prototypes]
341 | void output_kvm_defines(void)
| ^~~~~~~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:114: arch/mips/kernel/asm-offsets.s] Error 1
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:1287: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:226: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +1749 include/linux/mmzone.h
d41dee369bff3b Andy Whitcroft 2005-06-23 1744 835c134ec4dd75 Mel Gorman 2007-10-16 1745 #define SECTION_BLOCKFLAGS_BITS \ d9c2340052278d Mel Gorman 2007-10-16 1746 ((1UL << (PFN_SECTION_SHIFT - pageblock_order)) * NR_PAGEBLOCK_BITS) 835c134ec4dd75 Mel Gorman 2007-10-16 1747 ccefb5df94c3c6 Kirill A. Shutemov 2023-03-15 1748 #if (MAX_ORDER + PAGE_SHIFT) > SECTION_SIZE_BITS d41dee369bff3b Andy Whitcroft 2005-06-23 @1749 #error Allocator MAX_ORDER exceeds SECTION_SIZE d41dee369bff3b Andy Whitcroft 2005-06-23 1750 #endif d41dee369bff3b Andy Whitcroft 2005-06-23 1751
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
Quoted 36 lines · kernel test robot
Hi Kirill,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on powerpc/next powerpc/fixes linus/master v6.3-rc2 next-20230315] [cannot apply to davem-sparc/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Kirill-A-Shutemov/sparc-mm-Fix-MAX_ORDER-usage-in-tsb_grow/20230315-193254 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20230315113133.11326-11-kirill.shutemov%40linux.intel.com patch subject: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely config: mips-randconfig-r015-20230313 (https://download.01.org/0day-ci/archive/20230315/[email protected]/config) compiler: mips64el-linux-gcc (GCC) 12.1.0reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ccefb5df94c3c6c966f6f583d60c9d9c832b7a34
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Kirill-A-Shutemov/sparc-mm-Fix-MAX_ORDER-usage-in-tsb_grow/20230315-193254 git checkoutccefb5df94c3c6c966f6f583d60c9d9c832b7a34
# save the config file
mkdirbuild_dir&& cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips prepareIf you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
In file included from
include/linux/gfp.h:7,
Quoted 8 lines
from include/linux/xarray.h:15, from include/linux/list_lru.h:14, from include/linux/fs.h:13, from include/linux/compat.h:17, from arch/mips/kernel/asm-offsets.c:12:Quoted 1 line
Quoted 1 line
include/linux/mmzone.h:1749:2: error: #error AllocatorMAX_ORDERexceedsSECTION_SIZE1749 | #error Allocator
MAX_ORDERexceedsSECTION_SIZE
| ^~~~~
It is not regression. MIPS Kconfig allows for excessively large ARCH_FORCE_MAX_ORDER. The patch changes nothing with regarards to this. But it changes meaning of ARCH_FORCE_MAX_ORDER and old configs are now breaks.
Thomas, could you help with formulating more sensible upper limit for the config option, so it won't collide with SECTION_SIZE?
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
kernel test robot
build botRe: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
In reply to Kirill A. ShutemovThank you for the patch! Perhaps something to improve:
Hi Kirill,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on powerpc/next powerpc/fixes linus/master v6.3-rc2 next-20230315] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Kirill-A-Shutemov/sparc-mm-Fix-MAX_ORDER-usage-in-tsb_grow/20230315-193254 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20230315113133.11326-11-kirill.shutemov%40linux.intel.com patch subject: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely config: arm-randconfig-r033-20230313 (https://download.01.org/0day-ci/archive/20230315/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/ccefb5df94c3c6c966f6f583d60c9d9c832b7a34
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Kirill-A-Shutemov/sparc-mm-Fix-MAX_ORDER-usage-in-tsb_grow/20230315-193254 git checkout ccefb5df94c3c6c966f6f583d60c9d9c832b7a34
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> mm/memblock.c:2046:11: warning: comparison of distinct pointer types ('typeof (11) *' (aka 'int *') and 'typeof (__ffs(start)) *' (aka 'unsigned long *')) [-Wcompare-distinct-pointer-types]
order = min(MAX_ORDER, __ffs(start));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:67:19: note: expanded from macro 'min'
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~~~~~~~
include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~~~~~~~
include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~1 warning generated.
vim +2046 mm/memblock.c
2040
2041 static void __init __free_pages_memory(unsigned long start, unsigned long end)
2042 {
2043 int order;
2044
2045 while (start < end) {
> 2046 order = min(MAX_ORDER, __ffs(start));
2047
2048 while (start + (1UL << order) > end)
2049 order--;
2050
2051 memblock_free_pages(pfn_to_page(start), start, order);
2052
2053 start += (1UL << order);
2054 }
2055 }
2056
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
Quoted 30 lines · kernel test robot
Hi Kirill,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on powerpc/next powerpc/fixes linus/master v6.3-rc2 next-20230315] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Kirill-A-Shutemov/sparc-mm-Fix-MAX_ORDER-usage-in-tsb_grow/20230315-193254 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20230315113133.11326-11-kirill.shutemov%40linux.intel.com patch subject: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely config: arm-randconfig-r033-20230313 (https://download.01.org/0day-ci/archive/20230315/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/ccefb5df94c3c6c966f6f583d60c9d9c832b7a34
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Kirill-A-Shutemov/sparc-mm-Fix-MAX_ORDER-usage-in-tsb_grow/20230315-193254 git checkoutccefb5df94c3c6c966f6f583d60c9d9c832b7a34
# save the config file
mkdirbuild_dir&& cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
Quoted 8 lines
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
mm/memblock.c:2046:11: warning: comparison of distinct pointer types ('typeof (11) *' (aka 'int *') and 'typeof (__ffs(start)) *' (aka 'unsigned long *')) [-Wcompare-distinct-pointer-types]order = min(MAX_ORDER, __ffs(start));
The fixup:
mm/memblock.c +1 -1
@@ -2043,7 +2043,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)int order;while (start < end) { - order =min (MAX_ORDER ,__ffs (start)); + order =min_t (int,MAX_ORDER ,__ffs (start));while (start + (1UL << order) > end) order--;
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Zi Yan
reviewerRe: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
In reply to Kirill A. ShutemovQuoted 102 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Change the definition of
MAX_ORDERto be inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.Signed-off-by Kirill A. Shutemov <[email protected]>--- .../admin-guide/kdump/vmcoreinfo.rst | 2 +- .../admin-guide/kernel-parameters.txt | 2 +- arch/arc/Kconfig | 4 +- arch/arm/Kconfig | 9 ++--- arch/arm/configs/imx_v6_v7_defconfig | 2 +- arch/arm/configs/milbeaut_m10v_defconfig | 2 +- arch/arm/configs/oxnas_v6_defconfig | 2 +- arch/arm/configs/pxa_defconfig | 2 +- arch/arm/configs/sama7_defconfig | 2 +- arch/arm/configs/sp7021_defconfig | 2 +- arch/arm64/Kconfig | 27 ++++++------- arch/arm64/include/asm/sparsemem.h | 2 +- arch/arm64/kvm/hyp/include/nvhe/gfp.h | 2 +- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 10 ++--- arch/csky/Kconfig | 2 +- arch/ia64/Kconfig | 8 ++-- arch/ia64/include/asm/sparsemem.h | 4 +- arch/ia64/mm/hugetlbpage.c | 2 +- arch/loongarch/Kconfig | 15 +++----- arch/m68k/Kconfig.cpu | 5 +-- arch/mips/Kconfig | 19 ++++------ arch/nios2/Kconfig | 7 +--- arch/powerpc/Kconfig | 27 ++++++------- arch/powerpc/configs/85xx/ge_imp3a_defconfig | 2 +- arch/powerpc/configs/fsl-emb-nonhw.config | 2 +- arch/powerpc/mm/book3s64/iommu_api.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 2 +- arch/sh/configs/ecovec24_defconfig | 2 +- arch/sh/mm/Kconfig | 17 ++++----- arch/sparc/Kconfig | 5 +-- arch/sparc/kernel/pci_sun4v.c | 2 +- arch/sparc/kernel/traps_64.c | 2 +- arch/sparc/mm/tsb.c | 4 +- arch/um/kernel/um_arch.c | 4 +- arch/xtensa/Kconfig | 5 +-- drivers/base/regmap/regmap-debugfs.c | 8 ++-- drivers/block/floppy.c | 2 +- drivers/crypto/ccp/sev-dev.c | 2 +- drivers/crypto/hisilicon/sgl.c | 6 +-- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- .../gpu/drm/i915/gem/selftests/huge_pages.c | 2 +- drivers/gpu/drm/ttm/ttm_pool.c | 22 +++++------ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 +- drivers/iommu/dma-iommu.c | 2 +- drivers/irqchip/irq-gic-v3-its.c | 4 +- drivers/md/dm-bufio.c | 2 +- drivers/misc/genwqe/card_dev.c | 2 +- drivers/misc/genwqe/card_utils.c | 4 +- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- drivers/net/ethernet/ibm/ibmvnic.h | 2 +- drivers/video/fbdev/hyperv_fb.c | 4 +- drivers/video/fbdev/vermilion/vermilion.c | 2 +- drivers/virtio/virtio_balloon.c | 2 +- drivers/virtio/virtio_mem.c | 12 +++--- fs/ramfs/file-nommu.c | 2 +- include/drm/ttm/ttm_pool.h | 2 +- include/linux/hugetlb.h | 2 +- include/linux/mmzone.h | 10 ++--- include/linux/pageblock-flags.h | 4 +- include/linux/slab.h | 6 +-- kernel/crash_core.c | 2 +- kernel/dma/pool.c | 6 +-- kernel/events/ring_buffer.c | 4 +- mm/Kconfig | 6 +-- mm/compaction.c | 8 ++-- mm/debug_vm_pgtable.c | 4 +- mm/huge_memory.c | 2 +- mm/hugetlb.c | 4 +- mm/kmsan/init.c | 6 +-- mm/memblock.c | 2 +- mm/memory_hotplug.c | 4 +- mm/page_alloc.c | 38 +++++++++---------- mm/page_isolation.c | 12 +++--- mm/page_owner.c | 6 +-- mm/page_reporting.c | 6 +-- mm/shuffle.h | 2 +- mm/slab.c | 2 +- mm/slub.c | 6 +-- mm/vmscan.c | 2 +- mm/vmstat.c | 14 +++---- net/smc/smc_ib.c | 2 +- security/integrity/ima/ima_crypto.c | 2 +- tools/testing/memblock/linux/mmzone.h | 6 +-- 84 files changed, 218 insertions(+), 248 deletions(-)Documentation/admin-guide/kdump/vmcoreinfo.rst +0
-0
Documentation/admin-guide/kdump/vmcoreinfo.rst variables. · line 178
Quoted 8 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +1
-1@@ -172,7 +172,7 @@ variables. Offset of the free_list's member. This value is used to compute the number of free pages. -Each zone has a free_area structure array called free_area[MAX_ORDER]. +Each zone has a free_area structure array called free_area[MAX_ORDER + 1]. The free_list represents a linked list of free page blocks. (list_head, next|prev)
In vmcoreinfo.rst, line 192:
- (zone.free_area, MAX_ORDER)
+ (zone.free_area, MAX_ORDER + 1)
Documentation/admin-guide/kernel-parameters.txt line 3975
Quoted 13 lines
Documentation/admin-guide/kernel-parameters.txt +1
-1@@ -3969,7 +3969,7 @@ [KNL] Minimal page reporting order Format: <integer> Adjust the minimal page reporting order. The page - reporting is disabled when it exceeds (MAX_ORDER-1). + reporting is disabled when it exceeds MAX_ORDER. panic= [KNL] Kernel behaviour on panic: delay <timeout> timeout > 0: seconds before rebooting
line 942:
- possible value is MAX_ORDER/2. Setting this parameter
+ possible value is (MAX_ORDER + 1)/2. Setting this parameter
Quoted 1,231 lines
arch/arc/Kconfig +2
-2@@ -556,7 +556,7 @@ endmenu # "ARC Architecture Configuration" config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "12" if ARC_HUGEPAGE_16M - default "11" + default "11" if ARC_HUGEPAGE_16M + default "10" source "kernel/power/Kconfig"arch/arm/Kconfig +3
-6@@ -1355,9 +1355,9 @@ config ARM_MODULE_PLTS config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "12" if SOC_AM33XX - default "9" if SA1111 - default "11" + default "11" if SOC_AM33XX + default "8" if SA1111 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -1366,9 +1366,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - config ALIGNMENT_TRAP def_bool CPU_CP15_MMU select HAVE_PROC_CPU if PROC_FSarch/arm/configs/imx_v6_v7_defconfig +1
-1@@ -31,7 +31,7 @@ CONFIG_SOC_VF610=y CONFIG_SMP=y CONFIG_ARM_PSCI=y CONFIG_HIGHMEM=y -CONFIG_ARCH_FORCE_MAX_ORDER=14 +CONFIG_ARCH_FORCE_MAX_ORDER=13 CONFIG_CMDLINE="noinitrd console=ttymxc0,115200" CONFIG_KEXEC=y CONFIG_CPU_FREQ=yarch/arm/configs/milbeaut_m10v_defconfig +1
-1@@ -26,7 +26,7 @@ CONFIG_THUMB2_KERNEL=y # CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11 is not set # CONFIG_ARM_PATCH_IDIV is not set CONFIG_HIGHMEM=y -CONFIG_ARCH_FORCE_MAX_ORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=11 CONFIG_SECCOMP=y CONFIG_KEXEC=y CONFIG_EFI=yarch/arm/configs/oxnas_v6_defconfig +1
-1@@ -12,7 +12,7 @@ CONFIG_ARCH_OXNAS=y CONFIG_MACH_OX820=y CONFIG_SMP=y CONFIG_NR_CPUS=16 -CONFIG_ARCH_FORCE_MAX_ORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=11 CONFIG_SECCOMP=y CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_ATAG_DTB_COMPAT=yarch/arm/configs/pxa_defconfig +1
-1@@ -20,7 +20,7 @@ CONFIG_PXA_SHARPSL=y CONFIG_MACH_AKITA=y CONFIG_MACH_BORZOI=y CONFIG_AEABI=y -CONFIG_ARCH_FORCE_MAX_ORDER=9 +CONFIG_ARCH_FORCE_MAX_ORDER=8 CONFIG_CMDLINE="root=/dev/ram0 ro" CONFIG_KEXEC=y CONFIG_CPU_FREQ=yarch/arm/configs/sama7_defconfig +1
-1@@ -19,7 +19,7 @@ CONFIG_ATMEL_CLOCKSOURCE_TCB=y # CONFIG_CACHE_L2X0 is not set # CONFIG_ARM_PATCH_IDIV is not set # CONFIG_CPU_SW_DOMAIN_PAN is not set -CONFIG_ARCH_FORCE_MAX_ORDER=15 +CONFIG_ARCH_FORCE_MAX_ORDER=14 CONFIG_UACCESS_WITH_MEMCPY=y # CONFIG_ATAGS is not set CONFIG_CMDLINE="console=ttyS0,115200 earlyprintk ignore_loglevel"arch/arm/configs/sp7021_defconfig +1
-1@@ -17,7 +17,7 @@ CONFIG_ARCH_SUNPLUS=y # CONFIG_VDSO is not set CONFIG_SMP=y CONFIG_THUMB2_KERNEL=y -CONFIG_ARCH_FORCE_MAX_ORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=11 CONFIG_VFP=y CONFIG_NEON=y CONFIG_MODULES=yarch/arm64/Kconfig +12
-15@@ -1476,22 +1476,22 @@ config XEN # include/linux/mmzone.h requires the following to be true: # -# MAX_ORDER - 1 + PAGE_SHIFT <= SECTION_SIZE_BITS +# MAX_ORDER + PAGE_SHIFT <= SECTION_SIZE_BITS # -# so the maximum value of MAX_ORDER is SECTION_SIZE_BITS + 1 - PAGE_SHIFT: +# so the maximum value of MAX_ORDER is SECTION_SIZE_BITS - PAGE_SHIFT: # # | SECTION_SIZE_BITS | PAGE_SHIFT | max MAX_ORDER | default MAX_ORDER | # ----+-------------------+--------------+-----------------+--------------------+ -# 4K | 27 | 12 | 16 | 11 | -# 16K | 27 | 14 | 14 | 12 | -# 64K | 29 | 16 | 14 | 14 | +# 4K | 27 | 12 | 15 | 10 | +# 16K | 27 | 14 | 13 | 11 | +# 64K | 29 | 16 | 13 | 13 | config ARCH_FORCE_MAX_ORDER int "Maximum zone order" if ARM64_4K_PAGES || ARM64_16K_PAGES - default "14" if ARM64_64K_PAGES - range 12 14 if ARM64_16K_PAGES - default "12" if ARM64_16K_PAGES - range 11 16 if ARM64_4K_PAGES - default "11" + default "13" if ARM64_64K_PAGES + range 11 13 if ARM64_16K_PAGES + default "11" if ARM64_16K_PAGES + range 10 15 if ARM64_4K_PAGES + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -1500,14 +1500,11 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - We make sure that we can allocate up to a HugePage size for each configuration. Hence we have : - MAX_ORDER = (PMD_SHIFT - PAGE_SHIFT) + 1 => PAGE_SHIFT - 2 + MAX_ORDER = PMD_SHIFT - PAGE_SHIFT => PAGE_SHIFT - 3 - However for 4K, we choose a higher default value, 11 as opposed to 10, giving us + However for 4K, we choose a higher default value, 10 as opposed to 9, giving us 4M allocations matching the default size used by generic code. config UNMAP_KERNEL_AT_EL0arch/arm64/include/asm/sparsemem.h +1
-1@@ -10,7 +10,7 @@/* * Section size must be at least 512MB for 64K base * page size config. Otherwise it will be less than -* (MAX_ORDER - 1) and the build process will fail. +* MAX_ORDER and the build process will fail. */ #ifdef CONFIG_ARM64_64K_PAGES #define SECTION_SIZE_BITS 29arch/arm64/kvm/hyp/include/nvhe/gfp.h +1
-1@@ -16,7 +16,7 @@ struct hyp_pool {* API at EL2. */ hyp_spinlock_t lock; -struct list_head free_area[MAX_ORDER ]; +struct list_head free_area[MAX_ORDER +1 ];phys_addr_t range_start;phys_addr_t range_end;unsigned short max_order;arch/arm64/kvm/hyp/nvhe/page_alloc.c +5
-5@@ -110,7 +110,7 @@ static void __hyp_attach_page(struct hyp_pool *pool,* after coalescing, so make sure to mark it HYP_NO_ORDER proactively. */ p->order =HYP_NO_ORDER ; -for (; (order +1 ) < pool->max_order; order++) { +for (; (order +1 ) <= pool->max_order; order++) { buddy =__find_buddy_avail (pool, p, order);if (!buddy)break ;@@ -203,9 +203,9 @@ void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order)hyp_spin_lock (&pool->lock);/* Look for a high-enough-order page */ -while (i < pool->max_order &&list_empty (&pool->free_area[i])) +while (i <= pool->max_order &&list_empty (&pool->free_area[i])) i++; -if (i >= pool->max_order) { +if (i > pool->max_order) {hyp_spin_unlock (&pool->lock);return NULL ; }@@ -228,8 +228,8 @@ int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages,int i;hyp_spin_lock_init (&pool->lock); - pool->max_order =min (MAX_ORDER ,get_order ((nr_pages +1 ) <<PAGE_SHIFT )); -for (i =0 ; i < pool->max_order; i++) + pool->max_order =min (MAX_ORDER ,get_order (nr_pages <<PAGE_SHIFT )); +for (i =0 ; i <= pool->max_order; i++)INIT_LIST_HEAD (&pool->free_area[i]); pool->range_start = phys; pool->range_end = phys + (nr_pages <<PAGE_SHIFT );arch/csky/Kconfig +1
-1@@ -334,7 +334,7 @@ config HIGHMEM config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "11" + default "10" config DRAM_BASE hex "DRAM start addr (the same with memory-section in dts)"arch/ia64/Kconfig +4
-4@@ -202,10 +202,10 @@ config IA64_CYCLONE If you're unsure, answer N. config ARCH_FORCE_MAX_ORDER - int "MAX_ORDER (11 - 17)" if !HUGETLB_PAGE - range 11 17 if !HUGETLB_PAGE - default "17" if HUGETLB_PAGE - default "11" + int "MAX_ORDER (10 - 16)" if !HUGETLB_PAGE + range 10 16 if !HUGETLB_PAGE + default "16" if HUGETLB_PAGE + default "10" config SMP bool "Symmetric multi-processing support"arch/ia64/include/asm/sparsemem.h +2
-2@@ -12,9 +12,9 @@#define SECTION_SIZE_BITS (30)#define MAX_PHYSMEM_BITS (50)#ifdef CONFIG_ARCH_FORCE_MAX_ORDER -#if ((CONFIG_ARCH_FORCE_MAX_ORDER -1 +PAGE_SHIFT ) >SECTION_SIZE_BITS ) +#if (CONFIG_ARCH_FORCE_MAX_ORDER +PAGE_SHIFT >SECTION_SIZE_BITS )#undef SECTION_SIZE_BITS -#define SECTION_SIZE_BITS (CONFIG_ARCH_FORCE_MAX_ORDER - 1 + PAGE_SHIFT) +#define SECTION_SIZE_BITS (CONFIG_ARCH_FORCE_MAX_ORDER + PAGE_SHIFT)#endif #endif arch/ia64/mm/hugetlbpage.c +1
-1@@ -170,7 +170,7 @@ static int __init hugetlb_setup_sz(char *str) size =memparse (str, &str);if (*str || !is_power_of_2 (size) || !(tr_pages & size) || size <=PAGE_SIZE || - size >= (1UL <<PAGE_SHIFT <<MAX_ORDER )) { + size > (1UL <<PAGE_SHIFT <<MAX_ORDER )) {printk (KERN_WARNING "Invalid huge page size specified\n" );return 1 ; }arch/loongarch/Kconfig +6
-9@@ -420,12 +420,12 @@ config NODES_SHIFT config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 14 64 if PAGE_SIZE_64KB - default "14" if PAGE_SIZE_64KB - range 12 64 if PAGE_SIZE_16KB - default "12" if PAGE_SIZE_16KB - range 11 64 - default "11" + range 13 63 if PAGE_SIZE_64KB + default "13" if PAGE_SIZE_64KB + range 11 63 if PAGE_SIZE_16KB + default "11" if PAGE_SIZE_16KB + range 10 63 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -434,9 +434,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - The page size is not necessarily 4KB. Keep this in mind when choosing a value for this option.arch/m68k/Kconfig.cpu +1
-4@@ -400,7 +400,7 @@ config SINGLE_MEMORY_CHUNK config ARCH_FORCE_MAX_ORDER int "Maximum zone order" if ADVANCED depends on !SINGLE_MEMORY_CHUNK - default "11" + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -413,9 +413,6 @@ config ARCH_FORCE_MAX_ORDER value also defines the minimal size of the hole that allows freeing unused memory map. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - config 060_WRITETHROUGH bool "Use write-through caching for 68060 supervisor accesses" depends on ADVANCED && M68060arch/mips/Kconfig +8
-11@@ -2137,14 +2137,14 @@ endchoice config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 14 64 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB - default "14" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB - range 13 64 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB - default "13" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB - range 12 64 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB - default "12" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB - range 0 64 - default "11" + range 13 63 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB + default "13" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB + range 12 63 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB + default "12" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_32KB + range 11 63 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB + default "11" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_16KB + range 0 63 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -2153,9 +2153,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - The page size is not necessarily 4KB. Keep this in mind when choosing a value for this option.arch/nios2/Kconfig +2
-5@@ -46,8 +46,8 @@ source "kernel/Kconfig.hz" config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 9 20 - default "11" + range 8 19 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -56,9 +56,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - endmenu source "arch/nios2/platform/Kconfig.platform"arch/powerpc/Kconfig +12
-15@@ -896,18 +896,18 @@ config DATA_SHIFT config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 8 9 if PPC64 && PPC_64K_PAGES - default "9" if PPC64 && PPC_64K_PAGES - range 13 13 if PPC64 && !PPC_64K_PAGES - default "13" if PPC64 && !PPC_64K_PAGES - range 9 64 if PPC32 && PPC_16K_PAGES - default "9" if PPC32 && PPC_16K_PAGES - range 7 64 if PPC32 && PPC_64K_PAGES - default "7" if PPC32 && PPC_64K_PAGES - range 5 64 if PPC32 && PPC_256K_PAGES - default "5" if PPC32 && PPC_256K_PAGES - range 11 64 - default "11" + range 7 8 if PPC64 && PPC_64K_PAGES + default "8" if PPC64 && PPC_64K_PAGES + range 12 12 if PPC64 && !PPC_64K_PAGES + default "12" if PPC64 && !PPC_64K_PAGES + range 8 63 if PPC32 && PPC_16K_PAGES + default "8" if PPC32 && PPC_16K_PAGES + range 6 63 if PPC32 && PPC_64K_PAGES + default "6" if PPC32 && PPC_64K_PAGES + range 4 63 if PPC32 && PPC_256K_PAGES + default "4" if PPC32 && PPC_256K_PAGES + range 10 63 + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -916,9 +916,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - The page size is not necessarily 4KB. For example, on 64-bit systems, 64KB pages can be enabled via CONFIG_PPC_64K_PAGES. Keep this in mind when choosing a value for this option.arch/powerpc/configs/85xx/ge_imp3a_defconfig +1
-1@@ -30,7 +30,7 @@ CONFIG_PREEMPT=y # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set CONFIG_BINFMT_MISC=m CONFIG_MATH_EMULATION=y -CONFIG_ARCH_FORCE_MAX_ORDER=17 +CONFIG_ARCH_FORCE_MAX_ORDER=16 CONFIG_PCI=y CONFIG_PCIEPORTBUS=y CONFIG_PCI_MSI=yarch/powerpc/configs/fsl-emb-nonhw.config +1
-1@@ -41,7 +41,7 @@ CONFIG_FIXED_PHY=y CONFIG_FONT_8x16=y CONFIG_FONT_8x8=y CONFIG_FONTS=y -CONFIG_ARCH_FORCE_MAX_ORDER=13 +CONFIG_ARCH_FORCE_MAX_ORDER=12 CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FRAME_WARN=1024 CONFIG_FTL=yarch/powerpc/mm/book3s64/iommu_api.c +1
-1@@ -97,7 +97,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua, }mmap_read_lock (mm); - chunk = (1UL << (PAGE_SHIFT +MAX_ORDER -1 )) / + chunk = (1UL << (PAGE_SHIFT +MAX_ORDER )) /sizeof (struct vm_area_struct *); chunk =min (chunk, entries);for (entry =0 ; entry < entries; entry += chunk) {arch/powerpc/mm/hugetlbpage.c +1
-1@@ -615,7 +615,7 @@ void __init gigantic_hugetlb_cma_reserve(void) order =mmu_psize_to_shift (MMU_PAGE_16G ) -PAGE_SHIFT ;if (order) { -VM_WARN_ON (order <MAX_ORDER ); +VM_WARN_ON (order <=MAX_ORDER );hugetlb_cma_reserve (order); } }arch/powerpc/platforms/powernv/pci-ioda.c +1
-1@@ -1740,7 +1740,7 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe)* DMA window can be larger than available memory, which will * cause errors later. */ -const u64 maxblock =1UL << (PAGE_SHIFT +MAX_ORDER -1 ); +const u64 maxblock =1UL << (PAGE_SHIFT +MAX_ORDER );/* * We create the default window as big as we can. The constraint is arch/sh/configs/ecovec24_defconfig +1
-1@@ -8,7 +8,7 @@ CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y # CONFIG_BLK_DEV_BSG is not set CONFIG_CPU_SUBTYPE_SH7724=y -CONFIG_ARCH_FORCE_MAX_ORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=11 CONFIG_MEMORY_SIZE=0x10000000 CONFIG_FLATMEM_MANUAL=y CONFIG_SH_ECOVEC=yarch/sh/mm/Kconfig +7
-10@@ -20,13 +20,13 @@ config PAGE_OFFSET config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - range 9 64 if PAGE_SIZE_16KB - default "9" if PAGE_SIZE_16KB - range 7 64 if PAGE_SIZE_64KB - default "7" if PAGE_SIZE_64KB - range 11 64 - default "14" if !MMU - default "11" + range 8 63 if PAGE_SIZE_16KB + default "8" if PAGE_SIZE_16KB + range 6 63 if PAGE_SIZE_64KB + default "6" if PAGE_SIZE_64KB + range 10 63 + default "13" if !MMU + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -35,9 +35,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - The page size is not necessarily 4KB. Keep this in mind when choosing a value for this option.arch/sparc/Kconfig +1
-4@@ -271,7 +271,7 @@ config ARCH_SPARSEMEM_DEFAULT config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "13" + default "12" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -280,9 +280,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 13 means that the largest free memory block is 2^12 pages. - if SPARC64 || COMPILE_TEST source "kernel/power/Kconfig" endifarch/sparc/kernel/pci_sun4v.c +1
-1@@ -193,7 +193,7 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size, size =IO_PAGE_ALIGN (size); order =get_order (size); -if (unlikely (order >=MAX_ORDER )) +if (unlikely (order >MAX_ORDER ))return NULL ; npages = size >>IO_PAGE_SHIFT ;arch/sparc/kernel/traps_64.c +1
-1@@ -897,7 +897,7 @@ void __init cheetah_ecache_flush_init(void)/* Now allocate error trap reporting scoreboard. */ sz =NR_CPUS * (2 *sizeof (struct cheetah_err_info )); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {if ((PAGE_SIZE << order) >= sz)break ; }arch/sparc/mm/tsb.c +2
-2@@ -402,8 +402,8 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss)unsigned long new_rss_limit;gfp_t gfp_flags; -if (max_tsb_size > (PAGE_SIZE << (MAX_ORDER -1 ))) - max_tsb_size = (PAGE_SIZE << (MAX_ORDER -1 )); +if (max_tsb_size >PAGE_SIZE <<MAX_ORDER ) + max_tsb_size =PAGE_SIZE <<MAX_ORDER ; new_cache_index =0 ;for (new_size =8192 ; new_size < max_tsb_size; new_size <<=1UL ) {arch/um/kernel/um_arch.c +2
-2@@ -368,10 +368,10 @@ int __init linux_main(int argc, char **argv) max_physmem =TASK_SIZE - uml_physmem - iomem_size -MIN_VMALLOC ;/* -* Zones have to begin on a 1 << MAX_ORDER-1 page boundary, +* Zones have to begin on a 1 << MAX_ORDER page boundary, * so this makes sure that's true for highmem */ - max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER -1 )) -1 ); + max_physmem &= ~((1 << (PAGE_SHIFT +MAX_ORDER )) -1 );if (physmem_size + iomem_size > max_physmem) { highmem = physmem_size + iomem_size - max_physmem; physmem_size -= highmem;arch/xtensa/Kconfig +1
-4@@ -773,7 +773,7 @@ config HIGHMEM config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "11" + default "10" help The kernel memory allocator divides physically contiguous memory blocks into "zones", where each zone is a power of two number of@@ -782,9 +782,6 @@ config ARCH_FORCE_MAX_ORDER blocks of physically contiguous memory, then you may need to increase this value. - This config option is actually maximum order plus one. For example, - a value of 11 means that the largest free memory block is 2^10 pages. - endmenu menu "Power management options"drivers/base/regmap/regmap-debugfs.c +4
-4@@ -226,8 +226,8 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,if (*ppos <0 || !count)return -EINVAL ; -if (count > (PAGE_SIZE << (MAX_ORDER -1 ))) - count =PAGE_SIZE << (MAX_ORDER -1 ); +if (count > (PAGE_SIZE <<MAX_ORDER )) + count =PAGE_SIZE <<MAX_ORDER ; buf =kmalloc (count,GFP_KERNEL );if (!buf)@@ -373,8 +373,8 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,if (*ppos <0 || !count)return -EINVAL ; -if (count > (PAGE_SIZE << (MAX_ORDER -1 ))) - count =PAGE_SIZE << (MAX_ORDER -1 ); +if (count > (PAGE_SIZE <<MAX_ORDER )) + count =PAGE_SIZE <<MAX_ORDER ; buf =kmalloc (count,GFP_KERNEL );if (!buf)drivers/block/floppy.c +1
-1@@ -3079,7 +3079,7 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) } } -#define MAX_LEN (1UL << (MAX_ORDER - 1) << PAGE_SHIFT) +#define MAX_LEN (1UL << MAX_ORDER << PAGE_SHIFT)static int raw_cmd_copyin (int cmd,void __user *param,struct floppy_raw_cmd **rcmd)drivers/crypto/ccp/sev-dev.c +1
-1@@ -886,7 +886,7 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)/* * The length of the ID shouldn't be assumed by software since * it may change in the future. The allocation size is limited -* to 1 << (PAGE_SHIFT + MAX_ORDER - 1) by the page allocator. +* to 1 << (PAGE_SHIFT + MAX_ORDER) by the page allocator. * If the allocation fails, simply return ENOMEM rather than * warning in the kernel log. */ drivers/crypto/hisilicon/sgl.c +3
-3@@ -70,11 +70,11 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev, HISI_ACC_SGL_ALIGN_SIZE);/* -* the pool may allocate a block of memory of size PAGE_SIZE * 2^(MAX_ORDER - 1), +* the pool may allocate a block of memory of size PAGE_SIZE * 2^MAX_ORDER, * block size may exceed 2^31 on ia64, so the max of block size is 2^31 */ - block_size =1 << (PAGE_SHIFT +MAX_ORDER <=32 ? -PAGE_SHIFT +MAX_ORDER -1 :31 ); + block_size =1 << (PAGE_SHIFT +MAX_ORDER <32 ? +PAGE_SHIFT +MAX_ORDER :31 ); sgl_num_per_block = block_size / sgl_size; block_num = count / sgl_num_per_block; remain_sgl = count % sgl_num_per_block;drivers/gpu/drm/i915/gem/i915_gem_internal.c +1
-1@@ -36,7 +36,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)struct sg_table *st;struct scatterlist *sg;unsigned int npages;/* restricted by sg_alloc_table */ -int max_order =MAX_ORDER -1 ; +int max_order =MAX_ORDER ;unsigned int max_segment;gfp_t gfp;drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1
-1@@ -115,7 +115,7 @@ static int get_huge_pages(struct drm_i915_gem_object *obj) do { struct page *page; - GEM_BUG_ON(order >= MAX_ORDER); + GEM_BUG_ON(order > MAX_ORDER); page = alloc_pages(GFP | __GFP_ZERO, order); if (!page) goto err;drivers/gpu/drm/ttm/ttm_pool.c +11
-11@@ -65,11 +65,11 @@ module_param(page_pool_size, ulong, 0644);static atomic_long_t allocated_pages; -static struct ttm_pool_type global_write_combined[MAX_ORDER ]; -static struct ttm_pool_type global_uncached[MAX_ORDER ]; +static struct ttm_pool_type global_write_combined[MAX_ORDER +1 ]; +static struct ttm_pool_type global_uncached[MAX_ORDER +1 ]; -static struct ttm_pool_type global_dma32_write_combined[MAX_ORDER ]; -static struct ttm_pool_type global_dma32_uncached[MAX_ORDER ]; +static struct ttm_pool_type global_dma32_write_combined[MAX_ORDER +1 ]; +static struct ttm_pool_type global_dma32_uncached[MAX_ORDER +1 ];static spinlock_t shrinker_lock;static struct list_head shrinker_list;@@ -405,7 +405,7 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,else gfp_flags |=GFP_HIGHUSER ; - for (order = min_t(unsigned int, MAX_ORDER - 1, __fls(num_pages)); + for (order = min_t(unsigned int, MAX_ORDER, __fls(num_pages)); num_pages; order = min_t(unsigned int, order, __fls(num_pages))) {struct ttm_pool_type *pt;@@ -542,7 +542,7 @@ void ttm_pool_init(struct ttm_pool *pool, struct device *dev,if (use_dma_alloc) {for (i =0 ; i <TTM_NUM_CACHING_TYPES ; ++i) -for (j =0 ; j <MAX_ORDER ; ++j) +for (j =0 ; j <=MAX_ORDER ; ++j)ttm_pool_type_init (&pool->caching[i].orders[j], pool, i, j); }@@ -562,7 +562,7 @@ void ttm_pool_fini(struct ttm_pool *pool)if (pool->use_dma_alloc) {for (i =0 ; i <TTM_NUM_CACHING_TYPES ; ++i) -for (j =0 ; j <MAX_ORDER ; ++j) +for (j =0 ; j <=MAX_ORDER ; ++j)ttm_pool_type_fini (&pool->caching[i].orders[j]); }@@ -616,7 +616,7 @@ static void ttm_pool_debugfs_header(struct seq_file *m)unsigned int i;seq_puts (m,"\t " ); -for (i =0 ; i <MAX_ORDER ; ++i) +for (i =0 ; i <=MAX_ORDER ; ++i)seq_printf (m," ---%2u---" , i);seq_puts (m,"\n" ); }@@ -627,7 +627,7 @@ static void ttm_pool_debugfs_orders(struct ttm_pool_type *pt, {unsigned int i; -for (i =0 ; i <MAX_ORDER ; ++i) +for (i =0 ; i <=MAX_ORDER ; ++i)seq_printf (m," %8u" ,ttm_pool_type_count (&pt[i]));seq_puts (m,"\n" ); }@@ -736,7 +736,7 @@ int ttm_pool_mgr_init(unsigned long num_pages)spin_lock_init (&shrinker_lock);INIT_LIST_HEAD (&shrinker_list); -for (i =0 ; i <MAX_ORDER ; ++i) { +for (i =0 ; i <=MAX_ORDER ; ++i) {ttm_pool_type_init (&global_write_combined[i],NULL , ttm_write_combined, i);ttm_pool_type_init (&global_uncached[i],NULL , ttm_uncached, i);@@ -769,7 +769,7 @@ void ttm_pool_mgr_fini(void) {unsigned int i; -for (i =0 ; i <MAX_ORDER ; ++i) { +for (i =0 ; i <=MAX_ORDER ; ++i) {ttm_pool_type_fini (&global_write_combined[i]);ttm_pool_type_fini (&global_uncached[i]);drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +1
-1@@ -182,7 +182,7 @@#ifdef CONFIG_CMA_ALIGNMENT #define Q_MAX_SZ_SHIFT (PAGE_SHIFT + CONFIG_CMA_ALIGNMENT)#else -#define Q_MAX_SZ_SHIFT (PAGE_SHIFT + MAX_ORDER - 1) +#define Q_MAX_SZ_SHIFT (PAGE_SHIFT + MAX_ORDER)#endif /* drivers/iommu/dma-iommu.c +1
-1@@ -736,7 +736,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,struct page **pages;unsigned int i =0 , nid =dev_to_node (dev); - order_mask &=GENMASK (MAX_ORDER -1 ,0 ); + order_mask &=GENMASK (MAX_ORDER ,0 );if (!order_mask)return NULL ;drivers/irqchip/irq-gic-v3-its.c +2
-2@@ -2440,8 +2440,8 @@ static bool its_parse_indirect_baser(struct its_node *its,* feature is not supported by hardware. */ new_order =max_t (u32,get_order (esz << ids), new_order); -if (new_order >=MAX_ORDER ) { - new_order =MAX_ORDER -1 ; +if (new_order >MAX_ORDER ) { + new_order =MAX_ORDER ; ids =ilog2 (PAGE_ORDER_TO_SIZE (new_order) / (int )esz); pr_warn("ITS@%pa: %s Table too large, reduce ids %llu->%u\n", &its->phys_base, its_base_type_string[type],drivers/md/dm-bufio.c +1
-1@@ -408,7 +408,7 @@ static void __cache_size_refresh(void)* If the allocation may fail we use __get_free_pages. Memory fragmentation * won't have a fatal effect here, but it just causes flushes of some other * buffers and more I/O will be performed. Don't use __get_free_pages if it -* always fails (i.e. order >= MAX_ORDER). +* always fails (i.e. order > MAX_ORDER). * * If the allocation shouldn't fail we use __vmalloc. This is only for the * initial reserve allocation, so there's no risk of wasting all vmalloc drivers/misc/genwqe/card_dev.c +1
-1@@ -443,7 +443,7 @@ static int genwqe_mmap(struct file *filp, struct vm_area_struct *vma)if (vsize ==0 )return -EINVAL ; -if (get_order (vsize) >=MAX_ORDER ) +if (get_order (vsize) >MAX_ORDER )return -ENOMEM ; dma_map =kzalloc (sizeof (struct dma_mapping ),GFP_KERNEL );drivers/misc/genwqe/card_utils.c +2
-2@@ -210,7 +210,7 @@ u32 genwqe_crc32(u8 *buff, size_t len, u32 init)void *__genwqe_alloc_consistent (struct genwqe_dev *cd,size_t size,dma_addr_t *dma_handle) { -if (get_order (size) >=MAX_ORDER ) +if (get_order (size) >MAX_ORDER )return NULL ; return dma_alloc_coherent(&cd->pci_dev->dev, size, dma_handle,@@ -308,7 +308,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, sgl->write = write; sgl->sgl_size =genwqe_sgl_size (sgl->nr_pages); -if (get_order (sgl->sgl_size) >=MAX_ORDER ) { +if (get_order (sgl->sgl_size) >MAX_ORDER ) {dev_err (&pci_dev->dev,"[%s] err: too much memory requested!\n" , __func__);return ret;drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +1
-1@@ -1041,7 +1041,7 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)return ; order =get_order (alloc_size); -if (order >=MAX_ORDER ) { +if (order >MAX_ORDER ) {if (net_ratelimit ())dev_warn (ring_to_dev (ring),"failed to allocate tx spare buffer, exceed to max order\n" );return ;drivers/net/ethernet/ibm/ibmvnic.h +1
-1@@ -75,7 +75,7 @@* pool for the 4MB. Thus the 16 Rx and Tx queues require 32 * 5 = 160 * plus 16 for the TSO pools for a total of 176 LTB mappings per VNIC. */ -#define IBMVNIC_ONE_LTB_MAX ((u32)((1 << (MAX_ORDER - 1)) * PAGE_SIZE)) +#define IBMVNIC_ONE_LTB_MAX ((u32)((1 << MAX_ORDER) * PAGE_SIZE))#define IBMVNIC_ONE_LTB_SIZE min((u32)(8 << 20), IBMVNIC_ONE_LTB_MAX)#define IBMVNIC_LTB_SET_SIZE (38 << 20)drivers/video/fbdev/hyperv_fb.c +2
-2@@ -946,7 +946,7 @@ static phys_addr_t hvfb_get_phymem(struct hv_device *hdev,if (request_size ==0 )return -1 ; -if (order <MAX_ORDER ) { +if (order <=MAX_ORDER ) {/* Call alloc_pages if the size is less than 2^MAX_ORDER */ page =alloc_pages (GFP_KERNEL | __GFP_ZERO, order);if (!page)@@ -977,7 +977,7 @@ static void hvfb_release_phymem(struct hv_device *hdev, {unsigned int order =get_order (size); -if (order <MAX_ORDER ) +if (order <=MAX_ORDER )__free_pages (pfn_to_page (paddr >>PAGE_SHIFT ), order);else dma_free_coherent(&hdev->device,drivers/video/fbdev/vermilion/vermilion.c +1
-1@@ -197,7 +197,7 @@ static int vmlfb_alloc_vram(struct vml_info *vinfo, va = &vinfo->vram[i]; order =0 ; -while (requested > (PAGE_SIZE << order) && order <MAX_ORDER ) +while (requested > (PAGE_SIZE << order) && order <=MAX_ORDER ) order++; err =vmlfb_alloc_vram_area (va, order,0 );drivers/virtio/virtio_balloon.c +1
-1@@ -33,7 +33,7 @@#define VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG (__GFP_NORETRY | __GFP_NOWARN | \ __GFP_NOMEMALLOC)/* The order of free page blocks to report to host */ -#define VIRTIO_BALLOON_HINT_BLOCK_ORDER (MAX_ORDER - 1) +#define VIRTIO_BALLOON_HINT_BLOCK_ORDER MAX_ORDER/* The size of a free page block in bytes */ #define VIRTIO_BALLOON_HINT_BLOCK_BYTES \ (1 << (VIRTIO_BALLOON_HINT_BLOCK_ORDER + PAGE_SHIFT))drivers/virtio/virtio_mem.c +6
-6@@ -1120,13 +1120,13 @@ static void virtio_mem_clear_fake_offline(unsigned long pfn,*/ static void virtio_mem_fake_online (unsigned long pfn,unsigned long nr_pages) { -unsigned long order =MAX_ORDER -1 ; +unsigned long order =MAX_ORDER ;unsigned long i;/* * We might get called for ranges that don't cover properly aligned -* MAX_ORDER - 1 pages; however, we can only online properly aligned -* pages with an order of MAX_ORDER - 1 at maximum. +* MAX_ORDER pages; however, we can only online properly aligned +* pages with an order of MAX_ORDER at maximum. */ while (!IS_ALIGNED (pfn | nr_pages,1 << order)) order--;@@ -1237,9 +1237,9 @@ static void virtio_mem_online_page(struct virtio_mem *vm,bool do_online;/* -* We can get called with any order up to MAX_ORDER - 1. If our -* subblock size is smaller than that and we have a mixture of plugged -* and unplugged subblocks within such a page, we have to process in +* We can get called with any order up to MAX_ORDER. If our subblock +* size is smaller than that and we have a mixture of plugged and +* unplugged subblocks within such a page, we have to process in * smaller granularity. In that case we'll adjust the order exactly once * within the loop. */ fs/ramfs/file-nommu.c +1
-1@@ -70,7 +70,7 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)/* make various checks */ order =get_order (newsize); -if (unlikely (order >=MAX_ORDER )) +if (unlikely (order >MAX_ORDER ))return -EFBIG ; ret =inode_newsize_ok (inode, newsize);include/drm/ttm/ttm_pool.h +1
-1@@ -72,7 +72,7 @@ struct ttm_pool {bool use_dma32;struct { -struct ttm_pool_type orders[MAX_ORDER ]; +struct ttm_pool_type orders[MAX_ORDER +1 ]; } caching[TTM_NUM_CACHING_TYPES ]; };include/linux/hugetlb.h +1
-1@@ -818,7 +818,7 @@ static inline unsigned huge_page_shift(struct hstate *h)static inline bool hstate_is_gigantic (struct hstate *h) { -return huge_page_order (h) >=MAX_ORDER ; +return huge_page_order (h) >MAX_ORDER ; }static inline unsigned int pages_per_huge_page (const struct hstate *h)include/linux/mmzone.h +5
-5@@ -26,11 +26,11 @@/* Free memory management - zoned buddy allocator. */ #ifndef CONFIG_ARCH_FORCE_MAX_ORDER -#define MAX_ORDER 11 +#define MAX_ORDER 10#else #define MAX_ORDER CONFIG_ARCH_FORCE_MAX_ORDER#endif -#define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1)) +#define MAX_ORDER_NR_PAGES (1 << MAX_ORDER)/* * PAGE_ALLOC_COSTLY_ORDER is the order at which allocations are deemed @@ -93,7 +93,7 @@ static inline bool migratetype_is_mergeable(int mt) }#define for_each_migratetype_order (order, type) \ - for (order = 0; order < MAX_ORDER; order++) \ + for (order = 0; order <= MAX_ORDER; order++) \ for (type = 0; type < MIGRATE_TYPES; type++)extern int page_group_by_mobility_disabled;@@ -922,7 +922,7 @@ struct zone {CACHELINE_PADDING (_pad1_);/* free areas of different sizes */ -struct free_area free_area[MAX_ORDER ]; +struct free_area free_area[MAX_ORDER +1 ];/* zone flags, see below */ unsigned long flags;@@ -1745,7 +1745,7 @@ static inline bool movable_only_nodes(nodemask_t *nodes)#define SECTION_BLOCKFLAGS_BITS \ ((1UL << (PFN_SECTION_SHIFT - pageblock_order)) * NR_PAGEBLOCK_BITS) -#if (MAX_ORDER -1 +PAGE_SHIFT ) >SECTION_SIZE_BITS +#if (MAX_ORDER +PAGE_SHIFT ) >SECTION_SIZE_BITS #error Allocator MAX_ORDER exceeds SECTION_SIZE#endif include/linux/pageblock-flags.h +2
-2@@ -41,14 +41,14 @@ extern unsigned int pageblock_order;* Huge pages are a constant size, but don't exceed the maximum allocation * granularity. */ -#define pageblock_order min_t(unsigned int, HUGETLB_PAGE_ORDER, MAX_ORDER - 1) +#define pageblock_order min_t(unsigned int, HUGETLB_PAGE_ORDER, MAX_ORDER)#endif /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */ #else /* CONFIG_HUGETLB_PAGE */ /* If huge pages are not used, group by MAX_ORDER_NR_PAGES */ -#define pageblock_order (MAX_ORDER-1) +#define pageblock_order MAX_ORDER#endif /* CONFIG_HUGETLB_PAGE */ include/linux/slab.h +3
-3@@ -284,7 +284,7 @@ static inline unsigned int arch_slab_minalign(void)* (PAGE_SIZE*2). Larger requests are passed to the page allocator. */ #define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1) -#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) +#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT)#ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 5#endif @@ -292,7 +292,7 @@ static inline unsigned int arch_slab_minalign(void)#ifdef CONFIG_SLUB #define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1) -#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) +#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT)#ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 3#endif @@ -305,7 +305,7 @@ static inline unsigned int arch_slab_minalign(void)* be allocated from the same page. */ #define KMALLOC_SHIFT_HIGH PAGE_SHIFT -#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) +#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT)#ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 3#endif kernel/crash_core.c +1
-1@@ -474,7 +474,7 @@ static int __init crash_save_vmcoreinfo_init(void)VMCOREINFO_OFFSET (list_head, prev);VMCOREINFO_OFFSET (vmap_area, va_start);VMCOREINFO_OFFSET (vmap_area, list); -VMCOREINFO_LENGTH (zone.free_area,MAX_ORDER ); +VMCOREINFO_LENGTH (zone.free_area,MAX_ORDER +1 );log_buf_vmcoreinfo_setup ();VMCOREINFO_LENGTH (free_area.free_list,MIGRATE_TYPES );VMCOREINFO_NUMBER (NR_FREE_PAGES );kernel/dma/pool.c +3
-3@@ -84,8 +84,8 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,void *addr;int ret = -ENOMEM ; -/* Cannot allocate larger than MAX_ORDER-1 */ - order =min (get_order (pool_size),MAX_ORDER -1 ); +/* Cannot allocate larger than MAX_ORDER */ + order =min (get_order (pool_size),MAX_ORDER ); do { pool_size = 1 << (PAGE_SHIFT + order);@@ -190,7 +190,7 @@ static int __init dma_atomic_pool_init(void)/* * If coherent_pool was not used on the command line, default the pool -* sizes to 128KB per 1GB of memory, min 128KB, max MAX_ORDER-1. +* sizes to 128KB per 1GB of memory, min 128KB, max MAX_ORDER. */ if (!atomic_pool_size) {unsigned long pages =totalram_pages () / (SZ_1G /SZ_128K );kernel/events/ring_buffer.c +0
-0
kernel/events/ring_buffer.c static struct page *rb_alloc_aux_page(int node, int order) · line 616
Quoted 10 lines
kernel/events/ring_buffer.c +2
-2@@ -609,8 +609,8 @@ static struct page *rb_alloc_aux_page(int node, int order) {struct page *page; -if (order >=MAX_ORDER ) - order =MAX_ORDER -1 ; +if (order >MAX_ORDER ) + order =MAX_ORDER ; do { page = alloc_pages_node(node, PERF_AUX_GFP, order);
line 817:
- if (order_base_2(size) >= PAGE_SHIFT+MAX_ORDER)
+ if (order_base_2(size) > PAGE_SHIFT+MAX_ORDER)
Quoted 7 lines
mm/Kconfig +0
-0@@ -346,9 +346,9 @@ config SHUFFLE_PAGE_ALLOCATOR the presence of a memory-side-cache. There are also incidental security benefits as it reduces the predictability of page
mm/Kconfig config SHUFFLE_PAGE_ALLOCATOR · line 354
Quoted 10 lines
mm/Kconfig +3
-3allocations to compliment SLAB_FREELIST_RANDOM, but the - default granularity of shuffling on the "MAX_ORDER - 1" i.e, - 10th order of pages is selected based on cache utilization - benefits on x86. + default granularity of shuffling on the MAX_ORDER i.e, 10th + order of pages is selected based on cache utilization benefits + on x86. While the randomization improves cache utilization it may negatively impact workloads on platforms without a cache. For
line 669:
- Note that the pageblock_order cannot exceed MAX_ORDER - 1 and will be - clamped down to MAX_ORDER - 1. + Note that the pageblock_order cannot exceed MAX_ORDER and will be + clamped down to MAX_ORDER.
Quoted 102 lines
mm/compaction.c +4
-4@@ -583,7 +583,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,if (PageCompound (page)) {const unsigned int order =compound_order (page); -if (likely (order <MAX_ORDER )) { +if (likely (order <=MAX_ORDER )) { blockpfn += (1UL << order) -1 ; cursor += (1UL << order) -1 ; }@@ -938,7 +938,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,* a valid page order. Consider only values in the * valid order range to prevent low_pfn overflow. */ -if (freepage_order >0 && freepage_order <MAX_ORDER ) +if (freepage_order >0 && freepage_order <=MAX_ORDER ) low_pfn += (1UL << freepage_order) -1 ;continue ; }@@ -954,7 +954,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,if (PageCompound (page) && !cc->alloc_contig) {const unsigned int order =compound_order (page); -if (likely (order <MAX_ORDER )) +if (likely (order <=MAX_ORDER )) low_pfn += (1UL << order) -1 ; goto isolate_fail; }@@ -2124,7 +2124,7 @@ static enum compact_result __compact_finished(struct compact_control *cc)/* Direct compactor: Is a suitable page free? */ ret =COMPACT_NO_SUITABLE_PAGE ; -for (order = cc->order; order <MAX_ORDER ; order++) { +for (order = cc->order; order <=MAX_ORDER ; order++) {struct free_area *area = &cc->zone->free_area[order];bool can_steal;mm/debug_vm_pgtable.c +2
-2@@ -1086,7 +1086,7 @@ debug_vm_pgtable_alloc_huge_page(struct pgtable_debug_args *args, int order)struct page *page =NULL ;#ifdef CONFIG_CONTIG_ALLOC -if (order >=MAX_ORDER ) { +if (order >MAX_ORDER ) { page =alloc_contig_pages ((1 << order),GFP_KERNEL , first_online_node,NULL );if (page) {@@ -1096,7 +1096,7 @@ debug_vm_pgtable_alloc_huge_page(struct pgtable_debug_args *args, int order) }#endif -if (order <MAX_ORDER ) +if (order <=MAX_ORDER ) page =alloc_pages (GFP_KERNEL , order);return page;mm/huge_memory.c +1
-1@@ -471,7 +471,7 @@ static int __init hugepage_init(void)/* * hugepages can't be allocated by the buddy allocator */ -MAYBE_BUILD_BUG_ON (HPAGE_PMD_ORDER >=MAX_ORDER ); +MAYBE_BUILD_BUG_ON (HPAGE_PMD_ORDER >MAX_ORDER );/* * we use page->mapping and page->index in second tail page * as list_head: assuming THP order >= 2 mm/hugetlb.c +2
-2@@ -2090,7 +2090,7 @@ pgoff_t hugetlb_basepage_index(struct page *page)pgoff_t index =page_index (page_head);unsigned long compound_idx; -if (compound_order (page_head) >=MAX_ORDER ) +if (compound_order (page_head) >MAX_ORDER ) compound_idx =page_to_pfn (page) -page_to_pfn (page_head);else compound_idx = page - page_head;@@ -4497,7 +4497,7 @@ static int __init default_hugepagesz_setup(char *s)* The number of default huge pages (for this size) could have been * specified as the first hugetlb parameter: hugepages=X. If so, * then default_hstate_max_huge_pages is set. If the default huge -* page size is gigantic (>= MAX_ORDER), then the pages must be +* page size is gigantic (> MAX_ORDER), then the pages must be * allocated here from bootmem allocator. */ if (default_hstate_max_huge_pages) {mm/kmsan/init.c +0
-0
mm/kmsan/init.c void __init kmsan_init_shadow(void) · line 102
Quoted 8 lines
mm/kmsan/init.c +1
-1@@ -96,7 +96,7 @@ void __init kmsan_init_shadow(void)struct metadata_page_pair {struct page *shadow, *origin; }; -static struct metadata_page_pair held_back[MAX_ORDER ]__initdata ; +static struct metadata_page_pair held_back[MAX_ORDER +1 ]__initdata ;/* * Eager metadata allocation. When the memblock allocator is freeing pages to
line 144: this one I am not sure if the original code is wrong or not.
- .order = MAX_ORDER,
+ .order = MAX_ORDER + 1,
Quoted 16 lines
mm/kmsan/init.c +2
-2@@ -211,8 +211,8 @@ static void kmsan_memblock_discard(void)* order=N-1, * - repeat. */ - collect.order =MAX_ORDER -1 ; -for (int i =MAX_ORDER -1 ; i >=0 ; i--) { + collect.order =MAX_ORDER ; +for (int i =MAX_ORDER ; i >=0 ; i--) {if (held_back[i].shadow)smallstack_push (&collect, held_back[i].shadow);if (held_back[i].origin)mm/memblock.c +0
-0
mm/memblock.c static void __init __free_pages_memory(unsigned long start, unsigned long end) · line 2046
Quoted 5 lines
mm/memblock.c +1
-1@@ -2043,7 +2043,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)int order;while (start < end) { - order =min (MAX_ORDER -1UL ,__ffs (start)); + order =min (MAX_ORDER ,__ffs (start));
while you are here, maybe using min_t is better.
order = min_t(unsigned long, MAX_ORDER, __ffs(start));
Quoted 17 lines
mm/memblock.c +0
-0while (start + (1UL << order) > end) order--;mm/memory_hotplug.c +1
-1@@ -596,7 +596,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)unsigned long pfn;/* -* Online the pages in MAX_ORDER - 1 aligned chunks. The callback might +* Online the pages in MAX_ORDER aligned chunks. The callback might * decide to not expose all pages to the buddy (e.g., expose them * later). We account all pages as being online and belonging to this * zone ("present").
mm/memory_hotplug.c static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages) · line 608
Quoted 5 lines
mm/memory_hotplug.c +1
-1@@ -605,7 +605,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)* this and the first chunk to online will be pageblock_nr_pages. */ for (pfn = start_pfn; pfn < end_pfn;) { -int order =min (MAX_ORDER -1UL ,__ffs (pfn)); +int order =min (MAX_ORDER ,__ffs (pfn));
ditto
int order = min_t(unsigned long, MAX_ORDER, __ffs(pfn));
mm/page_alloc.c
Quoted 7 lines
mm/memory_hotplug.c +0
-0(*online_page_callback)(pfn_to_page (pfn), order); pfn += (1UL << order);mm/page_alloc.c +0
-0
line 842: it might make a difference when MAX_ORDER is odd.
- if (kstrtoul(buf, 10, &res) < 0 || res > MAX_ORDER / 2) {
+ if (kstrtoul(buf, 10, &res) < 0 || res > (MAX_ORDER + 1) / 2) {Quoted 314 lines
mm/page_alloc.c +19
-19@@ -1059,7 +1059,7 @@ buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn,unsigned long higher_page_pfn;struct page *higher_page; -if (order >=MAX_ORDER -2 ) +if (order >=MAX_ORDER -1 )return false; higher_page_pfn = buddy_pfn & pfn;@@ -1114,7 +1114,7 @@ static inline void __free_one_page(struct page *page,VM_BUG_ON_PAGE (pfn & ((1 << order) -1 ), page);VM_BUG_ON_PAGE (bad_range (zone, page), page); -while (order <MAX_ORDER -1 ) { +while (order <MAX_ORDER ) {if (compaction_capture (capc, page, order, migratetype)) {__mod_zone_freepage_state (zone, -(1 << order), migratetype);@@ -2579,7 +2579,7 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order,struct page *page;/* Find a page of the appropriate size in the preferred list */ -for (current_order = order; current_order <MAX_ORDER ; ++current_order) { +for (current_order = order; current_order <=MAX_ORDER ; ++current_order) { area = &(zone->free_area[current_order]); page =get_page_from_free_area (area, migratetype);if (!page)@@ -2951,7 +2951,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,continue ;spin_lock_irqsave (&zone->lock, flags); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {struct free_area *area = &(zone->free_area[order]); page =get_page_from_free_area (area,MIGRATE_HIGHATOMIC );@@ -3035,7 +3035,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype,* approximates finding the pageblock with the most free pages, which * would be too costly to do exactly. */ -for (current_order =MAX_ORDER -1 ; current_order >= min_order; +for (current_order =MAX_ORDER ; current_order >= min_order; --current_order) { area = &(zone->free_area[current_order]); fallback_mt = find_suitable_fallback(area, current_order,@@ -3061,7 +3061,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype,return false; find_smallest: -for (current_order = order; current_order <MAX_ORDER ; +for (current_order = order; current_order <=MAX_ORDER ; current_order++) { area = &(zone->free_area[current_order]); fallback_mt = find_suitable_fallback(area, current_order,@@ -3074,7 +3074,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype,* This should not happen - we already found a suitable fallback * when looking for the largest page. */ -VM_BUG_ON (current_order ==MAX_ORDER ); +VM_BUG_ON (current_order >MAX_ORDER ); do_steal: page =get_page_from_free_area (area, fallback_mt);@@ -4044,7 +4044,7 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,return true;/* For a high-order request, check at least one suitable page is free */ -for (o = order; o <MAX_ORDER ; o++) { +for (o = order; o <=MAX_ORDER ; o++) {struct free_area *area = &z->free_area[o];int mt;@@ -5564,7 +5564,7 @@ struct page *__alloc_pages(gfp_t gfp, unsigned int order, int preferred_nid,* There are several places where we assume that the order value is sane * so bail out early if the request is out of bound. */ -if (WARN_ON_ONCE_GFP (order >=MAX_ORDER , gfp)) +if (WARN_ON_ONCE_GFP (order >MAX_ORDER , gfp))return NULL ; gfp &= gfp_allowed_mask;@@ -6294,8 +6294,8 @@ void __show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_ifor_each_populated_zone (zone) {unsigned int order; -unsigned long nr[MAX_ORDER ], flags, total =0 ; -unsigned char types[MAX_ORDER ]; +unsigned long nr[MAX_ORDER +1 ], flags, total =0 ; +unsigned char types[MAX_ORDER +1 ];if (zone_idx (zone) > max_zone_idx)continue ;@@ -6305,7 +6305,7 @@ void __show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_iprintk (KERN_CONT "%s: " , zone->name);spin_lock_irqsave (&zone->lock, flags); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {struct free_area *area = &zone->free_area[order];int type;@@ -6319,7 +6319,7 @@ void __show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_i } }spin_unlock_irqrestore (&zone->lock, flags); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {printk (KERN_CONT "%lu*%lukB " , nr[order],K (1UL ) << order);if (nr[order])@@ -7670,7 +7670,7 @@ static inline void setup_usemap(struct zone *zone) {}/* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ void __init set_pageblock_order (void ) { -unsigned int order =MAX_ORDER -1 ; +unsigned int order =MAX_ORDER ;/* Check that pageblock_nr_pages has not already been setup */ if (pageblock_order)@@ -9165,7 +9165,7 @@ void *__init alloc_large_system_hash(const char *tablename,else table =memblock_alloc_raw (size,SMP_CACHE_BYTES ); - }else if (get_order (size) >=MAX_ORDER || hashdist) { + }else if (get_order (size) >MAX_ORDER || hashdist) { table =vmalloc_huge (size, gfp_flags); virt = true;if (table)@@ -9379,7 +9379,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, order =0 ; outer_start = start;while (!PageBuddy (pfn_to_page (outer_start))) { -if (++order >=MAX_ORDER ) { +if (++order >MAX_ORDER ) { outer_start = start;break ; }@@ -9629,7 +9629,7 @@ bool is_free_buddy_page(struct page *page)unsigned long pfn =page_to_pfn (page);unsigned int order; -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {struct page *page_head = page - (pfn & ((1 << order) -1 )); if (PageBuddy(page_head) &&@@ -9637,7 +9637,7 @@ bool is_free_buddy_page(struct page *page)break ; } -return order <MAX_ORDER ; +return order <=MAX_ORDER ; }EXPORT_SYMBOL (is_free_buddy_page);@@ -9688,7 +9688,7 @@ bool take_page_off_buddy(struct page *page)bool ret = false;spin_lock_irqsave (&zone->lock, flags); -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {struct page *page_head = page - (pfn & ((1 << order) -1 ));int page_order =buddy_order (page_head);mm/page_isolation.c +6
-6@@ -226,7 +226,7 @@ static void unset_migratetype_isolate(struct page *page, int migratetype)*/ if (PageBuddy (page)) { order =buddy_order (page); -if (order >= pageblock_order && order <MAX_ORDER -1 ) { +if (order >= pageblock_order && order <MAX_ORDER ) { buddy =find_buddy_page_pfn (page,page_to_pfn (page), order,NULL );if (buddy && !is_migrate_isolate_page (buddy)) {@@ -290,11 +290,11 @@ __first_valid_page(unsigned long pfn, unsigned long nr_pages)* isolate_single_pageblock() * @migratetype: migrate type to set in error recovery. * -* Free and in-use pages can be as big as MAX_ORDER-1 and contain more than one +* Free and in-use pages can be as big as MAX_ORDER and contain more than one * pageblock. When not all pageblocks within a page are isolated at the same * time, free page accounting can go wrong. For example, in the case of -* MAX_ORDER-1 = pageblock_order + 1, a MAX_ORDER-1 page has two pagelbocks. -* [ MAX_ORDER-1 ] +* MAX_ORDER = pageblock_order + 1, a MAX_ORDER page has two pagelbocks. +* [ MAX_ORDER ] * [ pageblock0 | pageblock1 ] * When either pageblock is isolated, if it is a free page, the page is not * split into separate migratetype lists, which is supposed to; if it is an @@ -451,7 +451,7 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags,* the free page to the right migratetype list. * * head_pfn is not used here as a hugetlb page order -* can be bigger than MAX_ORDER-1, but after it is +* can be bigger than MAX_ORDER, but after it is * freed, the free page order is not. Use pfn within * the range to find the head of the free page. */ @@ -459,7 +459,7 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, outer_pfn = pfn;while (!PageBuddy (pfn_to_page (outer_pfn))) {/* stop if we cannot find the free page */ -if (++order >=MAX_ORDER ) +if (++order >MAX_ORDER ) goto failed; outer_pfn &= ~0UL << order; }mm/page_owner.c +3
-3@@ -315,7 +315,7 @@ void pagetypeinfo_showmixedcount_print(struct seq_file *m,unsigned long freepage_order; freepage_order =buddy_order_unsafe (page); -if (freepage_order <MAX_ORDER ) +if (freepage_order <=MAX_ORDER ) pfn += (1UL << freepage_order) -1 ;continue ; }@@ -549,7 +549,7 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)if (PageBuddy (page)) {unsigned long freepage_order =buddy_order_unsafe (page); -if (freepage_order <MAX_ORDER ) +if (freepage_order <=MAX_ORDER ) pfn += (1UL << freepage_order) -1 ;continue ; }@@ -657,7 +657,7 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)if (PageBuddy (page)) {unsigned long order =buddy_order_unsafe (page); -if (order >0 && order <MAX_ORDER ) +if (order >0 && order <=MAX_ORDER ) pfn += (1UL << order) -1 ;continue ; }mm/page_reporting.c +3
-3@@ -20,7 +20,7 @@ static int page_order_update_notify(const char *val, const struct kernel_param ** If param is set beyond this limit, order is set to default * pageblock_order value */ -return param_set_uint_minmax (val, kp,0 ,MAX_ORDER -1 ); +return param_set_uint_minmax (val, kp,0 ,MAX_ORDER ); }static const struct kernel_param_ops page_reporting_param_ops = {@@ -276,7 +276,7 @@ page_reporting_process_zone(struct page_reporting_dev_info *prdev,return err;/* Process each free list starting from lowest order/mt */ -for (order = page_reporting_order; order <MAX_ORDER ; order++) { +for (order = page_reporting_order; order <=MAX_ORDER ; order++) {for (mt =0 ; mt <MIGRATE_TYPES ; mt++) {/* We do not pull pages from the isolate free list */ if (is_migrate_isolate (mt))@@ -370,7 +370,7 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)*/ if (page_reporting_order ==-1 ) { -if (prdev->order >0 && prdev->order <MAX_ORDER ) +if (prdev->order >0 && prdev->order <=MAX_ORDER ) page_reporting_order = prdev->order;else page_reporting_order = pageblock_order;mm/shuffle.h +1
-1@@ -4,7 +4,7 @@#define _MM_SHUFFLE_H#include <linux/jump_label.h> -#define SHUFFLE_ORDER (MAX_ORDER-1) +#define SHUFFLE_ORDER MAX_ORDER#ifdef CONFIG_SHUFFLE_PAGE_ALLOCATOR DECLARE_STATIC_KEY_FALSE (page_alloc_shuffle_key);mm/slab.c +1
-1@@ -465,7 +465,7 @@ static int __init slab_max_order_setup(char *str) {get_option (&str, &slab_max_order); slab_max_order = slab_max_order <0 ?0 : -min (slab_max_order,MAX_ORDER -1 ); +min (slab_max_order,MAX_ORDER ); slab_max_order_set = true;return 1 ;mm/slub.c +2
-2@@ -4171,8 +4171,8 @@ static inline int calculate_order(unsigned int size)/* * Doh this slab cannot be placed using slub_max_order. */ - order =calc_slab_order (size,1 ,MAX_ORDER -1 ,1 ); -if (order <MAX_ORDER ) + order =calc_slab_order (size,1 ,MAX_ORDER ,1 ); +if (order <=MAX_ORDER )return order;return -ENOSYS ; }
mm/slub.c __setup("slub_min_order=", setup_slub_min_order); · line 4700
Quoted 5 lines
mm/slub.c +1
-1@@ -4697,7 +4697,7 @@ __setup("slub_min_order=", setup_slub_min_order);static int __init setup_slub_max_order (char *str) {get_option (&str, (int *)&slub_max_order); - slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER -1 ); + slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER );
maybe min_t is better?
slub_max_order = min_t(unsigned int, slub_max_order, MAX_ORDER);
Quoted 129 lines
mm/slub.c +0
-0return 1 ; }mm/vmscan.c +1
-1@@ -6990,7 +6990,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,* scan_control uses s8 fields for order, priority, and reclaim_idx. * Confirm they are large enough for max values. */ -BUILD_BUG_ON (MAX_ORDER >S8_MAX ); +BUILD_BUG_ON (MAX_ORDER >=S8_MAX );BUILD_BUG_ON (DEF_PRIORITY >S8_MAX );BUILD_BUG_ON (MAX_NR_ZONES >S8_MAX );mm/vmstat.c +7
-7@@ -1055,7 +1055,7 @@ static void fill_contig_page_info(struct zone *zone, info->free_blocks_total =0 ; info->free_blocks_suitable =0 ; -for (order =0 ; order <MAX_ORDER ; order++) { +for (order =0 ; order <=MAX_ORDER ; order++) {unsigned long blocks;/* @@ -1088,7 +1088,7 @@ static int __fragmentation_index(unsigned int order, struct contig_page_info *in {unsigned long requested =1UL << order; -if (WARN_ON_ONCE (order >=MAX_ORDER )) +if (WARN_ON_ONCE (order >MAX_ORDER ))return 0 ;if (!info->free_blocks_total)@@ -1462,7 +1462,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,int order;seq_printf (m,"Node %d, zone %8s " , pgdat->node_id, zone->name); -for (order =0 ; order <MAX_ORDER ; ++order) +for (order =0 ; order <=MAX_ORDER ; ++order)/* * Access to nr_free is lockless as nr_free is used only for * printing purposes. Use data_race to avoid KCSAN warning. @@ -1491,7 +1491,7 @@ static void pagetypeinfo_showfree_print(struct seq_file *m, pgdat->node_id, zone->name, migratetype_names[mtype]); -for (order =0 ; order <MAX_ORDER ; ++order) { +for (order =0 ; order <=MAX_ORDER ; ++order) {unsigned long freecount =0 ;struct free_area *area;struct list_head *curr;@@ -1531,7 +1531,7 @@ static void pagetypeinfo_showfree(struct seq_file *m, void *arg)/* Print header */ seq_printf (m,"%-43s " ,"Free pages count per migrate type at order" ); -for (order =0 ; order <MAX_ORDER ; ++order) +for (order =0 ; order <=MAX_ORDER ; ++order)seq_printf (m,"%6d " , order);seq_putc (m,'\n' );@@ -2153,7 +2153,7 @@ static void unusable_show_print(struct seq_file *m,seq_printf (m,"Node %d, zone %8s " , pgdat->node_id, zone->name); -for (order =0 ; order <MAX_ORDER ; ++order) { +for (order =0 ; order <=MAX_ORDER ; ++order) {fill_contig_page_info (zone, order, &info); index =unusable_free_index (order, &info);seq_printf (m,"%d.%03d " , index /1000 , index %1000 );@@ -2205,7 +2205,7 @@ static void extfrag_show_print(struct seq_file *m,seq_printf (m,"Node %d, zone %8s " , pgdat->node_id, zone->name); -for (order =0 ; order <MAX_ORDER ; ++order) { +for (order =0 ; order <=MAX_ORDER ; ++order) {fill_contig_page_info (zone, order, &info); index =__fragmentation_index (order, &info);seq_printf (m,"%2d.%03d " , index /1000 , index %1000 );net/smc/smc_ib.c +1
-1@@ -843,7 +843,7 @@ long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev) goto out;/* the calculated number of cq entries fits to mlx5 cq allocation */ cqe_size_order =cache_line_size () ==128 ?7 :6 ; - smc_order =MAX_ORDER - cqe_size_order -1 ; + smc_order =MAX_ORDER - cqe_size_order;if (SMC_MAX_CQE +2 > (0x00000001 << smc_order) *PAGE_SIZE ) cqattr.cqe = (0x00000001 << smc_order) *PAGE_SIZE -2 ; smcibdev->roce_cq_send = ib_create_cq(smcibdev->ibdev,security/integrity/ima/ima_crypto.c +1
-1@@ -38,7 +38,7 @@ static int param_set_bufsize(const char *val, const struct kernel_param *kp) size =memparse (val,NULL ); order =get_order (size); -if (order >=MAX_ORDER ) +if (order >MAX_ORDER )return -EINVAL ; ima_maxorder = order; ima_bufsize =PAGE_SIZE << order;tools/testing/memblock/linux/mmzone.h +3
-3@@ -17,10 +17,10 @@ enum zone_type { };#define MAX_NR_ZONES __MAX_NR_ZONES -#define MAX_ORDER 11 -#define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1)) +#define MAX_ORDER 10 +#define MAX_ORDER_NR_PAGES (1 << MAX_ORDER) -#define pageblock_order (MAX_ORDER - 1) +#define pageblock_order MAX_ORDER#define pageblock_nr_pages BIT(pageblock_order)#define pageblock_align (pfn) ALIGN((pfn), pageblock_nr_pages)#define pageblock_start_pfn (pfn) ALIGN_DOWN((pfn), pageblock_nr_pages)Signature · 1 line
2.39.2
The changes look good to me. I added some missing changes inline, although the line number might not be exact. Feel free to add Reviewed-by: Zi Yan <[email protected]>.
Do you think it is worth adding a MAX_ORDER check in checkpatch.pl to warn people the meaning of MAX_ORDER has changed? Something like:
# check for MAX_ORDER uses as its semantics has changed.
# MAX_ORDER now really means the max order of a page that can come out of
# kernel buddy allocator
if ($line =~ /MAX_ORDER/) {
WARN("MAX_ORDER",
"MAX_ORDER has changed its semantics. The max order of a page that can be allocated from buddy allocator is MAX_ORDER instead of MAX_ORDER - 1.")
}Thanks.
--
Best Regards,
Yan, Zi
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
Quoted 12 lines · Zi Yan
Quoted 12 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +1
-1@@ -172,7 +172,7 @@ variables. Offset of the free_list's member. This value is used to compute the number of free pages. -Each zone has a free_area structure array called free_area[MAX_ORDER]. +Each zone has a free_area structure array called free_area[MAX_ORDER + 1]. The free_list represents a linked list of free page blocks.
Quoted 6 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst variables. · line 178
Quoted 1 line
Documentation/admin-guide/kdump/vmcoreinfo.rst +0
-0(list_head, next|prev)In
vmcoreinfo.rst, line 192:- (zone.free_area,
MAX_ORDER)
+ (zone.free_area,MAX_ORDER+ 1)
Okay.
Quoted 16 lines
Documentation/admin-guide/kernel-parameters.txt line 3975
Quoted 13 lines
Documentation/admin-guide/kernel-parameters.txt +1
-1@@ -3969,7 +3969,7 @@ [KNL] Minimal page reporting order Format: <integer> Adjust the minimal page reporting order. The page - reporting is disabled when it exceeds (MAX_ORDER-1). + reporting is disabled when it exceeds MAX_ORDER. panic= [KNL] Kernel behaviour on panic: delay <timeout> timeout > 0: seconds before rebootingline 942:
Review
Quoted 2 lines
(quoted diff) +1
-1- possible value is MAX_ORDER/2. Setting this parameter + possible value is (MAX_ORDER + 1)/2. Setting this parameter
I don't think it worth it. See below, on the relevant code change.
Quoted 18 lines
Quoted 5 lines
kernel/events/ring_buffer.c +0
-0kernel/events/ring_buffer.c static struct page *rb_alloc_aux_page(int node, int order) · line 616
Quoted 10 lines
kernel/events/ring_buffer.c +2
-2@@ -609,8 +609,8 @@ static struct page *rb_alloc_aux_page(int node, int order) {struct page *page; -if (order >=MAX_ORDER ) - order =MAX_ORDER -1 ; +if (order >MAX_ORDER ) + order =MAX_ORDER ; do { page = alloc_pages_node(node, PERF_AUX_GFP, order);line 817:
Review
Quoted 2 lines
(quoted diff) +1
-1- if (order_base_2(size) >= PAGE_SHIFT+MAX_ORDER) + if (order_base_2(size) > PAGE_SHIFT+MAX_ORDER)
Right.
Quoted 21 lines
Quoted 7 lines
mm/Kconfig +0
-0@@ -346,9 +346,9 @@ config SHUFFLE_PAGE_ALLOCATOR the presence of a memory-side-cache. There are also incidental security benefits as it reduces the predictability of pagemm/Kconfig config SHUFFLE_PAGE_ALLOCATOR · line 354
Quoted 10 lines
mm/Kconfig +3
-3allocations to compliment SLAB_FREELIST_RANDOM, but the - default granularity of shuffling on the "MAX_ORDER - 1" i.e, - 10th order of pages is selected based on cache utilization - benefits on x86. + default granularity of shuffling on the MAX_ORDER i.e, 10th + order of pages is selected based on cache utilization benefits + on x86. While the randomization improves cache utilization it may negatively impact workloads on platforms without a cache. Forline 669:
Review
Quoted 4 lines
(quoted diff) +2
-2- Note that the pageblock_order cannot exceed MAX_ORDER - 1 and will be - clamped down to MAX_ORDER - 1. + Note that the pageblock_order cannot exceed MAX_ORDER and will be + clamped down to MAX_ORDER.
Okay. Missed that.
Quoted 16 lines
mm/kmsan/init.c void __init kmsan_init_shadow(void) · line 102
Quoted 13 lines
mm/kmsan/init.c +1
-1@@ -96,7 +96,7 @@ void __init kmsan_init_shadow(void)struct metadata_page_pair {struct page *shadow, *origin; }; -static struct metadata_page_pair held_back[MAX_ORDER ]__initdata ; +static struct metadata_page_pair held_back[MAX_ORDER +1 ]__initdata ;/* * Eager metadata allocation. When the memblock allocator is freeing pages to line 144: this one I am not sure if the original code is wrong or not.
Review
Quoted 2 lines
(quoted diff) +1
-1- .order = MAX_ORDER, + .order = MAX_ORDER + 1,
I think the original code is wrong, but the initialization seems unused:
it got overridden in kmsan_memblock_discard() before the first use.
Quoted 18 lines
Quoted 18 lines
mm/kmsan/init.c +2
-2@@ -211,8 +211,8 @@ static void kmsan_memblock_discard(void)* order=N-1, * - repeat. */ - collect.order =MAX_ORDER -1 ; -for (int i =MAX_ORDER -1 ; i >=0 ; i--) { + collect.order =MAX_ORDER ; +for (int i =MAX_ORDER ; i >=0 ; i--) {if (held_back[i].shadow)smallstack_push (&collect, held_back[i].shadow);if (held_back[i].origin)mm/memblock.c +0
-0@@ -2043,7 +2043,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)int order;
Quoted 7 lines
mm/memblock.c static void __init __free_pages_memory(unsigned long start, unsigned long end) · line 2046
Quoted 3 lines
mm/memblock.c +1
-1while (start < end) { - order =min (MAX_ORDER -1UL ,__ffs (start)); + order =min (MAX_ORDER ,__ffs (start));while you are here, maybe using
min_tis better.order =
min_t(unsigned long, MAX_ORDER, __ffs(start));
Already addressed by fixup.
Quoted 25 lines
Quoted 17 lines
mm/memblock.c +0
-0while (start + (1UL << order) > end) order--;mm/memory_hotplug.c +1
-1@@ -596,7 +596,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)unsigned long pfn;/* -* Online the pages in MAX_ORDER - 1 aligned chunks. The callback might +* Online the pages in MAX_ORDER aligned chunks. The callback might * decide to not expose all pages to the buddy (e.g., expose them * later). We account all pages as being online and belonging to this * zone ("present"). mm/memory_hotplug.c static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages) · line 608
Quoted 5 lines
mm/memory_hotplug.c +1
-1@@ -605,7 +605,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)* this and the first chunk to online will be pageblock_nr_pages. */ for (pfn = start_pfn; pfn < end_pfn;) { -int order =min (MAX_ORDER -1UL ,__ffs (pfn)); +int order =min (MAX_ORDER ,__ffs (pfn));ditto
Quoted 1 line
int order =
min_t(unsigned long, MAX_ORDER, __ffs(pfn));
Ditto.
Review
Quoted 12 lines
mm/page_alloc.c
Quoted 7 lines
mm/memory_hotplug.c +0
-0(*online_page_callback)(pfn_to_page (pfn), order); pfn += (1UL << order);mm/page_alloc.c +0
-0line 842: it might make a difference when
MAX_ORDERis odd.(quoted diff) +1
-1- if (kstrtoul(buf, 10, &res) < 0 || res > MAX_ORDER / 2) { + if (kstrtoul(buf, 10, &res) < 0 || res > (MAX_ORDER + 1) / 2) {
I don't think it worth the complication: the upper limit here is pretty arbitrary and +1 doesn't really make a difference. I would rather keep it simple.
Quoted 24 lines
Quoted 16 lines
mm/slub.c +2
-2@@ -4171,8 +4171,8 @@ static inline int calculate_order(unsigned int size)/* * Doh this slab cannot be placed using slub_max_order. */ - order =calc_slab_order (size,1 ,MAX_ORDER -1 ,1 ); -if (order <MAX_ORDER ) + order =calc_slab_order (size,1 ,MAX_ORDER ,1 ); +if (order <=MAX_ORDER )return order;return -ENOSYS ; }mm/slub.c __setup("slub_min_order=", setup_slub_min_order); · line 4700
Quoted 5 lines
mm/slub.c +1
-1@@ -4697,7 +4697,7 @@ __setup("slub_min_order=", setup_slub_min_order);static int __init setup_slub_max_order (char *str) {get_option (&str, (int *)&slub_max_order); - slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER -1 ); + slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER );maybe
min_tis better?
Quoted 1 line
slub_max_order=min_t(unsigned int, slub_max_order, MAX_ORDER);
Fair enough.
...
Quoted 6 lines
The changes look good to me. I added some missing changes inline, although the line number might not be exact. Feel free to add Reviewed-by: Zi Yan <[email protected]>.
Do you think it is worth adding a
MAX_ORDERcheck in checkpatch.pl to warn people the meaning ofMAX_ORDERhas changed? Something like:
Quoted 8 lines
# check for MAX_ORDER uses as its semantics has changed.
# MAX_ORDER now really means the max order of a page that can come out of
# kernel buddy allocator
if ($line =~ /MAX_ORDER/) {
WARN("MAX_ORDER",
"MAX_ORDER has changed its semantics. The max order of a page that can be allocated from buddy allocator is MAX_ORDER instead of MAX_ORDER - 1.")
}We can add, if you think it is helpful. I don't feel strongly about this.
Below is fixup I made based on your feedback:
Documentation/admin-guide/kdump/vmcoreinfo.rst +1 -1
@@ -189,7 +189,7 @@ Offsets of the vmap_area's members. They carry vmalloc-specific information. Makedumpfile gets the start address of the vmalloc region from this. -(zone.free_area, MAX_ORDER) +(zone.free_area, MAX_ORDER + 1) --------------------------- Free areas descriptor. User-space tools use this value to iterate the
kernel/events/ring_buffer.c +1 -1
@@ -814,7 +814,7 @@ struct perf_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags) size =sizeof (struct perf_buffer ); size += nr_pages *sizeof (void *); -if (order_base_2 (size) >=PAGE_SHIFT +MAX_ORDER ) +if (order_base_2 (size) >PAGE_SHIFT +MAX_ORDER ) goto fail; node = (cpu ==-1 ) ? cpu :cpu_to_node (cpu);
mm/Kconfig +2 -2
@@ -666,8 +666,8 @@ config HUGETLB_PAGE_SIZE_VARIABLE HUGETLB_PAGE_ORDER when there are multiple HugeTLB page sizes available on a platform. - Note that the pageblock_order cannot exceed MAX_ORDER - 1 and will be - clamped down to MAX_ORDER - 1. + Note that the pageblock_order cannot exceed MAX_ORDER and will be + clamped down to MAX_ORDER. config CONTIG_ALLOC def_bool (MEMORY_ISOLATION && COMPACTION) || CMA
mm/slub.c +1 -1
@@ -4697,7 +4697,7 @@ __setup("slub_min_order=", setup_slub_min_order);static int __init setup_slub_max_order (char *str) {get_option (&str, (int *)&slub_max_order); - slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER ); + slub_max_order = min_t(unsigned int, slub_max_order, MAX_ORDER);return 1 ; }
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Zi Yan
reviewerRe: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
Quoted 295 lines · Kirill A. Shutemov
Quoted 12 lines · Zi Yan
Quoted 12 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +1
-1@@ -172,7 +172,7 @@ variables. Offset of the free_list's member. This value is used to compute the number of free pages. -Each zone has a free_area structure array called free_area[MAX_ORDER]. +Each zone has a free_area structure array called free_area[MAX_ORDER + 1]. The free_list represents a linked list of free page blocks.Quoted 6 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst variables. · line 178
Quoted 1 line
Documentation/admin-guide/kdump/vmcoreinfo.rst +0
-0(list_head, next|prev)In
vmcoreinfo.rst, line 192:- (zone.free_area,
MAX_ORDER)
+ (zone.free_area,MAX_ORDER+ 1)Okay.
Quoted 16 lines
Documentation/admin-guide/kernel-parameters.txt line 3975
Quoted 13 lines
Documentation/admin-guide/kernel-parameters.txt +1
-1@@ -3969,7 +3969,7 @@ [KNL] Minimal page reporting order Format: <integer> Adjust the minimal page reporting order. The page - reporting is disabled when it exceeds (MAX_ORDER-1). + reporting is disabled when it exceeds MAX_ORDER. panic= [KNL] Kernel behaviour on panic: delay <timeout> timeout > 0: seconds before rebootingline 942:
Review
Quoted 2 lines
(quoted diff) +1
-1- possible value is MAX_ORDER/2. Setting this parameter + possible value is (MAX_ORDER + 1)/2. Setting this parameterI don't think it worth it. See below, on the relevant code change.
Quoted 18 lines
Quoted 5 lines
kernel/events/ring_buffer.c +0
-0kernel/events/ring_buffer.c static struct page *rb_alloc_aux_page(int node, int order) · line 616
Quoted 10 lines
kernel/events/ring_buffer.c +2
-2@@ -609,8 +609,8 @@ static struct page *rb_alloc_aux_page(int node, int order) {struct page *page; -if (order >=MAX_ORDER ) - order =MAX_ORDER -1 ; +if (order >MAX_ORDER ) + order =MAX_ORDER ; do { page = alloc_pages_node(node, PERF_AUX_GFP, order);line 817:
kernel/events/ring_buffer.c struct perf_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags) · line 817
Quoted 2 lines
kernel/events/ring_buffer.c +1
-1-if (order_base_2 (size) >=PAGE_SHIFT +MAX_ORDER ) +if (order_base_2 (size) >PAGE_SHIFT +MAX_ORDER )Right.
Quoted 21 lines
Quoted 7 lines
mm/Kconfig +0
-0@@ -346,9 +346,9 @@ config SHUFFLE_PAGE_ALLOCATOR the presence of a memory-side-cache. There are also incidental security benefits as it reduces the predictability of pagemm/Kconfig config SHUFFLE_PAGE_ALLOCATOR · line 354
Quoted 10 lines
mm/Kconfig +3
-3allocations to compliment SLAB_FREELIST_RANDOM, but the - default granularity of shuffling on the "MAX_ORDER - 1" i.e, - 10th order of pages is selected based on cache utilization - benefits on x86. + default granularity of shuffling on the MAX_ORDER i.e, 10th + order of pages is selected based on cache utilization benefits + on x86. While the randomization improves cache utilization it may negatively impact workloads on platforms without a cache. Forline 669:
mm/Kconfig config HUGETLB_PAGE_SIZE_VARIABLE · line 670
Quoted 4 lines
mm/Kconfig +2
-2- Note that the pageblock_order cannot exceed MAX_ORDER - 1 and will be - clamped down to MAX_ORDER - 1. + Note that the pageblock_order cannot exceed MAX_ORDER and will be + clamped down to MAX_ORDER.Okay. Missed that.
Quoted 16 lines
mm/kmsan/init.c void __init kmsan_init_shadow(void) · line 102
Quoted 13 lines
mm/kmsan/init.c +1
-1@@ -96,7 +96,7 @@ void __init kmsan_init_shadow(void)struct metadata_page_pair {struct page *shadow, *origin; }; -static struct metadata_page_pair held_back[MAX_ORDER ]__initdata ; +static struct metadata_page_pair held_back[MAX_ORDER +1 ]__initdata ;/* * Eager metadata allocation. When the memblock allocator is freeing pages to line 144: this one I am not sure if the original code is wrong or not.
Review
Quoted 2 lines
(quoted diff) +1
-1- .order = MAX_ORDER, + .order = MAX_ORDER + 1,I think the original code is wrong, but the initialization seems unused:
it got overridden inkmsan_memblock_discard()before the first use.Quoted 18 lines
Quoted 18 lines
mm/kmsan/init.c +2
-2@@ -211,8 +211,8 @@ static void kmsan_memblock_discard(void)* order=N-1, * - repeat. */ - collect.order =MAX_ORDER -1 ; -for (int i =MAX_ORDER -1 ; i >=0 ; i--) { + collect.order =MAX_ORDER ; +for (int i =MAX_ORDER ; i >=0 ; i--) {if (held_back[i].shadow)smallstack_push (&collect, held_back[i].shadow);if (held_back[i].origin)mm/memblock.c +0
-0@@ -2043,7 +2043,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)int order;Quoted 7 lines
mm/memblock.c static void __init __free_pages_memory(unsigned long start, unsigned long end) · line 2046
Quoted 3 lines
mm/memblock.c +1
-1while (start < end) { - order =min (MAX_ORDER -1UL ,__ffs (start)); + order =min (MAX_ORDER ,__ffs (start));while you are here, maybe using
min_tis better.order =
min_t(unsigned long, MAX_ORDER, __ffs(start));Already addressed by fixup.
Quoted 25 lines
Quoted 17 lines
mm/memblock.c +0
-0while (start + (1UL << order) > end) order--;mm/memory_hotplug.c +1
-1@@ -596,7 +596,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)unsigned long pfn;/* -* Online the pages in MAX_ORDER - 1 aligned chunks. The callback might +* Online the pages in MAX_ORDER aligned chunks. The callback might * decide to not expose all pages to the buddy (e.g., expose them * later). We account all pages as being online and belonging to this * zone ("present"). mm/memory_hotplug.c static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages) · line 608
Quoted 5 lines
mm/memory_hotplug.c +1
-1@@ -605,7 +605,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)* this and the first chunk to online will be pageblock_nr_pages. */ for (pfn = start_pfn; pfn < end_pfn;) { -int order =min (MAX_ORDER -1UL ,__ffs (pfn)); +int order =min (MAX_ORDER ,__ffs (pfn));ditto
Quoted 1 line
int order =
min_t(unsigned long, MAX_ORDER, __ffs(pfn));Ditto.
Review
Quoted 12 lines
mm/page_alloc.c
Quoted 7 lines
mm/memory_hotplug.c +0
-0(*online_page_callback)(pfn_to_page (pfn), order); pfn += (1UL << order);mm/page_alloc.c +0
-0line 842: it might make a difference when
MAX_ORDERis odd.(quoted diff) +1
-1- if (kstrtoul(buf, 10, &res) < 0 || res > MAX_ORDER / 2) { + if (kstrtoul(buf, 10, &res) < 0 || res > (MAX_ORDER + 1) / 2) {I don't think it worth the complication: the upper limit here is pretty arbitrary and +1 doesn't really make a difference. I would rather keep it simple.
Quoted 24 lines
Quoted 16 lines
mm/slub.c +2
-2@@ -4171,8 +4171,8 @@ static inline int calculate_order(unsigned int size)/* * Doh this slab cannot be placed using slub_max_order. */ - order =calc_slab_order (size,1 ,MAX_ORDER -1 ,1 ); -if (order <MAX_ORDER ) + order =calc_slab_order (size,1 ,MAX_ORDER ,1 ); +if (order <=MAX_ORDER )return order;return -ENOSYS ; }mm/slub.c __setup("slub_min_order=", setup_slub_min_order); · line 4700
Quoted 5 lines
mm/slub.c +1
-1@@ -4697,7 +4697,7 @@ __setup("slub_min_order=", setup_slub_min_order);static int __init setup_slub_max_order (char *str) {get_option (&str, (int *)&slub_max_order); - slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER -1 ); + slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER );maybe
min_tis better?Quoted 1 line
slub_max_order=min_t(unsigned int, slub_max_order, MAX_ORDER);Fair enough.
...
Quoted 6 lines
The changes look good to me. I added some missing changes inline, although the line number might not be exact. Feel free to add Reviewed-by: Zi Yan <[email protected]>.
Do you think it is worth adding a
MAX_ORDERcheck in checkpatch.pl to warn people the meaning ofMAX_ORDERhas changed? Something like:Quoted 8 lines
# check for MAX_ORDER uses as its semantics has changed. # MAX_ORDER now really means the max order of a page that can come out of # kernel buddy allocator if ($line =~ /MAX_ORDER/) { WARN("MAX_ORDER", "MAX_ORDER has changed its semantics. The max order of a page that can be allocated from buddy allocator is MAX_ORDER instead of MAX_ORDER - 1.") }We can add, if you think it is helpful. I don't feel strongly about this.
Below is fixup I made based on your feedback:
Documentation/admin-guide/kdump/vmcoreinfo.rst +1
-1@@ -189,7 +189,7 @@ Offsets of the vmap_area's members. They carry vmalloc-specific information. Makedumpfile gets the start address of the vmalloc region from this. -(zone.free_area, MAX_ORDER) +(zone.free_area, MAX_ORDER + 1) --------------------------- Free areas descriptor. User-space tools use this value to iterate thekernel/events/ring_buffer.c +1
-1@@ -814,7 +814,7 @@ struct perf_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags) size =sizeof (struct perf_buffer ); size += nr_pages *sizeof (void *); -if (order_base_2 (size) >=PAGE_SHIFT +MAX_ORDER ) +if (order_base_2 (size) >PAGE_SHIFT +MAX_ORDER ) goto fail; node = (cpu ==-1 ) ? cpu :cpu_to_node (cpu);mm/Kconfig +2
-2@@ -666,8 +666,8 @@ config HUGETLB_PAGE_SIZE_VARIABLE HUGETLB_PAGE_ORDER when there are multiple HugeTLB page sizes available on a platform. - Note that the pageblock_order cannot exceed MAX_ORDER - 1 and will be - clamped down to MAX_ORDER - 1. + Note that the pageblock_order cannot exceed MAX_ORDER and will be + clamped down to MAX_ORDER. config CONTIG_ALLOC def_bool (MEMORY_ISOLATION && COMPACTION) || CMAmm/slub.c +1
-1@@ -4697,7 +4697,7 @@ __setup("slub_min_order=", setup_slub_min_order);static int __init setup_slub_max_order (char *str) {get_option (&str, (int *)&slub_max_order); - slub_max_order =min (slub_max_order, (unsigned int )MAX_ORDER ); + slub_max_order = min_t(unsigned int, slub_max_order, MAX_ORDER);return 1 ; }Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
LGTM. Thanks. Reviewed-by: Zi Yan <[email protected]>
--
Best Regards,
Yan, Zi
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
In reply to Kirill A. ShutemovQuoted 12 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Change the definition of
MAX_ORDERto be inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.
arch/arc/Kconfig endmenu # "ARC Architecture Configuration" · line 560
Quoted 7 lines
arch/arc/Kconfig +2
-2@@ -556,7 +556,7 @@ endmenu # "ARC Architecture Configuration" config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "12" if ARC_HUGEPAGE_16M - default "11" + default "11" if ARC_HUGEPAGE_16M + default "10"
Is this Kconfig file wrong (off by 1) today? It seems like it wants MAX_ORDER to be sufficiently large to allocate 16M if ARC_HUGEPAGE_16M. So, seems like it should be 13 today?
Signature · 1 line
Mike Kravetz
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
Quoted 14 lines · Mike Kravetz
Quoted 13 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Change the definition of
MAX_ORDERto be inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.arch/arc/Kconfig +0
-0@@ -556,7 +556,7 @@ endmenu # "ARC Architecture Configuration"
Quoted 10 lines
arch/arc/Kconfig endmenu # "ARC Architecture Configuration" · line 560
Quoted 6 lines
arch/arc/Kconfig +2
-2config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "12" if ARC_HUGEPAGE_16M - default "11" + default "11" if ARC_HUGEPAGE_16M + default "10"Is this
Kconfigfile wrong (off by 1) today? It seems like it wantsMAX_ORDERto be sufficiently large to allocate 16M ifARC_HUGEPAGE_16M. So, seems like it should be 13 today?
Nevermind, PAGE_SIZE seems to be 8K by default although it appears to be configurable. Not exactly sure how the hard coded values above work if PAGE_SIZE is configurable. Too confusing for me to make an intelligent comment. Sorry for the noise.
Signature · 1 line
Mike Kravetz
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
In reply to Mike KravetzQuoted 14 lines · Mike Kravetz
Quoted 13 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Change the definition of
MAX_ORDERto be inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.arch/arc/Kconfig +0
-0@@ -556,7 +556,7 @@ endmenu # "ARC Architecture Configuration"
Quoted 10 lines
arch/arc/Kconfig endmenu # "ARC Architecture Configuration" · line 560
Quoted 6 lines
arch/arc/Kconfig +2
-2config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "12" if ARC_HUGEPAGE_16M - default "11" + default "11" if ARC_HUGEPAGE_16M + default "10"Is this
Kconfigfile wrong (off by 1) today? It seems like it wantsMAX_ORDERto be sufficiently large to allocate 16M ifARC_HUGEPAGE_16M. So, seems like it should be 13 today?
+Vineet.
Hm. I think it is okay as long as CONFIG_ARC_PAGE_SIZE_8K=y which is default, but breaks for other PAGE_SIZE.
Looks like ARCH_FORCE_MAX_ORDER calculation should involve selected page size.
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
Quoted 24 lines · Kirill A. Shutemov
Quoted 14 lines · Mike Kravetz
Quoted 13 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Change the definition of
MAX_ORDERto be inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.arch/arc/Kconfig +0
-0@@ -556,7 +556,7 @@ endmenu # "ARC Architecture Configuration"Quoted 9 lines
arch/arc/Kconfig endmenu # "ARC Architecture Configuration" · line 560
Quoted 6 lines
arch/arc/Kconfig +2
-2config ARCH_FORCE_MAX_ORDER int "Maximum zone order" - default "12" if ARC_HUGEPAGE_16M - default "11" + default "11" if ARC_HUGEPAGE_16M + default "10"Is this
Kconfigfile wrong (off by 1) today? It seems like it wantsMAX_ORDERto be sufficiently large to allocate 16M ifARC_HUGEPAGE_16M. So, seems like it should be 13 today?
Quoted 7 lines
+Vineet.
Hm. I think it is okay as long as
CONFIG_ARC_PAGE_SIZE_8K=ywhich is default, but breaks for otherPAGE_SIZE.Looks like
ARCH_FORCE_MAX_ORDERcalculation should involve selected page size.
Thats right 8K is default for ARC.
-Vineet
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
In reply to Kirill A. ShutemovQuoted 10 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Change the definition of
MAX_ORDERto be inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.Signed-off-by Kirill A. Shutemov <[email protected]>
With the fixups:
Re: [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely
In reply to Kirill A. ShutemovQuoted 11 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Change the definition of
MAX_ORDERto be inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.Signed-off-by Kirill A. Shutemov <[email protected]>---
...
Quoted 6 lines
arch/powerpc/Kconfig | 27 ++++++------- arch/powerpc/configs/85xx/ge_imp3a_defconfig | 2 +- arch/powerpc/configs/fsl-emb-nonhw.config | 2 +- arch/powerpc/mm/book3s64/iommu_api.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
cheers
Quoted 10 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Fix the bugs and then change the definition of
MAX_ORDERto be
inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.
Overall looks sane other than the fixups that need to be added as flagged by LKP. There is a mild risk for stable backports that reference MAX_ORDER but that's the responsibilty of who is doing the backport. There is a mild risk of muscle memory adding off-by-one errors for new code using MAX_ORDER but it's low.
Signature · 2 lines
Mel Gorman SUSE Labs
From: Mel Gorman
Quoted 14 lines
Sent: 21 March 2023 16:39
Quoted 10 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Fix the bugs and then change the definition of
MAX_ORDERto be
inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.
Quoted 7 lines
Acked-by Mel Gorman <[email protected]>Overall looks sane other than the fixups that need to be added as flagged by LKP. There is a mild risk for stable backports that reference
MAX_ORDERbut that's the responsibilty of who is doing the backport. There is a mild risk of muscle memory adding off-by-one errors for new code usingMAX_ORDERbut it's low.
How many of the places that use MAX_ORDER weren't touched? Is it actually worth changing the name at the same time. That will stop stable backport issues.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Quoted 9 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Fix the bugs and then change the definition of
MAX_ORDERto be
inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.
Looks like this crossed with three changes that introduced new uses of MAX_ORDER:
drivers/accel/qaic/qaic_data.c: max_order = min(MAX_ORDER - 1, get_order(size)); drivers/md/dm-crypt.c: unsigned int order = MAX_ORDER - 1; drivers/md/dm-flakey.c: order = MAX_ORDER - 1;
The bugs are all benign, MAX_ORDER - 1 can simply be changed to MAX_ORDER to be consistent with the new world order.
CCing relevant maintainers...
Paolo
Quoted 94 lines
Kirill A. Shutemov (10):
sparc/mm: FixMAX_ORDERusage intsb_grow()
um: FixMAX_ORDERusage inlinux_main()
floppy: FixMAX_ORDERusage
drm/i915: FixMAX_ORDERusage ini915_gem_object_get_pages_internal()
genwqe: FixMAX_ORDERusage
perf/core: FixMAX_ORDERusage inrb_alloc_aux_page()mm/page_reporting: FixMAX_ORDERusage inpage_reporting_register()mm/slub: FixMAX_ORDERusage incalculate_order()
iommu: FixMAX_ORDERusage in__iommu_dma_alloc_pages()mm, treewide: RedefineMAX_ORDERsanely.../admin-guide/kdump/vmcoreinfo.rst | 2 +- .../admin-guide/kernel-parameters.txt | 2 +- arch/arc/Kconfig | 4 +- arch/arm/Kconfig | 9 ++--- arch/arm/configs/imx_v6_v7_defconfig | 2 +- arch/arm/configs/milbeaut_m10v_defconfig | 2 +- arch/arm/configs/oxnas_v6_defconfig | 2 +- arch/arm/configs/pxa_defconfig | 2 +- arch/arm/configs/sama7_defconfig | 2 +- arch/arm/configs/sp7021_defconfig | 2 +- arch/arm64/Kconfig | 27 ++++++------- arch/arm64/include/asm/sparsemem.h | 2 +- arch/arm64/kvm/hyp/include/nvhe/gfp.h | 2 +- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 10 ++--- arch/csky/Kconfig | 2 +- arch/ia64/Kconfig | 8 ++-- arch/ia64/include/asm/sparsemem.h | 4 +- arch/ia64/mm/hugetlbpage.c | 2 +- arch/loongarch/Kconfig | 15 +++----- arch/m68k/Kconfig.cpu | 5 +-- arch/mips/Kconfig | 19 ++++------ arch/nios2/Kconfig | 7 +--- arch/powerpc/Kconfig | 27 ++++++------- arch/powerpc/configs/85xx/ge_imp3a_defconfig | 2 +- arch/powerpc/configs/fsl-emb-nonhw.config | 2 +- arch/powerpc/mm/book3s64/iommu_api.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 2 +- arch/sh/configs/ecovec24_defconfig | 2 +- arch/sh/mm/Kconfig | 17 ++++----- arch/sparc/Kconfig | 5 +-- arch/sparc/kernel/pci_sun4v.c | 2 +- arch/sparc/kernel/traps_64.c | 2 +- arch/sparc/mm/tsb.c | 4 +- arch/xtensa/Kconfig | 5 +-- drivers/base/regmap/regmap-debugfs.c | 8 ++-- drivers/block/floppy.c | 2 +- drivers/crypto/ccp/sev-dev.c | 2 +- drivers/crypto/hisilicon/sgl.c | 6 +-- .../gpu/drm/i915/gem/selftests/huge_pages.c | 2 +- drivers/gpu/drm/ttm/ttm_pool.c | 22 +++++------ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 +- drivers/iommu/dma-iommu.c | 4 +- drivers/irqchip/irq-gic-v3-its.c | 4 +- drivers/md/dm-bufio.c | 2 +- drivers/misc/genwqe/card_utils.c | 2 +- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- drivers/net/ethernet/ibm/ibmvnic.h | 2 +- drivers/video/fbdev/hyperv_fb.c | 4 +- drivers/video/fbdev/vermilion/vermilion.c | 2 +- drivers/virtio/virtio_balloon.c | 2 +- drivers/virtio/virtio_mem.c | 12 +++--- fs/ramfs/file-nommu.c | 2 +- include/drm/ttm/ttm_pool.h | 2 +- include/linux/hugetlb.h | 2 +- include/linux/mmzone.h | 10 ++--- include/linux/pageblock-flags.h | 4 +- include/linux/slab.h | 6 +-- kernel/crash_core.c | 2 +- kernel/dma/pool.c | 6 +-- mm/Kconfig | 6 +-- mm/compaction.c | 8 ++-- mm/debug_vm_pgtable.c | 4 +- mm/huge_memory.c | 2 +- mm/hugetlb.c | 4 +- mm/kmsan/init.c | 6 +-- mm/memblock.c | 2 +- mm/memory_hotplug.c | 4 +- mm/page_alloc.c | 38 +++++++++---------- mm/page_isolation.c | 12 +++--- mm/page_owner.c | 6 +-- mm/page_reporting.c | 4 +- mm/shuffle.h | 2 +- mm/slab.c | 2 +- mm/slub.c | 4 +- mm/vmscan.c | 2 +- mm/vmstat.c | 14 +++---- net/smc/smc_ib.c | 2 +- security/integrity/ima/ima_crypto.c | 2 +- tools/testing/memblock/linux/mmzone.h | 6 +-- 80 files changed, 210 insertions(+), 240 deletions(-)
Mikulas Patocka
maintainerQuoted 10 lines · Paolo Bonzini
Quoted 9 lines · Kirill A. Shutemov
MAX_ORDERcurrently defined as number of orders page allocator supports:
user can ask buddy allocator for page order between 0 and MAX_ORDER-1.This definition is counter-intuitive and lead to number of bugs all over the kernel.
Fix the bugs and then change the definition of
MAX_ORDERto be
inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.
I think that exclusive MAX_ORDER is more intuitive in the C language - i.e. if you write "for (i = 0; i < MAX_ORDER; i++)", you are supposed to loop over all allowed values. If you declare an array "void *array[MAX_ORDER];" you are supposed to hold a value for each allowed order.
Pascal has for loops and array dimensions with inclusive ranges - and it is more prone to off-by-one errors.
Mikulas
Quoted 11 lines · Mikulas Patocka
Quoted 3 lines
Quoted 3 lines
Fix the bugs and then change the definition of
MAX_ORDERto be
inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.I think that exclusive
MAX_ORDERis more intuitive in the C language - i.e. if you write "for (i = 0; i <MAX_ORDER; i++)", you are supposed to loop over all allowed values. If you declare an array "void *array[MAX_ORDER];" you are supposed to hold a value for each allowed order.Pascal has for loops and array dimensions with inclusive ranges - and it is more prone to off-by-one errors.
I agree it's somewhat confusing either way but the ship has sailed, the patch has been included in Linux for several months.
Paolo
Quoted 10 lines · Paolo Bonzini
Quoted 9 lines · Mikulas Patocka
Quoted 3 lines
Quoted 3 lines
Fix the bugs and then change the definition of
MAX_ORDERto be
inclusive: the range of orders user can ask from buddy allocator is 0..MAX_ORDER now.I think that exclusive
MAX_ORDERis more intuitive in the C language - i.e. if you write "for (i = 0; i <MAX_ORDER; i++)", you are supposed to loop over all allowed values. If you declare an array "void *array[MAX_ORDER];" you are supposed to hold a value for each allowed order.
Quoted 5 lines
Quoted 2 lines
Pascal has for loops and array dimensions with inclusive ranges - and it is more prone to off-by-one errors.
I agree it's somewhat confusing either way but the ship has sailed, the patch has been included in Linux for several months.
Just make sure people don't backport it to stable. Fixes: (the commit that causes the semantic change) should do the trick.
BR,
Pavel
Signature · 1 line
People of Russia, stop Putin before his war on Ukraine escalates.