From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, Balaji Rao <balajirrao@gmail.com>,
Dhaval Giani <dhaval@linux.vnet.ibm.com>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
Li Zefan <lizf@cn.fujitsu.com>, Paul Menage <menage@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
linux-arch@vger.kernel.org
Subject: Re: [RFC PATCH -tip] cpuacct: per-cgroup utime/stime statistics - v2
Date: Mon, 16 Mar 2009 10:07:54 +0530 [thread overview]
Message-ID: <20090316043754.GA3449@in.ibm.com> (raw)
In-Reply-To: <20090316103517.b0f8a20c.kamezawa.hiroyu@jp.fujitsu.com>
On Mon, Mar 16, 2009 at 10:35:17AM +0900, KAMEZAWA Hiroyuki wrote:
> On Thu, 12 Mar 2009 16:39:24 +0530
> Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:
>
> > #ifdef CONFIG_CGROUP_CPUACCT
> > static void cpuacct_charge(struct task_struct *tsk, u64 cputime);
> > +static void cpuacct_update_stats(struct task_struct *tsk,
> > + enum cpuacct_stat_index idx, cputime_t val);
> > #else
> > static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {}
> > +static void cpuacct_update_stats(struct task_struct *tsk,
> > + enum cpuacct_stat_index idx, cputime_t val) {}
> > #endif
> "static inline"
> if no "inline", the complier will show warning as
> "this function is defined but not used.."
Ok.
> >
> > +/*
> > + * Account the system/user time to the task's accounting group.
> > + */
> > +static void cpuacct_update_stats(struct task_struct *tsk,
> > + enum cpuacct_stat_index idx, cputime_t val)
> > +{
> > + struct cpuacct *ca;
> > +
> > + if (unlikely(!cpuacct_subsys.active))
> > + return;
> > +
> > + ca = task_ca(tsk);
> > +
> > + do {
> > + percpu_counter_add(&ca->cpustat[idx], val);
> > + ca = ca->parent;
> > + } while (ca);
> > +}
> > +
>
> IIUC, to make sure accessing "ca" to be safe, we need some condition.
> (task_lock() or some other.....
task_lock() protects tsk->cgroups->subsys[]. So can we hold task_lock()
to protect this walk ? But we do this cpuacct hierarchy walk for the
current task here. So can a current task's ca or ca's parents disappear
from under us ?
Regards,
Bharata.
next prev parent reply other threads:[~2009-03-16 4:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 11:09 [RFC PATCH -tip] cpuacct: per-cgroup utime/stime statistics - v2 Bharata B Rao
2009-03-16 1:35 ` KAMEZAWA Hiroyuki
2009-03-16 4:37 ` Bharata B Rao [this message]
2009-03-16 5:01 ` KAMEZAWA Hiroyuki
2009-03-16 7:13 ` Li Zefan
2009-03-16 8:47 ` Bharata B Rao
2009-03-16 8:58 ` Li Zefan
2009-03-16 8:58 ` Li Zefan
2009-03-17 6:23 ` Bharata B Rao
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=20090316043754.GA3449@in.ibm.com \
--to=bharata@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=balajirrao@gmail.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=dhaval@linux.vnet.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
--cc=mingo@elte.hu \
/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