Re: [PATCH v4 4/5] page_idle: Drain all LRU pagevec before idle tracking

Michal Hocko
2019-08-06T08:44:08Z

On Mon 05-08-19 13:04:50, Joel Fernandes (Google) wrote:
> During idle tracking, we see that sometimes faulted anon pages are in
> pagevec but are not drained to LRU. Idle tracking considers pages only
> on LRU. Drain all CPU's LRU before starting idle tracking.

Please expand on why does this matter enough to introduce a potentially
expensinve draining which has to schedule a work on each CPU and wait
for them to finish.

> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> ---
> mm/page_idle.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/mm/page_idle.c b/mm/page_idle.c
> index a5b00d63216c..2972367a599f 100644
> --- a/mm/page_idle.c
> +++ b/mm/page_idle.c
> @@ -180,6 +180,8 @@ static ssize_t page_idle_bitmap_read(struct file *file, struct kobject *kobj,
> unsigned long pfn, end_pfn;
> int bit, ret;
>
> + lru_add_drain_all();
> +
> ret = page_idle_get_frames(pos, count, NULL, &pfn, &end_pfn);
> if (ret == -ENXIO)
> return 0; /* Reads beyond max_pfn do nothing */
> @@ -211,6 +213,8 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj,
> unsigned long pfn, end_pfn;
> int bit, ret;
>
> + lru_add_drain_all();
> +
> ret = page_idle_get_frames(pos, count, NULL, &pfn, &end_pfn);
> if (ret)
> return ret;
> @@ -428,6 +432,8 @@ ssize_t page_idle_proc_generic(struct file *file, char __user *ubuff,
> walk.private = &priv;
> walk.mm = mm;
>
> + lru_add_drain_all();
> +
> down_read(&mm->mmap_sem);
>
> /*
> --
> 2.22.0.770.g0f2c4a37fd-goog

--
Michal Hocko
SUSE Labs