On Mon, Jul 08, 2024 at 11:15:17AM +0800, Zhiguo Jiang wrote:Hi Matthew Wilcox,
If an anon folio reclaimed by shrink_inactive_list is mapped by anHow is the file folio similar? File folios are never written to swap,
exiting task, this anon folio will be firstly swaped-out into
swapspace in shrink flow and then this swap folio is freed in task
exit flow. But if this folio mapped by an exiting task can skip
shrink and be freed directly in task exiting flow, which will save
swap-out time and alleviate the load of the tasks exiting process.
The file folio is also similar.
and they'll be written back from the page cache whenever the filesystem
decides it's a good time to do so.
Ok, thanks.
mm/rmap.c | 10 ++++++++++Uh, what? Why would you make this file executable?
1 file changed, 10 insertions(+)
mode change 100644 => 100755 mm/rmap.c
diff --git a/mm/rmap.c b/mm/rmap.cComments start with a /* on a line by itself.
index 26806b49a86f..16b7ed04bcbe
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -843,6 +843,16 @@ static bool folio_referenced_one(struct folio *folio,
int referenced = 0;
unsigned long start = address, ptes = 0;
+ /* Skip the unshared folios mapped only by the single
+ * exiting process.
+ */
+ if ((!atomic_read(&vma->vm_mm->mm_users) ||This indentation is unreadable. Follow the style used in the rest of
+ test_bit(MMF_OOM_SKIP, &vma->vm_mm->flags)) &&
+ !test_bit(VM_SHARED, &vma->vm_flags)) {
+ pra->referenced = -1;
+ return false;
the file.