diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2009-07-05 06:30:15 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-07-05 10:31:26 -0400 |
commit | fb93a1c75eb646fde35985e9af23da936775ae52 (patch) | |
tree | 345ad933ae9a1c114c4185b7578e9ddf08c608a2 /arch/arm/include/asm/pgtable.h | |
parent | ba9b42e4ff5eb68f9c946378229d7e45299d7151 (diff) |
[ARM] pgtable: swp pte layout documentation, definitions, and check
Document the layout of our swp PTE entries, adding definitions for
the bit masks/shifts/sizes, and implement MAX_SWAPFILES_CHECK()
such that we fail to build if we are unable to properly encode the
swp type field.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm/pgtable.h')
-rw-r--r-- | arch/arm/include/asm/pgtable.h | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index 1cd2d6416bda..c1d97938f3e2 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h | |||
@@ -384,16 +384,36 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) | |||
384 | 384 | ||
385 | extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; | 385 | extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; |
386 | 386 | ||
387 | /* Encode and decode a swap entry. | 387 | /* |
388 | * Encode and decode a swap entry. Swap entries are stored in the Linux | ||
389 | * page tables as follows: | ||
390 | * | ||
391 | * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 | ||
392 | * 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 | ||
393 | * <--------------- offset --------------------> <--- type --> 0 0 | ||
388 | * | 394 | * |
389 | * We support up to 32GB of swap on 4k machines | 395 | * This gives us up to 127 swap files and 32GB per swap file. Note that |
396 | * the offset field is always non-zero. | ||
390 | */ | 397 | */ |
391 | #define __swp_type(x) (((x).val >> 2) & 0x7f) | 398 | #define __SWP_TYPE_SHIFT 2 |
392 | #define __swp_offset(x) ((x).val >> 9) | 399 | #define __SWP_TYPE_BITS 7 |
393 | #define __swp_entry(type,offset) ((swp_entry_t) { ((type) << 2) | ((offset) << 9) }) | 400 | #define __SWP_TYPE_MASK ((1 << __SWP_TYPE_BITS) - 1) |
401 | #define __SWP_OFFSET_SHIFT (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT) | ||
402 | |||
403 | #define __swp_type(x) (((x).val >> __SWP_TYPE_SHIFT) & __SWP_TYPE_MASK) | ||
404 | #define __swp_offset(x) ((x).val >> __SWP_OFFSET_SHIFT) | ||
405 | #define __swp_entry(type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) }) | ||
406 | |||
394 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) | 407 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) |
395 | #define __swp_entry_to_pte(swp) ((pte_t) { (swp).val }) | 408 | #define __swp_entry_to_pte(swp) ((pte_t) { (swp).val }) |
396 | 409 | ||
410 | /* | ||
411 | * It is an error for the kernel to have more swap files than we can | ||
412 | * encode in the PTEs. This ensures that we know when MAX_SWAPFILES | ||
413 | * is increased beyond what we presently support. | ||
414 | */ | ||
415 | #define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > __SWP_TYPE_BITS) | ||
416 | |||
397 | /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */ | 417 | /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */ |
398 | /* FIXME: this is not correct */ | 418 | /* FIXME: this is not correct */ |
399 | #define kern_addr_valid(addr) (1) | 419 | #define kern_addr_valid(addr) (1) |