Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl for protecting the working set

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mandeep Singh Baines
Date: Monday, November 1, 2010 - 11:24 am

KOSAKI Motohiro (kosaki.motohiro@jp.fujitsu.com) wrote:

swap would be intersting if we could somehow control swap thrashing. Maybe
we could add min_anonlist_kbytes. Just kidding:)


mlock is too coarse grain. It requires locking the whole file in memory.
The chrome and X binaries are quite large so locking them would waste a lot
of memory. We could lock just the pages that are part of the working set but
that is difficult to do in practice. Its unmaintainable if you do it
statically. If you do it at runtime by mlocking the working set, you're
sort of giving up on mm's active list.

Like akpm, I'm sad that we need this patch. I'd rather the kernel did a better
job of identifying the working set. We did look at ways to do a better
job of keeping the working set in the active list but these were tricker
patches and never quite worked out. This patch is simple and works great.

Under memory pressure, I see the active list get smaller and smaller. Its
getting smaller because we're scanning it faster and faster, causing more
and more page faults which slows forward progress resulting in the active
list getting smaller still. One way to approach this might to make the
scan rate constant and configurable. It doesn't seem right that we scan
memory faster and faster under low memory. For us, we'd rather OOM than
evict pages that are likely to be accessed again so we'd prefer to make
a conservative estimate as to what belongs in the working set. Other
folks (long computations) might want to reclaim more aggressively.


50M was small enough that we were comfortable with keeping 50M of file pages
in memory and large enough that it is bigger than the working set. I tested
by loading up a bunch of popular web sites in chrome and then observing what
happend when I ran out of memory. With 50M, I saw almost no thrashing and
the system stayed responsive even under low memory. but I wanted to be
conservative since I'm really just guessing.

Other users could calculate their value by doing something similar. Load
up the system (exhaust free memory) with a typical load and then observe
file io via vmstat. They can then set min_filelist_kbytes to the value
where they see a tolerable amounting of thrashing (page faults, block io).


I think this feature should be useful to a lot of embedded applications where
OOM is OK, especially web browsing applications where the user is OK with
losing 1 of many tabs they have open. However, I consider this patch a
stop-gap. I think the real solution is to do a better job of protecting
the active list.


Yes, will definitely look at OOM notifier. Currently trying to see if we can
get by with oomadj. With OOM notifier you'd have to respond earlier so you
might OOM more. However, with a notifier you might be able to take action that
might prevent OOM altogether.

I see memcg more as an isolation mechanism but I guess you could use it to
isolate the working set from anon browser tab data as Kamezawa suggests.

Regards,
Mandeep

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] RFC: vmscan: add min_filelist_kbytes sysctl for pr ..., Mandeep Singh Baines, (Thu Oct 28, 12:15 pm)
Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl fo ..., Mandeep Singh Baines, (Thu Oct 28, 3:03 pm)
Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl fo ..., Mandeep Singh Baines, (Thu Oct 28, 3:13 pm)
Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl fo ..., KAMEZAWA Hiroyuki, (Thu Oct 28, 5:04 pm)
Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl fo ..., Mandeep Singh Baines, (Mon Nov 1, 11:24 am)
Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl fo ..., Mandeep Singh Baines, (Mon Nov 1, 12:43 pm)
Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl fo ..., Mandeep Singh Baines, (Wed Nov 3, 3:40 pm)
Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl fo ..., Mandeep Singh Baines, (Wed Nov 3, 6:52 pm)
Re: [PATCH] RFC: vmscan: add min_filelist_kbytes sysctl fo ..., Mandeep Singh Baines, (Mon Nov 8, 2:55 pm)