All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Menage <menage@google.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	mingo@elte.hu,
	"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
	"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
	"lizf@cn.fujitsu.com" <lizf@cn.fujitsu.com>
Subject: Re: [PATCH][rc1] cgroup: catch bad css refcnt at css_put
Date: Mon, 28 Sep 2009 07:20:08 -0700	[thread overview]
Message-ID: <6599ad830909280720u6f70e52cp33b89c02c7e389fa@mail.gmail.com> (raw)
In-Reply-To: <20090928181310.9492a8a2.kamezawa.hiroyu@jp.fujitsu.com>

On Mon, Sep 28, 2009 at 2:13 AM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@jp.fujitsu.com> wrote:
> This is a patch for checking css->refcnt's sanity at css_put().
>
> BTW, I noticed that...css->refcnt may overflow if used with memcg...
> Now, refcnt is incremented per a page. Paul, do you have any idea ?
> (Ah, yes. "don't use css->refcnt per page" is maybe reasonable but
>  it will be big change..)
>
> ==
> __css_put() doesn't check a bug as refcnt goes to minus.
> I think it should be caught. This patch adds a check for it.
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Acked-by: Paul Menage <menage@google.com>

Looks reasonable, although there's no guarantee that it will warn on a
buggy release rather than a correct release that occur after a buggy
release.

> ---
>  kernel/cgroup.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.32-rc1/kernel/cgroup.c
> ===================================================================
> --- linux-2.6.32-rc1.orig/kernel/cgroup.c
> +++ linux-2.6.32-rc1/kernel/cgroup.c
> @@ -3708,8 +3708,10 @@ static void check_for_release(struct cgr
>  void __css_put(struct cgroup_subsys_state *css)
>  {
>        struct cgroup *cgrp = css->cgroup;
> +       int val;
>        rcu_read_lock();
> -       if (atomic_dec_return(&css->refcnt) == 1) {
> +       val = atomic_dec_return(&css->refcnt);
> +       if (val == 1) {
>                if (notify_on_release(cgrp)) {
>                        set_bit(CGRP_RELEASABLE, &cgrp->flags);
>                        check_for_release(cgrp);
> @@ -3717,6 +3719,7 @@ void __css_put(struct cgroup_subsys_stat
>                cgroup_wakeup_rmdir_waiter(cgrp);
>        }
>        rcu_read_unlock();
> +       WARN_ON(val < 1);
>  }
>
>  /*
>
>

  reply	other threads:[~2009-09-28 14:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-25 21:35 mmotm 2009-09-25-14-35 uploaded akpm
2009-09-25 21:35 ` akpm
2009-09-28  6:42 ` Question: RCU stall detected in memcg (Re: " KAMEZAWA Hiroyuki
2009-09-28  8:33   ` KAMEZAWA Hiroyuki
2009-09-28  9:06   ` [BUGFIX][PATCH][rc1] memcg: fix refcnt goes to minus KAMEZAWA Hiroyuki
2009-09-28  9:13     ` [PATCH][rc1] cgroup: catch bad css refcnt at css_put KAMEZAWA Hiroyuki
2009-09-28 14:20       ` Paul Menage [this message]
2009-09-29  3:06         ` KAMEZAWA Hiroyuki
2009-09-29  0:50       ` Li Zefan
2009-09-29  2:55         ` KAMEZAWA Hiroyuki
2009-09-29  3:09         ` [PATCH][rc1] cgroup: catch bad css refcnt at css_put v2 KAMEZAWA Hiroyuki
2009-09-28  9:32     ` [BUGFIX][PATCH][rc1] memcg: fix refcnt goes to minus Balbir Singh
2009-09-28 11:22       ` KAMEZAWA Hiroyuki
2009-09-28  9:22   ` Question: RCU stall detected in memcg (Re: mmotm 2009-09-25-14-35 uploaded Balbir Singh
2009-09-28 11:26     ` KAMEZAWA Hiroyuki
2009-09-28  9:34   ` Paul E. McKenney
2009-09-28 11:30     ` KAMEZAWA Hiroyuki
2009-09-28 20:34 ` [PATCH -mmotm] ecryptfs: depends on CRYPTO Randy Dunlap
2009-09-29  0:10   ` Tyler Hicks
2009-09-29  0:20     ` Randy Dunlap
2009-09-29 17:08       ` Tyler Hicks
2009-09-29 17:17         ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6599ad830909280720u6f70e52cp33b89c02c7e389fa@mail.gmail.com \
    --to=menage@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.