mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Menage <menage@google.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Containers <containers@lists.linux-foundation.org>
Subject: Re: [PATCH] cpuset: rcu_read_lock() to protect task_cs()
Date: Fri, 21 Nov 2008 10:36:37 -0800	[thread overview]
Message-ID: <6599ad830811211036k419ff716h6068d532c9942d73@mail.gmail.com> (raw)
In-Reply-To: <49267621.2070706@cn.fujitsu.com>

On Fri, Nov 21, 2008 at 12:49 AM, Lai Jiangshan <laijs@cn.fujitsu.com> wrote:
>
> task_cs() calls cgroup_subsys_state().

You mean it calls task_subsys_state().

>
> we must use rcu_read_lock() to protect cgroup_subsys_state().
>
> it's correct that top_cpuset is never freed, but cgroup_subsys_state()
> accesses css_set, this css_set maybe freed when task_cs() called.

It would be nice to have an RCU debug mode where rcu_dereference()
does a WARN() if it's invoked not under rcu_read_lock().

>
> we use use rcu_read_lock() to protect it.
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> index 3e00526..e0e087e 100644
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -363,14 +363,9 @@ void cpuset_update_task_memory_state(void)
>        struct task_struct *tsk = current;
>        struct cpuset *cs;
>
> -       if (task_cs(tsk) == &top_cpuset) {
> -               /* Don't need rcu for top_cpuset.  It's never freed. */
> -               my_cpusets_mem_gen = top_cpuset.mems_generation;
> -       } else {
> -               rcu_read_lock();
> -               my_cpusets_mem_gen = task_cs(tsk)->mems_generation;
> -               rcu_read_unlock();
> -       }
> +       rcu_read_lock();
> +       my_cpusets_mem_gen = task_cs(tsk)->mems_generation;
> +       rcu_read_unlock();

Yes, I guess this old cpusets assumption is no longer valid in cgroups.

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

Thanks

Paul

      reply	other threads:[~2008-11-21 18:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-21  8:49 Lai Jiangshan
2008-11-21 18:36 ` Paul Menage [this message]

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=6599ad830811211036k419ff716h6068d532c9942d73@mail.gmail.com \
    --to=menage@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=containers@lists.linux-foundation.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®