(Was: introduce get_compound_page)
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest7 patches 6 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | mm: thp: introduce __put_nontail_page()mm/ | +26 | 0 replies | |
| 2/7 | mm: thp: change __get_page_tail() to use __put_nontail_page()mm/ | +1 | 0 replies | |
| 3/7 | mm: change release_pages() to use put_page() rather than put_compound_page()mm/ | +1 | 0 replies | |
| 4/7 | mm: thp: turn put_compound_page() into __put_page_tail()mm/ | +6 | 2 replies | |
| 5/7 | mm: thp: reorganize out_put_single code in __put_page_tail()mm/ | +28 | 0 replies | |
| 6/7 | mm: thp: introduce get_lock_thp_head()mm/ | +45 | 2 replies | |
| 7/7 | mm: thp: introduce compound_head_put_tail(), change get_futex_key() to use itinclude/ kernel/ mm/ | +38 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH -mm 0/7] (Was: introduce get_compound_page)
Quoted 13 lines · Andrea Arcangeli
Quoted 11 lines · Oleg Nesterov
I can't stop thinking about another change. What if we simply change
__split_huge_page_refcount()to also do compound_lock/unlock(page_tail) in a main loop?This way we can greatly simplify get/put_page paths, we can rely on
compound_lock(sub-page)and avoidget_page_unless_zero(page_head). Yes, this will make_splita bit slower, butPG_compound_lockshould not be contended? And we should changepage_tail->flagscarefully, but this looks simple.
Quoted 3 lines
Quoted 1 line
Or this is not possible/desirable?
That would be 512 nested spinlocks instead of 1,
Yes. But, just in case, we do not need to take them all at once. We only need to take/release the additional lock per page_tail in a loop.
Quoted 3 lines
last time I did
something like that inmm_take_all_lockspeople weren't too pleased as it started firing lockdeps complains too.
bit_spin_lock() doesn't have the lockdep annotations and it would be trivial to add _nested if necessary.
Quoted 5 lines
split_huge_pageto the contrary could run in a flood if you're unlucky.split_huge_pageis needed not just to handle non-THP aware paths that mostly disappeared by now, but also when you truncate a vma so that a THP doesn't fit in it anymore. So it's up to userland how frequently it needs to run.
Yes, I understand. I _think_ this should be fine performance-wise, compared to other things split_huge_page() paths should do these 511 test_and_set_bit + clear_bit should not be noticeable.
But of course I can be wrong.
Quoted 7 lines
I think it's reasonable to consider it though, but then it's not guaranteed that a
put_pageon a THP tail is more frequent thansplit_huge_page. Keep in mind we do theget_page_unless_zeroto stabilize the head to take thecompound_lockon it, only for the tails, never for the heads. So this restricts it to _only_ theput_pagefollowing agup_fast. Onlygup_fastcan ever take a reference on the tail pages of a THP. Nothing else can.
I see. But my main point was simplification.
And I'm afraid this compound_lock() in get/put can race with someone else playing with page->flags "because I own this freshly allocated page". Perhaps.
However. I do understand your concerns, lets forget about this for now.
---------------------------------------------------------------------------
Please review get_futex_key() changes we discussed before. As for the race with prep_new_page() I'll send another patch, it is completely orthogonal to this series.
Testing. I simply have no idea how can I test this series so I didn't even try ;) I'll try to do something tomorrow, but in any case I have to rely on your review.
Most of the cleanups in this series are not needed to change get_futex_key(), but imho make sense. And we need more cleanups after this series, I'll do this later if this series makes any sense.
Oleg.
include/linux/mm.h | 2 + kernel/futex.c | 37 +-------- mm/swap.c | 251 ++++++++++++++++++++++++++-------------------------- 3 files changed, 128 insertions(+), 162 deletions(-)