Re: Q: cgroup: Questions about possible issues in cgroup locking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/21, Mandeep Singh Baines wrote:
>
> Oleg Nesterov (oleg@xxxxxxxxxx) wrote:
> > +/*
> > + * rcu-safe, but should start at ->group_leader.
> > + * thread_group_leader(g) protects against the race with exec which
> > + * removes the leader from list.
> > + * smp_rmb() pairs with implicit mb() implied by unlock + lock in
> > + * de_thread()->release_task() path.
> > + */
> > +#define while_each_thread_rcu(g, t)				\
> > +	while ((t = next_thread(t)) != g &&			\
> > +		({ smp_rmb(); thread_group_leader(g); }))
> > +
>
> Couldn't you miss the exec_thread if:
>
> t = exec_thread && !thread_group_leader(g)

Yes, we already discussed this, iirc.

I was going to write that this is fine, but then I changed my mind.
Indeed, it is not good while_each_thread_rcu() can miss the new leader.

> Could we change do_prlimit()? Especially since its slow path.

But do_prlimit() is correct. It sees the unhashed task under tasklist,
task->group_leader should be correct.

> I really like you're earlier solution (ignoring barrier):
>
> #define while_each_thread(g, t) \
> 	while (t->group_leader == g->group_leader && (t = next_thread(t)) != g)

The problem is "ignoring barrier and races".

OK, I'll try to think again.

Oleg.

_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/containers


[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux