* [patch 136/158] mm/thp: flush file for !is_shmem PageDirty() case in collapse_file()
@ 2019-12-01 1:57 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2019-12-01 1:57 UTC (permalink / raw)
To: akpm, hannes, hughd, kirill.shutemov, linux-mm, mm-commits,
songliubraving, torvalds, william.kucharski, willy
From: Song Liu <songliubraving@fb.com>
Subject: mm/thp: flush file for !is_shmem PageDirty() case in collapse_file()
For non-shmem file THPs, khugepaged only collapses read only .text mapping
(VM_DENYWRITE). These pages should not be dirty except the case where the
file hasn't been flushed since first write.
Call filemap_flush() in collapse_file() to accelerate the write back in
such cases.
Link: http://lkml.kernel.org/r/20191106060930.2571389-3-songliubraving@fb.com
Signed-off-by: Song Liu <songliubraving@fb.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/khugepaged.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
--- a/mm/khugepaged.c~mm-thp-flush-file-for-is_shmem-pagedirty-case-in-collapse_file
+++ a/mm/khugepaged.c
@@ -1602,6 +1602,24 @@ static void collapse_file(struct mm_stru
result = SCAN_FAIL;
goto xa_unlocked;
}
+ } else if (PageDirty(page)) {
+ /*
+ * khugepaged only works on read-only fd,
+ * so this page is dirty because it hasn't
+ * been flushed since first write. There
+ * won't be new dirty pages.
+ *
+ * Trigger async flush here and hope the
+ * writeback is done when khugepaged
+ * revisits this page.
+ *
+ * This is a one-off situation. We are not
+ * forcing writeback in loop.
+ */
+ xas_unlock_irq(&xas);
+ filemap_flush(mapping);
+ result = SCAN_FAIL;
+ goto xa_unlocked;
} else if (trylock_page(page)) {
get_page(page);
xas_unlock_irq(&xas);
_
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-01 1:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01 1:57 [patch 136/158] mm/thp: flush file for !is_shmem PageDirty() case in collapse_file() akpm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).