Commit 8a144612 authored by Andrew Yang's avatar Andrew Yang Committed by Andrew Morton

fs: drop_caches: draining pages before dropping caches

We expect a file page access after dropping caches should be a major
fault, but sometimes it's still a minor fault.  That's because a file page
can't be dropped if it's in a per-cpu pagevec.  Draining all pages from
per-cpu pagevec to lru list before trying to drop caches.

Link: https://lkml.kernel.org/r/20230630092203.16080-1-andrew.yang@mediatek.comSigned-off-by: default avatarAndrew Yang <andrew.yang@mediatek.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 86327e8e
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/writeback.h> #include <linux/writeback.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/swap.h>
#include "internal.h" #include "internal.h"
/* A global variable is a bit ugly, but it keeps the code simple */ /* A global variable is a bit ugly, but it keeps the code simple */
...@@ -59,6 +60,7 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, ...@@ -59,6 +60,7 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write,
static int stfu; static int stfu;
if (sysctl_drop_caches & 1) { if (sysctl_drop_caches & 1) {
lru_add_drain_all();
iterate_supers(drop_pagecache_sb, NULL); iterate_supers(drop_pagecache_sb, NULL);
count_vm_event(DROP_PAGECACHE); count_vm_event(DROP_PAGECACHE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment