mm/thp: decrease nr_thps in file's mapping on THP split
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CGME20211012120247eucas1p1f66926c6fc334216cdbdd39285601aa8@eucas1p1.samsung.com
PATCH 1/1 mm/thp: decrease nr_thps in file's mapping on THP split
Decrease nr_thps counter in file's mapping to ensure that the page cache won't be dropped excessively on file write access if page has been already splitted.
---
I've analyzed the code a few times but either I missed something or the nr_thps counter is not decremented during the THP split on non-shmem file pages.
--- mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/huge_memory.c +4 -2
@@ -2709,10 +2709,12 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) }spin_unlock (&ds_queue->split_queue_lock);if (mapping) { -if (PageSwapBacked (head)) +if (PageSwapBacked (head)) {__dec_node_page_state (head,NR_SHMEM_THPS ); -else + }else {__dec_node_page_state (head,NR_FILE_THPS ); +filemap_nr_thps_dec (mapping); + } }__split_huge_page (page, list, end, flags);
Signature · 1 line
2.17.1
Quoted 11 lines · Marek Szyprowski
Decrease
nr_thpscounter in file's mapping to ensure that the page cache won't be dropped excessively on file write access if page has been already splitted.Signed-off-by Marek Szyprowski <[email protected]>Fixes 09d91cda0e82 ("mm,thp: avoid writes to file with THP in pagecache")Fixes 06d3eff62d9d ("mm/thp: fix node page state in split_huge_page_to_list()")---
I've analyzed the code a few times but either I missed something or thenr_thpscounter is not decremented during the THP split on non-shmem file pages.
This looks OK to me, but have you tested it? If so, what workload did you use? The way you wrote this changelog makes it sound like you only read the code and there have been rather too many bugs introduced recently that way :-(
Quoted 12 lines · Matthew Wilcox
Quoted 11 lines · Marek Szyprowski
Decrease
nr_thpscounter in file's mapping to ensure that the page cache won't be dropped excessively on file write access if page has been already splitted.Signed-off-by Marek Szyprowski <[email protected]>Fixes 09d91cda0e82 ("mm,thp: avoid writes to file with THP in pagecache")Fixes 06d3eff62d9d ("mm/thp: fix node page state in split_huge_page_to_list()")---
I've analyzed the code a few times but either I missed something or thenr_thpscounter is not decremented during the THP split on non-shmem file pages.
Quoted 4 lines
This looks OK to me, but have you tested it? If so, what workload did you use? The way you wrote this changelog makes it sound like you only read the code and there have been rather too many bugs introduced recently that way :-(
Well, indeed I've found it while reading the code. However I've just tried a test scenario, where one runs a big binary, kernel remaps it with THPs, then one forces THP split with /sys/kernel/debug/split_huge_pages. During any further open of that binary with O_RDWR or O_WRITEONLY kernel drops page cache for it, because of non-zero thps counter.
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Matthew Wilcox
Acked-byQuoted 18 lines · Marek Szyprowski
Quoted 12 lines · Matthew Wilcox
Quoted 11 lines · Marek Szyprowski
Decrease
nr_thpscounter in file's mapping to ensure that the page cache won't be dropped excessively on file write access if page has been already splitted.Signed-off-by Marek Szyprowski <[email protected]>Fixes 09d91cda0e82 ("mm,thp: avoid writes to file with THP in pagecache")Fixes 06d3eff62d9d ("mm/thp: fix node page state in split_huge_page_to_list()")---
I've analyzed the code a few times but either I missed something or thenr_thpscounter is not decremented during the THP split on non-shmem file pages.Quoted 4 lines
This looks OK to me, but have you tested it? If so, what workload did you use? The way you wrote this changelog makes it sound like you only read the code and there have been rather too many bugs introduced recently that way :-(
Quoted 6 lines
Well, indeed I've found it while reading the code. However I've just tried a test scenario, where one runs a big binary, kernel remaps it with THPs, then one forces THP split with
/sys/kernel/debug/split_huge_pages. During any further open of that binary withO_RDWRorO_WRITEONLYkernel drops page cache for it, because of non-zero thps counter.
... and with this patch, it no longer happens? Good enough for me!
Quoted 8 lines · Marek Szyprowski
Decrease
nr_thpscounter in file's mapping to ensure that the page cache won't be dropped excessively on file write access if page has been already splitted.Signed-off-by Marek Szyprowski <[email protected]>Fixes 09d91cda0e82 ("mm,thp: avoid writes to file with THP in pagecache")Fixes 06d3eff62d9d ("mm/thp: fix node page state in split_huge_page_to_list()")
Quoted 31 lines
---
I've analyzed the code a few times but either I missed something or thenr_thpscounter is not decremented during the THP split on non-shmem file pages.--- mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)mm/huge_memory.c +4
-3@@ -2709,10 +2709,12 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) }spin_unlock (&ds_queue->split_queue_lock);if (mapping) { -if (PageSwapBacked (head)) +if (PageSwapBacked (head)) {__dec_node_page_state (head,NR_SHMEM_THPS ); -else + }else {__dec_node_page_state (head,NR_FILE_THPS ); +filemap_nr_thps_dec (mapping); + } }__split_huge_page (page, list, end, flags); --2.17.1