lkml.org 
[lkml]   [2020]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] mm: avoid blocking lock_page() in kcompactd
On Thu, Feb 13, 2020 at 08:48:47AM +0100, Michal Hocko wrote:
> Can we pursue on this please? An explicit NOFS scope annotation with a
> reference to compaction potentially locking up on pages in the readahead
> would be a great start.

How about this (on top of the current readahead series):

diff --git a/mm/readahead.c b/mm/readahead.c
index 29ca25c8f01e..32fd32b913da 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -160,6 +160,16 @@ unsigned long page_cache_readahead_limit(struct address_space *mapping,
.nr_pages = 0,
};

+ /*
+ * Partway through the readahead operation, we will have added
+ * locked pages to the page cache, but will not yet have submitted
+ * them for I/O. Adding another page may need to allocate
+ * memory, which can trigger memory migration. Telling the VM
+ * we're in the middle of a filesystem operation will cause it
+ * to not touch file-backed pages, preventing a deadlock.
+ */
+ unsigned int nofs = memalloc_nofs_save();
+
/*
* Preallocate as many pages as we will need.
*/
@@ -217,6 +227,7 @@ unsigned long page_cache_readahead_limit(struct address_space *mapping,
*/
read_pages(&rac, &page_pool);
BUG_ON(!list_empty(&page_pool));
+ memalloc_nofs_restore(nofs);
return rac.nr_pages;
}
EXPORT_SYMBOL_GPL(page_cache_readahead_limit);
\
 
 \ /
  Last update: 2020-02-13 17:46    [W:0.139 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site