Improve folio split related functions
Status from this message: [merged mm-stable] mm-huge_memory-fix-folio-split-stats-counting.patch removed from -mm tree
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest4 patches 0 repliesApplied 4/4
- v34 patches 7 repliesSuperseded
- v24 patches 27 repliesSuperseded
Patches in v4 All 4 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | mm/huge_memory: change folio_split_supported() to folio_check_splittable()include/ mm/ | +46 | 0 replies | Applied |
| 2/4 | mm/huge_memory: replace can_split_folio() with direct refcount calculationinclude/ mm/ mm/ | +22 | 0 replies | Applied |
| 3/4 | mm/huge_memory: make min_order_for_split() always return an orderinclude/ mm/ | +22 | 0 replies | Applied |
| 4/4 | mm/huge_memory: fix folio split stats countingmm/ | +9 | 0 replies | Applied |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | Wei Yang | Balbir Singh | David Hildenbrand (Red Hat) | Lorenzo Stoakes |
|---|---|---|---|---|
| 1/4 | R-b | A-b | A-b | |
| 2/4 | R-b | A-b | ||
| 3/4 | R-b | A-b | R-b | |
| 4/4 | R-b | A-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.
Cover letter [PATCH v4 0/4] Improve folio split related functions
Hi all,
This patchset improves several folio split related functions to avoid future misuse. The changes are:
1. Consolidated folio splittable checks by moving truncated folio check, huge zero folio check, and writeback folio check into folio_split_supported(). Changed the function return type. Renamed it to folio_check_splittable() for clarification.
2. Replaced can_split_folio() with open coded folio_expected_ref_count() and folio_ref_count() and introduced folio_cache_ref_count().
3. Changed min_order_for_split() to always return an order.
4. Fixed folio split stats counting.
Motivation
===
This is based on Wei's observation[1] and solves several potential issues:
1. Dereferencing NULL folio->mapping in try_folio_split_to_order() if it is called on truncated folios.
2. Not handling of negative return value of min_order_for_split() in mm/memory-failure.c
There is no bug in the current code.
The code is based on latest mm-new with V2 reverted and can replace V2 cleanly on mm-new branch.
Changelog
===
From V3[4]:
1. Reordered conditions when checking truncated shmem or to-be-anon folios.
2. Removed expected_refs.
From V2[3]:
1. Removed "bool warns" parameter from folio_check_splittable().
2. Removed all warnings in folio_check_splittable() and added a single warning in its caller, __folio_split() instead.
3. Spelled out in the comment in folio_check_splittable() that folios without a mapping in the swapcache can be shmem or to-be-anon folios.
4. Renamed folio_cache_references to folio_cache_ref_count.
5. Removed extra_pins variable.
6. Replaced folio_expected_ref_count() with folio_cache_ref_count() for folio_ref_unfreeze() uses in __folio_freeze_and_split_unmapped(), since they are equivalent at those call sites.
From RFC[2]:
1. Renamed folio_split_supported() to folio_check_splittable(), changed its return type from bool to int to return error code directly, and added kernel-doc.
2. Moved truncated folio check, zero huge folio check, and writeback check in folio_check_splittable().
3. Changed zero huge folio check's error number from -EBUSY to -EINVAL.
4. Replaced can_split_folio() with open code.
5. Changed min_order_for_split() to return 0 for truncated folio instead of -EBUSY and added kernel-doc.
6. Fixed folio split stats counting.
Comments and feedbacks are welcome.
Zi Yan (4):
mm/huge_memory: change folio_split_supported() to
folio_check_splittable()
mm/huge_memory: replace can_split_folio() with direct refcount
calculation
mm/huge_memory: make min_order_for_split() always return an order mm/huge_memory: fix folio split stats counting
include/linux/huge_mm.h | 13 ++-- mm/huge_memory.c | 165 ++++++++++++++++++++++------------------ mm/vmscan.c | 3 +- 3 files changed, 98 insertions(+), 83 deletions(-)
Signature · 1 line
2.51.0