Re: [PATCH][BUGFIX] memcg fix zone congestion

KAMEZAWA Hiroyuki
2011-05-13T06:59:45Z

On Thu, 12 May 2011 23:25:00 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Fri, 13 May 2011 12:10:30 +0900 KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
>
> >
> > ZONE_CONGESTED should be a state of global memory reclaim.
> > If not, a busy memcg sets this and give unnecessary throttoling in
> > wait_iff_congested() against memory recalim in other contexts. This makes
> > system performance bad.
> >
> > I'll think about "memcg is congested!" flag is required or not, later.
> > But this fix is required 1st.
> >
> > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> > ---
> > mm/vmscan.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > Index: mmotm-May11/mm/vmscan.c
> > ===================================================================
> > --- mmotm-May11.orig/mm/vmscan.c
> > +++ mmotm-May11/mm/vmscan.c
> > @@ -941,7 +941,8 @@ keep_lumpy:
> > * back off and wait for congestion to clear because further reclaim
> > * will encounter the same problem
> > */
> > - if (nr_dirty == nr_congested && nr_dirty != 0)
> > + if (scanning_global_lru(sc) &&
> > + nr_dirty == nr_congested && nr_dirty != 0)
> > zone_set_flag(zone, ZONE_CONGESTED);
> >
>
> nit: which is more probable? nr_dirty==nr_congested or
> scanning_global_lru(sc)?
>
> If the user is actually _using_ memcg then
>

If the user uses memcg, yes, nr_dirty == nr_congested is more probable.
If user doesn't, scanning_global_lru() returns always true.

> --- a/mm/vmscan.c~a
> +++ a/mm/vmscan.c
> @@ -937,7 +937,7 @@ keep_lumpy:
> * back off and wait for congestion to clear because further reclaim
> * will encounter the same problem
> */
> - if (nr_dirty == nr_congested && nr_dirty != 0)
> + if (nr_dirty == nr_congested && scanning_global_lru(sc) && nr_dirty)
> zone_set_flag(zone, ZONE_CONGESTED);
>
> free_page_list(&free_pages);
>
>
> is more efficient. If the user isn't using memcg then your patch is faster?
>

Hmm, maybe your fix is always faster. But in many case, if nr_congested == nr_dirty,
nr_dirty == 0 because vmscan just finds clean pages...fast path.
So, nr_dirty should be 1st ?

How about this ?
==

ZONE_CONGESTED should be a state of global memory reclaim.
Changelog:v1->v2
- fixed the order of conditions.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
mm/vmscan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: mmotm-May11/mm/vmscan.c
===================================================================
--- mmotm-May11.orig/mm/vmscan.c
+++ mmotm-May11/mm/vmscan.c
@@ -941,7 +941,7 @@ keep_lumpy:
* back off and wait for congestion to clear because further reclaim
* will encounter the same problem
*/
- if (nr_dirty == nr_congested && nr_dirty != 0)
+ if (nr_dirty && nr_dirty == nr_congested && scanning_global_lru(sc))
zone_set_flag(zone, ZONE_CONGESTED);

free_page_list(&free_pages);