Re: cgroup attach task - slogging cpu

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

 



>>>> --- a/kernel/cgroup.c
>>>> +++ b/kernel/cgroup.c
>>>> @@ -2002,7 +2002,9 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
>>>>  		ent.task = tsk;
>>>>  		ent.cgrp = task_cgroup_from_root(tsk, root);
>>>>  		/* nothing to do if this task is already in the cgroup */
>>>> -		if (ent.cgrp == cgrp)
>>>> +		if (ent.cgrp == cgrp && !threadgroup)
>>>> +			break;
>>>> +		else if(ent.cgrp == cgrp)
>>>>  			continue;
>>
>> I have no idea know how this would make any difference.  Hmm...
> 
> I guess the patch needs a cleanup, but this code looks indeed wrong
> even if we forget about rcu/while_each_thread? Really, we should not
> "continue" if threadgroup == T, in this case we miss the last
> 
> 		if (!threadgroup)
> 			break;
> 

Yes, this is wrong.

lxc34:/mnt/tmp # echo 5207 > tasks
lxc34:/mnt/tmp # cat tasks
5207
lxc34:/mnt/tmp # echo 5207 > tasks
lxc34:/mnt/tmp # cat tasks
5207
5215
lxc34:/mnt/tmp # echo 5207 > tasks
lxc34:/mnt/tmp # cat tasks
5207
5215
5216

I wanted to attach 5207 to the cgroup, and in this case it should be
a no-op because the thread was already in this cgroup, but the result
was another thread got attached to it.

Anjana, could you revise the patch and send it out with proper changelog
and Signed-off-by? And please add "Cc: <stable@xxxxxxxxxxxxxxx> # 3.9+"

The cpu slogging issue is another bug that we're working on.

> check in the main loop. So Anjana was right (sorry again!), and we
> should probably do
> 
> 		ent.cgrp = task_cgroup_from_root(...);
> 		if (ent.cgrp != cgrp) {
> 			retval = flex_array_put(...);
> 			...
> 		}
> 
> 		if (!threadgroup)
> 			break;
> 

Or

do {
	...
	if (ent.cgrp == cgrp)
		goto next;
	...
next:
	if (!threadgroup)
		break;
} while (...);

> Or I am wrong again?
> 

No, you are not! :)

--
To unsubscribe from this list: send the line "unsubscribe cgroups" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux