mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Wed, 14 Feb 2018 11:16:49 +0000 (14:16 +0300)
committerIngo Molnar <mingo@kernel.org>
Wed, 14 Feb 2018 12:11:13 +0000 (13:11 +0100)
With boot-time switching between paging mode we will have variable
MAX_PHYSMEM_BITS.

Let's use the maximum variable possible for CONFIG_X86_5LEVEL=y
configuration to define zsmalloc data structures.

The patch introduces MAX_POSSIBLE_PHYSMEM_BITS to cover such case.
It also suits well to handle PAE special case.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Nitin Gupta <ngupta@vflare.org>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/20180214111656.88514-3-kirill.shutemov@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/pgtable-3level_types.h
arch/x86/include/asm/pgtable_64_types.h
mm/zsmalloc.c

index 876b4c77d983eba9c795e1dd0ebb5408912115e9..6a59a6d0cc508857299afa9b06b58a8d6cc2e5f5 100644 (file)
@@ -44,5 +44,6 @@ typedef union {
  */
 #define PTRS_PER_PTE   512
 
+#define MAX_POSSIBLE_PHYSMEM_BITS      36
 
 #endif /* _ASM_X86_PGTABLE_3LEVEL_DEFS_H */
index 6b8f73dcbc2c2b6a835e17ac0828d8b6484f4dce..7168de7d34ebd65646bc92b7d7c63f1daf8563fd 100644 (file)
@@ -40,6 +40,8 @@ typedef struct { pteval_t pte; } pte_t;
 #define P4D_SIZE       (_AC(1, UL) << P4D_SHIFT)
 #define P4D_MASK       (~(P4D_SIZE - 1))
 
+#define MAX_POSSIBLE_PHYSMEM_BITS      52
+
 #else /* CONFIG_X86_5LEVEL */
 
 /*
index c3013505c30527dc42714946916f6cf26c51c602..b7f61cd1c709318a22ddba31ab2fb2b01d9322a8 100644 (file)
  * This is made more complicated by various memory models and PAE.
  */
 
-#ifndef MAX_PHYSMEM_BITS
-#ifdef CONFIG_HIGHMEM64G
-#define MAX_PHYSMEM_BITS 36
-#else /* !CONFIG_HIGHMEM64G */
+#ifndef MAX_POSSIBLE_PHYSMEM_BITS
+#ifdef MAX_PHYSMEM_BITS
+#define MAX_POSSIBLE_PHYSMEM_BITS MAX_PHYSMEM_BITS
+#else
 /*
  * If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just
  * be PAGE_SHIFT
  */
-#define MAX_PHYSMEM_BITS BITS_PER_LONG
+#define MAX_POSSIBLE_PHYSMEM_BITS BITS_PER_LONG
 #endif
 #endif
-#define _PFN_BITS              (MAX_PHYSMEM_BITS - PAGE_SHIFT)
+
+#define _PFN_BITS              (MAX_POSSIBLE_PHYSMEM_BITS - PAGE_SHIFT)
 
 /*
  * Memory for allocating for handle keeps object position by