Skip to content

RFC Reduce cost of ptep_get_lockless on arm64

Ryan Roberts linux-arm-kernel linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 43 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4mm: Introduce ptep_get_lockless_norecency()include/linux/pgtable.h kernel/events/core.c mm/hugetlb.c +4 more+40 -95 replies
2/4mm/gup: Use ptep_get_lockless_norecency()include/linux/pgtable.h mm/gup.c+22 -32 replies
3/4mm/memory: Use ptep_get_lockless_norecency() for orig_ptemm/memory.c+34 -217 replies
4/4arm64/mm: Override ptep_get_lockless_norecency()arch/arm64/include/asm/pgtable.h+6 -01 reply

Reviews trailers per patch

2 of 4 patches have a Reviewed-by or Acked-by.

PatchDavid Hildenbrand
1/4
2/4A-b
3/4
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH v1 0/4] Reduce cost of ptep_get_lockless on arm64

This is an RFC for a series that aims to reduce the cost and complexity of ptep_get_lockless() for arm64 when supporting transparent contpte mappings [1]. The approach came from discussion with Mark and David [2].

It introduces a new helper, ptep_get_lockless_norecency(), which allows the access and dirty bits in the returned pte to be incorrect. This relaxation permits arm64's implementation to just read the single target pte, and avoids having to iterate over the full contpte block to gather the access and dirty bits, for the contpte case.

It turns out that none of the call sites using ptep_get_lockless() require accurate access and dirty bit information, so we can also convert those sites. Although a couple of places need care (see patches 2 and 3).

Arguably patch 3 is a bit fragile, given the wide accessibility of vmf->orig_pte. So it might make sense to drop this patch and stick to using ptep_get_lockless() in the page fault path. I'm keen to hear opinions.

I've chosen the name "recency" because it's shortish and somewhat descriptive, and is alredy used in a couple of places to mean similar things (see mglru and damon). I'm open to other names if anyone has better ideas.

If concensus is that this approach is generally acceptable, I intend to create a series in future to do a similar thing with ptep_get() -> ptep_get_norecency().

---
This series applies on top of [1].

[1] https://lore.kernel.org/linux-mm/[email protected]/
[2] https://lore.kernel.org/linux-mm/[email protected]/

Thanks,
Ryan

Ryan Roberts (4):
mm: Introduce ptep_get_lockless_norecency() mm/gup: Use ptep_get_lockless_norecency() mm/memory: Use ptep_get_lockless_norecency() for orig_pte arm64/mm: Override ptep_get_lockless_norecency()

 arch/arm64/include/asm/pgtable.h |  6 ++++
 include/linux/pgtable.h          | 55 ++++++++++++++++++++++++++++--
 kernel/events/core.c             |  2 +-
 mm/gup.c                         |  7 ++--
 mm/hugetlb.c                     |  2 +-
 mm/khugepaged.c                  |  2 +-
 mm/memory.c                      | 57 ++++++++++++++++++++------------
 mm/swap_state.c                  |  2 +-
 mm/swapfile.c                    |  2 +-
 9 files changed, 102 insertions(+), 33 deletions(-)

--
2.25.1