Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,13 @@ static inline int current_is_kswapd(void)
*/

/*
* PTE markers are used to persist information onto PTEs that are mapped with
* file-backed memories. As its name "PTE" hints, it should only be applied to
* the leaves of pgtables.
* PTE markers are used to persist information onto PTEs that otherwise
* should be a none pte. As its name "PTE" hints, it should only be
* applied to the leaves of pgtables.
*/
#ifdef CONFIG_PTE_MARKER
#define SWP_PTE_MARKER_NUM 1
#define SWP_PTE_MARKER (MAX_SWAPFILES + SWP_HWPOISON_NUM + \
SWP_MIGRATION_NUM + SWP_DEVICE_NUM)
#else
#define SWP_PTE_MARKER_NUM 0
#endif

/*
* Unaddressable device memory support. See include/linux/hmm.h and
Expand Down
31 changes: 0 additions & 31 deletions include/linux/swapops.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,6 @@ typedef unsigned long pte_marker;
#define PTE_MARKER_SWAPIN_ERROR BIT(1)
#define PTE_MARKER_MASK (BIT(2) - 1)

#ifdef CONFIG_PTE_MARKER

static inline swp_entry_t make_pte_marker_entry(pte_marker marker)
{
return swp_entry(SWP_PTE_MARKER, marker);
Expand All @@ -418,32 +416,6 @@ static inline bool is_pte_marker(pte_t pte)
return is_swap_pte(pte) && is_pte_marker_entry(pte_to_swp_entry(pte));
}

#else /* CONFIG_PTE_MARKER */

static inline swp_entry_t make_pte_marker_entry(pte_marker marker)
{
/* This should never be called if !CONFIG_PTE_MARKER */
WARN_ON_ONCE(1);
return swp_entry(0, 0);
}

static inline bool is_pte_marker_entry(swp_entry_t entry)
{
return false;
}

static inline pte_marker pte_marker_get(swp_entry_t entry)
{
return 0;
}

static inline bool is_pte_marker(pte_t pte)
{
return false;
}

#endif /* CONFIG_PTE_MARKER */

static inline pte_t make_pte_marker(pte_marker marker)
{
return swp_entry_to_pte(make_pte_marker_entry(marker));
Expand Down Expand Up @@ -472,9 +444,6 @@ static inline int is_swapin_error_entry(swp_entry_t entry)
* memory, kernel-only memory (including when the system is during-boot),
* non-ram based generic file-system. It's fine to be used even there, but the
* extra pte marker check will be pure overhead.
*
* For systems configured with !CONFIG_PTE_MARKER this will be automatically
* optimized to pte_none().
*/
static inline int pte_none_mostly(pte_t pte)
{
Expand Down
7 changes: 0 additions & 7 deletions mm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1123,17 +1123,10 @@ config HAVE_ARCH_USERFAULTFD_MINOR
help
Arch has userfaultfd minor fault support

config PTE_MARKER
bool

help
Allows to create marker PTEs for file-backed memory.

config PTE_MARKER_UFFD_WP
bool "Userfaultfd write protection support for shmem/hugetlbfs"
default y
depends on HAVE_ARCH_USERFAULTFD_WP
select PTE_MARKER

help
Allows to create marker PTEs for userfaultfd write protection
Expand Down
7 changes: 3 additions & 4 deletions mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -3704,11 +3704,10 @@ static vm_fault_t handle_pte_marker(struct vm_fault *vmf)
unsigned long marker = pte_marker_get(entry);

/*
* PTE markers should always be with file-backed memories, and the
* marker should never be empty. If anything weird happened, the best
* thing to do is to kill the process along with its mm.
* PTE markers should never be empty. If anything weird happened,
* the best thing to do is to kill the process along with its mm.
*/
if (WARN_ON_ONCE(vma_is_anonymous(vmf->vma) || !marker))
if (WARN_ON_ONCE(!marker))
return VM_FAULT_SIGBUS;

/* Higher priority than uffd-wp when data corrupted */
Expand Down