Skip to content

Use RCU to stabilize page counts

Michel Lespinasse linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9mm: rcu read lock for getting reference on pages in migration_entry_wait()mm/migrate.c+3 -00 replies
2/9mm: avoid calling get_page_unless_zero() when charging cgroupsmm/memcontrol.c+10 -100 replies
3/9mm: rcu read lock when getting from tail to head pagemm/ksm.c mm/swap.c+11 -10 replies
4/9mm: use get_page in deactivate_page()mm/swap.c+7 -70 replies
5/9kvm: use get_page instead of get_page_unless_zeroarch/x86/kvm/mmu.c+1 -20 replies
6/9mm: assert that get_page_unless_zero() callers hold the rcu lockinclude/linux/mm.h include/linux/pagemap.h mm/hwpoison-inject.c +3 more+27 -71 reply
7/9rcu: rcu_get_gp_cookie() / rcu_gp_cookie_elapsed() stand-insinclude/linux/rcupdate.h+35 -00 replies
8/9mm: add API for setting a grace period cookie on compound pagesinclude/linux/mm.h include/linux/mm_types.h mm/page_alloc.c+28 -10 replies
9/9mm: make sure tail page counts are stable before splitting THP pagesmm/huge_memory.c+29 -40 replies

Reviews trailers per patch

None of the 9 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMinchan KimMichel LespinasseDavid S. Miller
SeriesR-b R-b R-b R-b R-b R-b R-b R-b A-b
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/9] Use RCU to stabilize page counts

include/linux/pagemap.h describes the protocol one should use to get pages from page cache - one can't know if the reference they get will be on the desired page, so newly allocated pages might see elevated reference counts, but using RCU this effect can be limited in time to one RCU grace period.

For this protocol to work, every call site of get_page_unless_zero() has to participate, and this was not previously enforced.

Patches 1-3 convert some get_page_unless_zero() call sites to use the proper RCU protocol as described in pagemap.h

Patches 4-5 convert some get_page_unless_zero() call sites to just call get_page()

Patch 6 asserts that every remaining get_page_unless_zero() call site should participate in the RCU protocol. Well, not actually all of them - __isolate_rcu_page() is exempted because it holds the zone LRU lock which would prevent the given page from getting entirely freed, and a few others related to hwpoison, memory hotplug and memory failure are exempted because I haven't been able to figure out what to do.

Patch 7 is a placeholder for an RCU API extension we have been talking about with Paul McKenney. The idea is to record an initial time as an opaque cookie, and to be able to determine later on if an rcu grace period has elapsed since that initial time.

Patch 8 adds wrapper functions to store an RCU cookie into compound pages.

Patch 9 makes use of new RCU API, as well as the prior fixes from patches 1-6, to ensure tail page counts are stable while we split THP pages. This fixes a (rather theorical, not actually been observed) race condition where THP page splitting could result in incorrect page counts if THP page allocation and splitting both occur while another thread tries to run get_page_unless_zero on a single page that got re-allocated as THP tail page.

The patches have received only a limited amount of testing; however I believe patches 1-6 to be sane and I would like them to get more exposure, maybe as part of andrew's -mm tree.

Besides that, this proposal is also to sync up with Paul regarding the RCU functionality :)

Michel Lespinasse (9):
mm: rcu read lock for getting reference on pages in
migration_entry_wait()
mm: avoid calling get_page_unless_zero() when charging cgroups
mm: rcu read lock when getting from tail to head page
mm: use get_page in deactivate_page()
kvm: use get_page instead of get_page_unless_zero
mm: assert that get_page_unless_zero() callers hold the rcu lock
rcu: rcu_get_gp_cookie() / rcu_gp_cookie_elapsed() stand-ins
mm: add API for setting a grace period cookie on compound pages
mm: make sure tail page counts are stable before splitting THP pages

 arch/x86/kvm/mmu.c       |    3 +--
 include/linux/mm.h       |   38 +++++++++++++++++++++++++++++++++++++-
 include/linux/mm_types.h |    6 +++++-
 include/linux/pagemap.h  |    1 +
 include/linux/rcupdate.h |   35 +++++++++++++++++++++++++++++++++++
 mm/huge_memory.c         |   33 +++++++++++++++++++++++++++++----
 mm/hwpoison-inject.c     |    2 +-
 mm/ksm.c                 |    4 ++++
 mm/memcontrol.c          |   20 ++++++++++----------
 mm/memory-failure.c      |    6 +++---
 mm/memory_hotplug.c      |    2 +-
 mm/migrate.c             |    3 +++
 mm/page_alloc.c          |    1 +
 mm/swap.c                |   22 ++++++++++++++--------
 mm/vmscan.c              |    7 ++++++-
 15 files changed, 151 insertions(+), 32 deletions(-)
Signature · 1 line
1.7.3.1