From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"lizf@cn.fujitsu.com" <lizf@cn.fujitsu.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
nishimura@mxp.nes.nec.co.jp
Subject: Re: [RFC][PATCH] Reduce size of swap_cgroup by CSS ID v2
Date: Mon, 23 Feb 2009 14:58:28 +0900 [thread overview]
Message-ID: <20090223145828.d14ff015.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20090209145557.d0754a9f.kamezawa.hiroyu@jp.fujitsu.com>
I'm sorry for my late reply.
It looks good basically, but I have 1 comment.
> static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)
> {
> - struct mem_cgroup *mem;
> + unsigned short id;
> + struct mem_cgroup *mem = NULL;
> swp_entry_t ent;
>
> if (!PageSwapCache(page))
> return NULL;
>
> ent.val = page_private(page);
> - mem = lookup_swap_cgroup(ent);
> - if (!mem)
> - return NULL;
> + id = lookup_swap_cgroup(ent);
> + rcu_read_lock();
> + mem = mem_cgroup_lookup(id);
> if (!css_tryget(&mem->css))
We should check whether "mem" is NULL or not before css_tryget, because
"mem" can be NULL(or "id" can be 0) if the page is on swapcache,
that is, remove_from_swap_cache has not been called yet.
Actually, I got NULL pointer dereference bug here.
> - return NULL;
> + mem = NULL;
> + rcu_read_unlock();
> return mem;
> }
>
Thanks,
Daisuke Nishimura.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-02-23 6:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-05 9:59 [RFC][PATCH] Reduce size of swap_cgroup by CSS ID KAMEZAWA Hiroyuki
2009-02-05 13:17 ` Paul E. McKenney
2009-02-05 13:27 ` KAMEZAWA Hiroyuki
2009-02-06 2:07 ` Li Zefan
2009-02-06 2:18 ` KAMEZAWA Hiroyuki
2009-02-09 5:55 ` [RFC][PATCH] Reduce size of swap_cgroup by CSS ID v2 KAMEZAWA Hiroyuki
2009-02-10 8:07 ` Balbir Singh
2009-02-10 8:50 ` KAMEZAWA Hiroyuki
2009-02-23 5:58 ` Daisuke Nishimura [this message]
2009-02-24 0:10 ` KAMEZAWA Hiroyuki
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=20090223145828.d14ff015.nishimura@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=balbir@linux.vnet.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox