Commit d1402fc7 authored by Logan Gunthorpe's avatar Logan Gunthorpe Committed by Linus Torvalds

mm: introduce common STRUCT_PAGE_MAX_SHIFT define

This define is used by arm64 to calculate the size of the vmemmap
region.  It is defined as the log2 of the upper bound on the size of a
struct page.

We move it into mm_types.h so it can be defined properly instead of set
and checked with a build bug.  This also allows us to use the same
define for riscv.

Link: Logan Gunthorpe's avatarLogan Gunthorpe <>
Acked-by: default avatarWill Deacon <>
Acked-by: default avatarAndrew Morton <>
Acked-by: default avatarArd Biesheuvel <>
Acked-by: default avatarCatalin Marinas <>
Cc: Arnd Bergmann <>
Cc: Christoph Hellwig <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 5b526090
......@@ -34,15 +34,6 @@
#define PCI_IO_SIZE SZ_16M
* Log2 of the upper bound of the size of a struct page. Used for sizing
* the vmemmap region only, does not affect actual memory footprint.
* We don't use sizeof(struct page) directly since taking its size here
* requires its definition to be available at this point in the inclusion
* chain, and it may not be a power of 2 in the first place.
* VMEMMAP_SIZE - allows the whole linear region to be covered by
* a struct page array
......@@ -610,14 +610,6 @@ void __init mem_init(void)
* Make sure we chose the upper bound of sizeof(struct page)
* correctly when sizing the VMEMMAP array.
BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT));
if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
extern int sysctl_overcommit_memory;
......@@ -16,6 +16,7 @@
#include <linux/bug.h>
#include <linux/mm_types.h>
#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
......@@ -206,6 +206,11 @@ struct page {
} _struct_page_alignment;
* Used for sizing the vmemmap region on some architectures
#define STRUCT_PAGE_MAX_SHIFT (order_base_2(sizeof(struct page)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment