Skip to content

Commit 3151cc2

Browse files
davidhildenbrandakpm00
authored andcommitted
ia64/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE
Let's support __HAVE_ARCH_PTE_SWP_EXCLUSIVE by stealing one bit from the type. Generic MM currently only uses 5 bits for the type (MAX_SWAPFILES_SHIFT), so the stolen bit is effectively unused. While at it, also mask the type in __swp_entry(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 61f4a89 commit 3151cc2

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

arch/ia64/include/asm/pgtable.h

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
#define _PAGE_ED (__IA64_UL(1) << 52) /* exception deferral */
5959
#define _PAGE_PROTNONE (__IA64_UL(1) << 63)
6060

61+
/* We borrow bit 7 to store the exclusive marker in swap PTEs. */
62+
#define _PAGE_SWP_EXCLUSIVE (1 << 7)
63+
6164
#define _PFN_MASK _PAGE_PPN_MASK
6265
/* Mask of bits which may be changed by pte_modify(); the odd bits are there for _PAGE_PROTNONE */
6366
#define _PAGE_CHG_MASK (_PAGE_P | _PAGE_PROTNONE | _PAGE_PL_MASK | _PAGE_AR_MASK | _PAGE_ED)
@@ -399,23 +402,46 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
399402
extern void paging_init (void);
400403

401404
/*
405+
* Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
406+
* are !pte_none() && !pte_present().
407+
*
402408
* Note: The macros below rely on the fact that MAX_SWAPFILES_SHIFT <= number of
403409
* bits in the swap-type field of the swap pte. It would be nice to
404410
* enforce that, but we can't easily include <linux/swap.h> here.
405411
* (Of course, better still would be to define MAX_SWAPFILES_SHIFT here...).
406412
*
407413
* Format of swap pte:
408414
* bit 0 : present bit (must be zero)
409-
* bits 1- 7: swap-type
415+
* bits 1- 6: swap type
416+
* bit 7 : exclusive marker
410417
* bits 8-62: swap offset
411418
* bit 63 : _PAGE_PROTNONE bit
412419
*/
413-
#define __swp_type(entry) (((entry).val >> 1) & 0x7f)
420+
#define __swp_type(entry) (((entry).val >> 1) & 0x3f)
414421
#define __swp_offset(entry) (((entry).val << 1) >> 9)
415-
#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << 1) | ((long) (offset) << 8) })
422+
#define __swp_entry(type, offset) ((swp_entry_t) { ((type & 0x3f) << 1) | \
423+
((long) (offset) << 8) })
416424
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
417425
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
418426

427+
#define __HAVE_ARCH_PTE_SWP_EXCLUSIVE
428+
static inline int pte_swp_exclusive(pte_t pte)
429+
{
430+
return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
431+
}
432+
433+
static inline pte_t pte_swp_mkexclusive(pte_t pte)
434+
{
435+
pte_val(pte) |= _PAGE_SWP_EXCLUSIVE;
436+
return pte;
437+
}
438+
439+
static inline pte_t pte_swp_clear_exclusive(pte_t pte)
440+
{
441+
pte_val(pte) &= ~_PAGE_SWP_EXCLUSIVE;
442+
return pte;
443+
}
444+
419445
/*
420446
* ZERO_PAGE is a global shared page that is always zero: used
421447
* for zero-mapped memory areas etc..

0 commit comments

Comments
 (0)