Messages in this thread | | | Date | Thu, 26 Feb 2009 17:40:33 +0900 | From | KAMEZAWA Hiroyuki <> | Subject | Re: [PATCH] cpuacct: add a branch prediction |
| |
On Thu, 26 Feb 2009 16:35:33 +0800 Li Zefan <lizf@cn.fujitsu.com> wrote:
> ca is not checked before hierarchy support, and it's a side-effect. > > Before cpuacct is initialized, css == task->cgroups->subsys[cpuacct_subsys] == NULL, > but ca = task_ca(tsk) is not necessarily NULL, unless struct cgroup_subsys_state is the > first member of struct cpuacct. > > And the above code actually should be: > > do { > ... > } while (ca->parent); > I'll send no more objections to this patch itself.
But IMHO, this loop is tooo bad, I think. The hierarchy information should be gathered by read-side and the total code should be
void charge_statistics(tsk, cputime) { ca = task_ca(tsk) /* ca can be null while init */ if (likely(ca)) { u64 *cpuusage = percpu_ptr(ca->cpuusage, task_cpu(tsk)) *cpuusage += cputime } } (Need changes to read-side and create/destroy of cpuacct cgroups.)
Thanks, -Kame
| |