From: Glauber Costa <glommer@parallels.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: <linux-kernel@vger.kernel.org>, <paul@paulmenage.org>,
<lizf@cn.fujitsu.com>, <daniel.lezcano@free.fr>,
<jbottomley@parallels.com>
Subject: Re: [PATCH 04/10] Display /proc/stat information per cgroup
Date: Wed, 5 Oct 2011 16:43:20 +0400 [thread overview]
Message-ID: <4E8C50E8.2030505@parallels.com> (raw)
In-Reply-To: <1317818294.6766.16.camel@twins>
On 10/05/2011 04:38 PM, Peter Zijlstra wrote:
> On Wed, 2011-10-05 at 16:10 +0400, Glauber Costa wrote:
>> On 10/05/2011 12:56 PM, Peter Zijlstra wrote:
>>> On Sun, 2011-10-02 at 23:21 +0400, Glauber Costa wrote:
>>>> +struct kernel_stat *task_group_kstat(struct task_struct *p)
>>>> +{
>>>> + struct task_group *tg;
>>>> + struct kernel_stat *kstat;
>>>> +
>>>> + rcu_read_lock();
>>>> + tg = task_group(p);
>>>> + kstat = tg->cpustat;
>>>> + rcu_read_unlock();
>>>> + return kstat;
>>>> +}
>>>
>>> Who keeps tg alive and kicking while you poke at its (cpustat) member?
>>
>> * All calls to this function currently pass current as a parameter
>> (Okay, maybe it is too generic and we should pass nothing at all, and
>> grab current within it)
>> * rcu_read_lock() guarantees that current will exist during this call,
>> and task_group won't change. (right?)
>
> The thing I worry about is:
>
> A (pid n) B
>
> kstat = task_group_kstat()
> echo n> /cgroup/something-else/pid
> rmdir /cgroup/group-that-had-A
> <timer interrupt>
> RCU complete
> <softirq>
> kfree(tg) etc..
>
> kstat->foo++;<-- *BOOM*
>
>
> The only way to avoid someone moving you around is by holding some
> cgroup lock, task->alloc_lock, task->pi_lock or the rq->lock where task
> runs. Alternatively keep rcu_read_lock() around the entire kstat usage.
>
>
Well, if I understand it correctly, we'd have to hold the lock around
the entire kstat usge as well, right?
Otherwise it can just explode. So rcu does seem the way to go. I do,
however, see the problem you are describing.
Maybe we can remove the rcu_read_lock() call and replace with a rcu
validation. Then patch all callers. (Including of course the current
users of kstat_cpu() all over). What do you think?
next prev parent reply other threads:[~2011-10-05 12:43 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-02 19:21 [PATCH 00/10] Per-cgroup /proc/stat information Glauber Costa
2011-10-02 19:21 ` [PATCH 01/10] trivial: initialize root cgroup's sibling list Glauber Costa
2011-10-02 19:21 ` [PATCH 02/10] Change cpustat fields to an array Glauber Costa
2011-10-02 19:21 ` [PATCH 03/10] Move /proc/stat logic inside sched.c Glauber Costa
2011-10-02 19:21 ` [PATCH 04/10] Display /proc/stat information per cgroup Glauber Costa
2011-10-05 8:56 ` Peter Zijlstra
2011-10-05 12:10 ` Glauber Costa
2011-10-05 12:38 ` Peter Zijlstra
2011-10-05 12:43 ` Glauber Costa [this message]
2011-10-05 9:04 ` Peter Zijlstra
2011-10-05 12:11 ` Glauber Costa
2011-10-02 19:21 ` [PATCH 05/10] Make total_forks per-cgroup Glauber Costa
2011-10-05 9:05 ` Peter Zijlstra
2011-10-05 12:12 ` Glauber Costa
2011-10-11 23:45 ` Frederic Weisbecker
2011-10-12 7:35 ` Glauber Costa
2011-10-12 12:59 ` Frederic Weisbecker
2011-10-12 12:59 ` Glauber Costa
2011-10-12 13:03 ` Frederic Weisbecker
2011-10-12 13:03 ` Glauber Costa
2011-10-12 14:03 ` Frederic Weisbecker
2011-10-02 19:21 ` [PATCH 06/10] per-cgroup boot time Glauber Costa
2011-10-02 19:21 ` [PATCH 07/10] Report steal time for cgroup Glauber Costa
2011-10-02 19:21 ` [PATCH 08/10] provide a version of cpuacct statistics inside cpu cgroup Glauber Costa
2011-10-05 9:10 ` Peter Zijlstra
2011-10-05 12:16 ` Glauber Costa
2011-10-02 19:21 ` [PATCH 09/10] provide a version of cpuusage " Glauber Costa
2011-10-05 9:14 ` Peter Zijlstra
2011-10-05 12:17 ` Glauber Costa
2011-10-05 9:46 ` Peter Zijlstra
2011-10-05 12:22 ` Glauber Costa
2011-10-05 12:31 ` Peter Zijlstra
2011-10-05 15:05 ` Glauber Costa
2011-10-02 19:21 ` [PATCH 10/10] Change CPUACCT to default n Glauber Costa
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=4E8C50E8.2030505@parallels.com \
--to=glommer@parallels.com \
--cc=a.p.zijlstra@chello.nl \
--cc=daniel.lezcano@free.fr \
--cc=jbottomley@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=paul@paulmenage.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