[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20110201085021.fa975a56.kamezawa.hiroyu@jp.fujitsu.com>
Date: Tue, 1 Feb 2011 08:50:21 +0900
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Johannes Weiner <hannes@...xchg.org>, nishimura@....nes.nec.co.jp,
balbir@...ux.vnet.ibm.com, minchan.kim@...il.com,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [patch 2/3] memcg: prevent endless loop when charging huge
pages to near-limit group
On Mon, 31 Jan 2011 14:41:31 -0800
Andrew Morton <akpm@...ux-foundation.org> wrote:
> On Mon, 31 Jan 2011 15:03:54 +0100
> Johannes Weiner <hannes@...xchg.org> wrote:
>
> > +static inline bool res_counter_check_margin(struct res_counter *cnt,
> > + unsigned long bytes)
> > +{
> > + bool ret;
> > + unsigned long flags;
> > +
> > + spin_lock_irqsave(&cnt->lock, flags);
> > + ret = cnt->limit - cnt->usage >= bytes;
> > + spin_unlock_irqrestore(&cnt->lock, flags);
> > + return ret;
> > +}
> > +
> > static inline bool res_counter_check_under_soft_limit(struct res_counter *cnt)
> > {
> > bool ret;
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index 73ea323..c28072f 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -1111,6 +1111,15 @@ static bool mem_cgroup_check_under_limit(struct mem_cgroup *mem)
> > return false;
> > }
> >
> > +static bool mem_cgroup_check_margin(struct mem_cgroup *mem, unsigned long bytes)
> > +{
> > + if (!res_counter_check_margin(&mem->res, bytes))
> > + return false;
> > + if (do_swap_account && !res_counter_check_margin(&mem->memsw, bytes))
> > + return false;
> > + return true;
> > +}
>
> argh.
>
> If you ever have a function with the string "check" in its name, it's a
> good sign that you did something wrong.
>
> Check what? Against what? Returning what?
>
> mem_cgroup_check_under_limit() isn't toooo bad - the name tells you
> what's being checked and tells you what to expect the return value to
> mean.
>
> But "res_counter_check_margin" and "mem_cgroup_check_margin" are just
> awful. Something like
>
> bool res_counter_may_charge(counter, bytes)
>
> would be much clearer.
>
> If we really want to stick with the "check" names (perhaps as an ironic
> reference to res_counter's past mistakes) then please at least document
> the sorry things?
>
Ah, I ack the concept of patch.
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Johannes, could you change name ? I'm sorry.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists