Re: [RFC][PATCH] oom_kill: avoid depends on total_vm and use realRSS/swap value for oom_score (Re: Memory overcommit

From: Minchan Kim
Date: Tue Oct 27 2009 - 03:56:56 EST


On Tue, 27 Oct 2009 16:45:26 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:

> On Tue, 27 Oct 2009 15:55:26 +0900
> Minchan Kim <minchan.kim@xxxxxxxxx> wrote:
>
> > >> Hmm.
> > >> I wonder why we consider VM size for OOM kiling.
> > >> How about RSS size?
> > >>
> > >
> > > Maybe the current code assumes "Tons of swap have been generated, already" if
> > > oom-kill is invoked. Then, just using mm->anon_rss will not be correct.
> > >
> > > Hm, should we count # of swap entries reference from mm ?....
> >
> > In Vedran case, he didn't use swap. So, Only considering vm is the problem.
> > I think it would be better to consider both RSS + # of swap entries as
> > Kosaki mentioned.
> >
> Then, maybe this kind of patch is necessary.
> This is on 2.6.31...then I may have to rebase this to mmotom.
> Added more CCs.
>
> Vedran, I'm glad if you can test this patch.
>
>
> ==
> Now, oom-killer's score uses mm->total_vm as its base value.
> But, in these days, applications like GUI program tend to use
> much shared libraries and total_vm grows too high even when
> pages are not fully mapped.
>
> For example, running a program "mmap" which allocates 1 GBbytes of
> anonymous memory, oom_score top 10 on system will be..
>
> score PID name
> 89924 3938 mixer_applet2
> 90210 3942 tomboy
> 94753 3936 clock-applet
> 101994 3919 pulseaudio
> 113525 4028 gnome-terminal
> 127340 1 init
> 128177 3871 nautilus
> 151003 11515 bash
> 256944 11653 mmap <-----------------use 1G of anon
> 425561 3829 gnome-session
>
> No one believes gnome-session is more guilty than "mmap".
>
> Instead of total_vm, we should use anon/file/swap usage of a process, I think.
> This patch adds mm->swap_usage and calculate oom_score based on
> anon_rss + file_rss + swap_usage.
> Considering usual applications, this will be much better information than
> total_vm. After this patch, the score on my desktop is
>
> score PID name
> 4033 3176 gnome-panel
> 4077 3113 xinit
> 4526 3190 python
> 4820 3161 gnome-settings-
> 4989 3289 gnome-terminal
> 7105 3271 tomboy
> 8427 3177 nautilus
> 17549 3140 gnome-session
> 128501 3299 bash
> 256106 3383 mmap
>
> This order is not bad, I think.
>
> Note: This adss new counter...then new cost is added.
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>

Thanks for making the patch.
Let's hear other's opinion. :)

--
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/