lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 28 Sep 2011 00:21:47 +0200
From:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
To:	Glauber Costa <glommer@...allels.com>
Cc:	Balbir Singh <bsingharora@...il.com>, linux-kernel@...r.kernel.org,
	paul@...lmenage.org, lizf@...fujitsu.com, daniel.lezcano@...e.fr,
	jbottomley@...allels.com
Subject: Re: [RFD 3/9] Display /proc/stat information per cgroup

On Tue, 2011-09-27 at 15:42 -0300, Glauber Costa wrote:
> >> +static inline void task_cgroup_account_field(struct task_struct *p,
> >> +                                            cputime64_t tmp, int index)
> >> +{
> >> +       struct kernel_stat *kstat;
> >> +       struct task_group *tg = task_group(p);
> >> +
> >> +       do {
> >> +               kstat = this_cpu_ptr(tg->cpustat);
> >> +               kstat->cpustat[index] = cputime64_add(kstat->cpustat[index],
> >> +                                                     tmp);
> >> +               tg = tg->parent;
> >> +       } while (tg);
> >> +}
> >
> > What protects the walk (tg = tg->parent)? Could you please document it
> I think that the fact that the hierarchy only grows down, thus parent 
> never changes (or am I wrong?)
> 
> And since we run all this with preempt disabled and with the runqueue 
> locked, we should have no problems.
> 
> Do you agree? 

Right, so the tg can't be destroyed unless its empty, us finding this
task in it means its not empty, we require rq->lock or p->pi_lock to
move the task.

However, afaict we don't actually have any of those locks.

That said, it should be sufficient to wrap the whole thing in
rcu_read_lock(), accounting one tick funny because a cgroup move race
isn't the end of the world and its really no different than moving the
task a little later anyway.

task_group() should complain about this if you compile a kernel with
CONFIG_PROVE_RCU.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ