]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - mm/fadvise.c
mm: fadvise: avoid expensive remote LRU cache draining after FADV_DONTNEED
[karo-tx-linux.git] / mm / fadvise.c
index 6c707bfe02fde002feae9ea2fab3fc9647c3baa0..a430131125815803ba25a7014917c6118087dd5c 100644 (file)
@@ -139,7 +139,20 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice)
                }
 
                if (end_index >= start_index) {
-                       unsigned long count = invalidate_mapping_pages(mapping,
+                       unsigned long count;
+
+                       /*
+                        * It's common to FADV_DONTNEED right after
+                        * the read or write that instantiates the
+                        * pages, in which case there will be some
+                        * sitting on the local LRU cache. Try to
+                        * avoid the expensive remote drain and the
+                        * second cache tree walk below by flushing
+                        * them out right away.
+                        */
+                       lru_add_drain();
+
+                       count = invalidate_mapping_pages(mapping,
                                                start_index, end_index);
 
                        /*