public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Paul Menage <menage@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux Containers <containers@lists.linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Paul Jackson <pj@sgi.com>
Subject: Re: [RFC] [PATCH] cgroup: add "procs" control file
Date: Sat, 21 Jun 2008 14:20:16 +0800	[thread overview]
Message-ID: <485C9DA0.9080803@cn.fujitsu.com> (raw)
In-Reply-To: <6599ad830806192237y8b10c4ao923375074aff56c5@mail.gmail.com>

Paul Menage wrote:
> On Wed, Jun 18, 2008 at 1:02 AM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>> - What to do if the attaching of a thread failed? continue to attach
>>  other threads, or stop and return error?
> 
> I think this is something that will have to be handled in the design
> of transactional cgroup attach.
> 

Is the following proposal feasable?
- call can_attach() for each thread before attaching them into the new group.
  This works for cpuset, doesn't it?
- the above may not always reasonable, for example for Kosaki-san's task cgroup.
  in this case, we require the subsystem to provide a can_attach_thread_group(),
  like:

static int task_cgroup_can_attach_group(struct cgroup_subsys *ss,
				  struct cgroup *cgrp, struct task_struct *tsk)
{
	struct task_cgroup *taskcg = task_cgroup_from_cgrp(cgrp);
	struct task_struct *t;
	int ret = 0;
	int nr_threads = 1;

	for (t = next_thread(tsk); t != tsk; t = next_thread(t)
		nr_threads++;

	spin_lock(&taskcg->lock);
	if (taskcg->nr_tasks + nr_threads > taskcg->max_tasks)
		ret = -EBUSY;
	spin_unlock(&taskcg->lock);

	return ret;
}

>> - When a sub-thread of a process is in the cgroup, but not its thread
>>  cgroup leader, what to do when 'cat procs'? just skip those threads?
> 
> Sounds reasonable. I think that in general the procs file is more
> useful as a write API than a read API anyway, for the reasons you
> indicate there.
> 
> 
>> +       tsk = attach_get_task(cgrp, pidbuf);
>> +       if (IS_ERR(tsk))
>> +               return PTR_ERR(tsk);
>> +
>> +       /* attach thread group leader */
> 
> Should we check that this is in fact a thread group leader?
> 

No need actually, I added this check originally and then removed it, but
forgot to remove the comment.

>> +
>> +       /* attach all sub-threads */
>> +       rcu_read_lock();
> 
> cgroup_attach_task() calls synchronize_rcu(), so it doesn't seem
> likely that rcu_read_lock() is useful here, and might even deadlock?
> 
> What are you trying to protect against with the RCU lock?
> 

Ah yes, bad here. I am trying to protect the thread list.

>>        {
>> +               .name = "procs",
> 
> Maybe call it "cgroup.procs" to avoid name clashes in future? We had a
> debate a while back where I tried to get the cgroup files like "tasks"
> and "notify_on_release" prefixed with "cgroup." , which were argued
> against on grounds of backwards compatibility. But there's no
> compatibility issue here. The only question is whether it's too ugly
> to have the legacy filenames without a prefix and the new ones with a
> prefix.
> 

Yes it's ugly.. Is possible name clash of "procs" a kind of breaking
compatibility that should be avoid in any case?



      reply	other threads:[~2008-06-21  6:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-18  8:02 [RFC] [PATCH] cgroup: add "procs" control file Li Zefan
2008-06-19  0:14 ` KAMEZAWA Hiroyuki
2008-06-19  3:07   ` Li Zefan
2008-06-19  3:17     ` KAMEZAWA Hiroyuki
2008-06-20 14:19   ` Balbir Singh
2008-06-20  5:37 ` Paul Menage
2008-06-21  6:20   ` Li Zefan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=485C9DA0.9080803@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menage@google.com \
    --cc=pj@sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox