Strange condition in invalidate_mapping_pages()
Hi Kirill,
in commit fc127da085c26 "truncate: handle file thp" you've added the following to invalidate_mapping_pages():
/* Middle of THP: skip */
if (PageTransTail(page)) {
unlock_page(page);
continue;
} else if (PageTransHuge(page)) {
index += HPAGE_PMD_NR - 1;
i += HPAGE_PMD_NR - 1;
/* 'end' is in the middle of THP */
if (index == round_down(end, HPAGE_PMD_NR))
continue;
}Now how can ever condition "if (index == round_down(end, HPAGE_PMD_NR))" be true? We have just added HPAGE_PMD_NR - 1 to 'index' so it will not be a multiple of HPAGE_PMD_NR. Presumably you wanted to check whether the current THP is the one containing 'end' here which would be something like 'round_down(index, HPAGE_PMD_NR) == round_down(end, HPAGE_PMD_NR)' but then I still miss why you'd like to avoid invalidating the partial THP at the end of file... Can you please enlighten me? Thanks!
Honza
Signature · 8 lines
Jan Kara <[email protected]> SUSE Labs, CR -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 17 lines · Jan Kara
Hi Kirill,
in commit
fc127da085c26"truncate: handle file thp" you've added the following toinvalidate_mapping_pages():/* Middle of THP: skip */ if (PageTransTail(page)) { unlock_page(page); continue; } else if (PageTransHuge(page)) { index += HPAGE_PMD_NR - 1; i += HPAGE_PMD_NR - 1; /* 'end' is in the middle of THP */ if (index == round_down(end, HPAGE_PMD_NR)) continue; }
Quoted 6 lines
Now how can ever condition "if (index ==
round_down(end, HPAGE_PMD_NR))" be true? We have just addedHPAGE_PMD_NR- 1 to 'index' so it will not be a multiple ofHPAGE_PMD_NR. Presumably you wanted to check whether the current THP is the one containing 'end' here which would be something like 'round_down(index, HPAGE_PMD_NR)==round_down(end, HPAGE_PMD_NR)'.
You're right, it's a bug. 'page->index' instead of 'index' should do the trick.
Would you like to prepare the patch? (I'm deep in 5-level paging at the moment.)
Quoted 2 lines
but then I still miss why you'd like to avoid invalidating the partial THP at the end of file... Can you please enlighten me? Thanks!
My logic was that the data in the non-invalidated part of the page can be still useful and it's better to leave it in page cache.
I don't have performance numbers to validate my intuition.
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>