From: Li Zefan <lizf@cn.fujitsu.com>
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>,
"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH] Reduce size of swap_cgroup by CSS ID
Date: Fri, 06 Feb 2009 10:07:40 +0800 [thread overview]
Message-ID: <498B9B6C.3000808@cn.fujitsu.com> (raw)
In-Reply-To: <20090205185959.7971dee4.kamezawa.hiroyu@jp.fujitsu.com>
> +/*
> + * A helper function to get mem_cgroup from ID. must be called under
> + * rcu_read_lock(). Because css_tryget() is called under this, css_put
> + * should be called later.
> + */
> +static struct mem_cgroup *mem_cgroup_lookup_get(unsigned short id)
> +{
> + struct cgroup_subsys_state *css;
> +
> + /* ID 0 is unused ID */
> + if (!id)
> + return NULL;
> + css = css_lookup(&mem_cgroup_subsys, id);
> + if (css && css_tryget(css))
> + return container_of(css, struct mem_cgroup, css);
> + return NULL;
> +}
the returned mem_cgroup needn't be protected by rcu_read_lock(), so I
think this is better:
rcu_read_lock();
css = css_lookup(&mem_cgroup_subsys, id);
rcu_read_unlock();
and no lock is needed when calling mem_cgroup_lookup_get().
> * Returns old value at success, NULL at failure.
> * (Of course, old value can be NULL.)
> */
> -struct mem_cgroup *swap_cgroup_record(swp_entry_t ent, struct mem_cgroup *mem)
> +unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
kernel-doc needs to be updated
> * lookup_swap_cgroup - lookup mem_cgroup tied to swap entry
> * @ent: swap entry to be looked up.
> *
> - * Returns pointer to mem_cgroup at success. NULL at failure.
> + * Returns CSS ID of mem_cgroup at success. NULL at failure.
s/NULL/0/
> */
> -struct mem_cgroup *lookup_swap_cgroup(swp_entry_t ent)
> +unsigned short lookup_swap_cgroup(swp_entry_t ent)
WARNING: multiple messages have this Message-ID (diff)
From: Li Zefan <lizf@cn.fujitsu.com>
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>,
"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH] Reduce size of swap_cgroup by CSS ID
Date: Fri, 06 Feb 2009 10:07:40 +0800 [thread overview]
Message-ID: <498B9B6C.3000808@cn.fujitsu.com> (raw)
In-Reply-To: <20090205185959.7971dee4.kamezawa.hiroyu@jp.fujitsu.com>
> +/*
> + * A helper function to get mem_cgroup from ID. must be called under
> + * rcu_read_lock(). Because css_tryget() is called under this, css_put
> + * should be called later.
> + */
> +static struct mem_cgroup *mem_cgroup_lookup_get(unsigned short id)
> +{
> + struct cgroup_subsys_state *css;
> +
> + /* ID 0 is unused ID */
> + if (!id)
> + return NULL;
> + css = css_lookup(&mem_cgroup_subsys, id);
> + if (css && css_tryget(css))
> + return container_of(css, struct mem_cgroup, css);
> + return NULL;
> +}
the returned mem_cgroup needn't be protected by rcu_read_lock(), so I
think this is better:
rcu_read_lock();
css = css_lookup(&mem_cgroup_subsys, id);
rcu_read_unlock();
and no lock is needed when calling mem_cgroup_lookup_get().
> * Returns old value at success, NULL at failure.
> * (Of course, old value can be NULL.)
> */
> -struct mem_cgroup *swap_cgroup_record(swp_entry_t ent, struct mem_cgroup *mem)
> +unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
kernel-doc needs to be updated
> * lookup_swap_cgroup - lookup mem_cgroup tied to swap entry
> * @ent: swap entry to be looked up.
> *
> - * Returns pointer to mem_cgroup at success. NULL at failure.
> + * Returns CSS ID of mem_cgroup at success. NULL at failure.
s/NULL/0/
> */
> -struct mem_cgroup *lookup_swap_cgroup(swp_entry_t ent)
> +unsigned short lookup_swap_cgroup(swp_entry_t ent)
--
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-06 2:08 UTC|newest]
Thread overview: 20+ 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 9:59 ` KAMEZAWA Hiroyuki
2009-02-05 13:17 ` Paul E. McKenney
2009-02-05 13:17 ` Paul E. McKenney
2009-02-05 13:27 ` KAMEZAWA Hiroyuki
2009-02-05 13:27 ` KAMEZAWA Hiroyuki
2009-02-06 2:07 ` Li Zefan [this message]
2009-02-06 2:07 ` Li Zefan
2009-02-06 2:18 ` KAMEZAWA Hiroyuki
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-09 5:55 ` KAMEZAWA Hiroyuki
2009-02-10 8:07 ` Balbir Singh
2009-02-10 8:07 ` Balbir Singh
2009-02-10 8:50 ` KAMEZAWA Hiroyuki
2009-02-10 8:50 ` KAMEZAWA Hiroyuki
2009-02-23 5:58 ` Daisuke Nishimura
2009-02-23 5:58 ` Daisuke Nishimura
2009-02-24 0:10 ` KAMEZAWA Hiroyuki
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=498B9B6C.3000808@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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.