Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 7488/1: mm: use 5 bits for swapfile type encoding

Page migration encodes the pfn in the offset field of a swp_entry_t.
For LPAE, we support physical addresses of up to 36 bits (due to
sparsemem limitations with the size of page flags), requiring 24 bits
to represent a pfn. A further 3 bits are used to encode a swp_entry into
a pte, leaving 5 bits for the type field. Furthermore, the core code
defines MAX_SWAPFILES_SHIFT as 5, so the additional type bit does not
get used.

This patch reduces the width of the type field to 5 bits, allowing us
to create up to 31 swapfiles of 64GB each.

Cc: <stable@vger.kernel.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Will Deacon and committed by
Russell King
f5f2025e 47f12043

+3 -3
+3 -3
arch/arm/include/asm/pgtable.h
··· 253 253 * 254 254 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 255 255 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 256 - * <--------------- offset --------------------> <- type --> 0 0 0 256 + * <--------------- offset ----------------------> < type -> 0 0 0 257 257 * 258 - * This gives us up to 63 swap files and 32GB per swap file. Note that 258 + * This gives us up to 31 swap files and 64GB per swap file. Note that 259 259 * the offset field is always non-zero. 260 260 */ 261 261 #define __SWP_TYPE_SHIFT 3 262 - #define __SWP_TYPE_BITS 6 262 + #define __SWP_TYPE_BITS 5 263 263 #define __SWP_TYPE_MASK ((1 << __SWP_TYPE_BITS) - 1) 264 264 #define __SWP_OFFSET_SHIFT (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT) 265 265