All of lore.kernel.org
 help / color / mirror / Atom feed
* cgroup attach task - slogging cpu
@ 2013-10-04  5:25 anjana vk
       [not found] ` <CALPf4Tz+Gf_Q7wKKBufCc1mtV1qVPVrOW0S1qhHxfOv6pJa2Kg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: anjana vk @ 2013-10-04  5:25 UTC (permalink / raw)
  To: oleg-H+wXaHxf7aLQT0dZR+AlfA, tj-DgEjT+Ai2ygdnm+yROfE0A
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1651 bytes --]

Hi Oleg, All

I saw an issue of CPU slogging posted in
https://lkml.org/lkml/2013/8/28/283, and require your valuable
suggestion on a very similar issue I am facing.

We are facing the issue of cpu slogging in the function
    cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
bool threadgroup)
in the do-while loop which iterates over the threadgroup.

 rcu_read_lock();
 do {
 struct task_and_cgroup ent;

 /* @tsk either already exited or can't exit until the end */
 if (tsk->flags & PF_EXITING)
 continue;

 /* as per above, nr_threads may decrease, but not increase. */
 BUG_ON(i >= group_size);
 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)
 continue;
 /*
 * saying GFP_ATOMIC has no effect here because we did prealloc
 * earlier, but it's good form to communicate our expectations.
 */
 retval = flex_array_put(group, i, &ent, GFP_ATOMIC);
 BUG_ON(retval != 0);
 i++;

 if (!threadgroup)
 break;
 } while_each_thread(leader, tsk);

Problem Observed:
In this loop, in case of a single thread, and argument “bool
threadgroup” as “false” and
if(ent.cgrp == cgrp) is true
we will continue to the next thread instead of breaking out of the loop.

Possible Solution and Doubt:
When a break condition was added as shown in the patch attached, the
cpu sluggishness was not occurring.
Can you please provide your suggestions, if this is the right way to
fix the above mentioned issue.
Also, if a fix is already in for this, can you please guide me to that.

Thanks and Regards
Anjana

[-- Attachment #2: cgroup_singe_thread_attach.patch --]
[-- Type: application/octet-stream, Size: 737 bytes --]

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 1f53387..cae8416 100644
--- 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;
 		/*
 		 * saying GFP_ATOMIC has no effect here because we did prealloc
@@ -2199,7 +2201,6 @@ retry_find_task:
 	ret = cgroup_attach_task(cgrp, tsk, threadgroup);
 
 	threadgroup_unlock(tsk);
-
 	put_task_struct(tsk);
 out_unlock_cgroup:
 	mutex_unlock(&cgroup_mutex);

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2013-10-15 13:34 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-04  5:25 cgroup attach task - slogging cpu anjana vk
     [not found] ` <CALPf4Tz+Gf_Q7wKKBufCc1mtV1qVPVrOW0S1qhHxfOv6pJa2Kg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-04 13:02   ` Oleg Nesterov
     [not found]     ` <20131004130207.GA9338-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-07 18:45       ` Tejun Heo
     [not found]         ` <20131007184507.GD27396-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-10-08 14:58           ` Oleg Nesterov
     [not found]             ` <20131008145833.GA15600-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-09  5:35               ` Li Zefan
     [not found]                 ` <5254EB2A.7090803-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-10-09 13:30                   ` Oleg Nesterov
     [not found]                     ` <20131009133047.GA12414-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-10-09 14:05                       ` Oleg Nesterov
2013-10-09 16:54                         ` cgroup_attach_task && while_each_thread (Was: cgroup attach task - slogging cpu) Oleg Nesterov
2013-10-09 16:54                           ` Oleg Nesterov
2013-10-11 13:15                           ` Li Zefan
2013-10-11 13:15                             ` Li Zefan
2013-10-11 16:00                             ` Oleg Nesterov
2013-10-11 16:00                               ` Oleg Nesterov
2013-10-12  2:59                               ` [PATCH] cgroup: fix to break the while loop in cgroup_attach_task() correctly Li Zefan
2013-10-12  2:59                                 ` Li Zefan
2013-10-13 20:08                                 ` Tejun Heo
2013-10-13 20:08                                   ` Tejun Heo
2013-10-15  5:04                               ` cgroup_attach_task && while_each_thread (Was: cgroup attach task - slogging cpu) anjana vk
2013-10-15  5:04                                 ` anjana vk
2013-10-15 13:34                                 ` Tejun Heo
2013-10-15 13:34                                   ` Tejun Heo
     [not found]                         ` <CAChhN7RerxpSadqyosUeSKFg+qcOpO4d-maEKBZ0rvOQGvN27g@mail.gmail.com>
     [not found]                           ` <CAChhN7RerxpSadqyosUeSKFg+qcOpO4d-maEKBZ0rvOQGvN27g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-10  4:22                             ` cgroup attach task - slogging cpu anjana vk
2013-10-10 11:11                             ` Oleg Nesterov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.