linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Li Zefan <lizefan@huawei.com>
To: Tejun Heo <tj@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>, Dave Jones <davej@redhat.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	<cgroups@vger.kernel.org>
Subject: Re: lockdep trace from prepare_bprm_creds
Date: Sat, 9 Mar 2013 10:11:51 +0800	[thread overview]
Message-ID: <513A9A67.60909@huawei.com> (raw)
In-Reply-To: <20130307193820.GB3209@htj.dyndns.org>

On 2013/3/8 3:38, Tejun Heo wrote:
> Hello,
> 
> On Thu, Mar 07, 2013 at 08:12:42PM +0100, Oleg Nesterov wrote:
>> Well yes, I agree. I think that perfomance-wise threadgroup_change_begin()
>> in de_thread() is fine, and perhaps it is even more clean because we are
>> going to do the thread-group change. The scope of cred_guard_mutex is huge,
>> it doesn't look very nice in threadgroup_lock().
>>
>> But we should avoid the cgroup-specific hooks as much as possible, so I
>> like your patch more.
> 
> I don't really mind how it's done but while my approach seems to limit
> itself to cgroup proper, threadgroup locking is actually more invasive
> by meddling with cred_mutex.  As you said, yours is the cleaner and
> probably more permanent one here.
> 

Agreed.

Now we need that patch to be resent with SOB and proper changelog.

>>> +	if (threadgroup && !thread_group_leader(tsk)) {
>>> +		/*
>>> +		 * a race with de_thread from another thread's exec() may
>>> +		 * strip us of our leadership, if this happens, there is no
>>> +		 * choice but to throw this task away and try again; this
>>> +		 * is "double-double-toil-and-trouble-check locking".
>>> +		 */
>>> +		threadgroup_unlock(tsk);
>>> +		put_task_struct(tsk);
>>> +		goto retry_find_task;
>>> +	}
>>>
>>> +	ret = -ENODEV;
>>> +	if (cgroup_lock_live_group(cgrp)) {
>>> +		if (threadgroup)
>>> +			ret = cgroup_attach_proc(cgrp, tsk);
>>
>> Offtopic, but with or without this change I do not understand the
>> thread_group_leader/retry_find_task logic.
>>
>> Why do we actually need to restart? We do not really care if it is leader
>> or not, we only need to ensure we can safely use while_each_thread() to
>> find all !PF_EXITING threads.
> 
> If my memory serves me right (which BTW often fails), it's cgroup API
> thing.  cgroup wants to guarantee to the controllers that if multiple
> tasks are migrated together, they always constitute a threadgroup and
> the first one is the leader.  ISTR a controller callback which depends
> on the first one being the leader.
> 

It did serve you right this time. :)


  reply	other threads:[~2013-03-09  2:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06 22:36 lockdep trace from prepare_bprm_creds Dave Jones
2013-03-07 17:25 ` Oleg Nesterov
2013-03-07 18:01   ` Tejun Heo
2013-03-07 18:03     ` Tejun Heo
2013-03-07 19:12       ` Oleg Nesterov
2013-03-07 19:38         ` Tejun Heo
2013-03-09  2:11           ` Li Zefan [this message]
2013-03-09  3:29             ` Tejun Heo
2013-03-09  7:47               ` Li Zefan
2013-03-09 20:00                 ` [PATCH 0/1] do not abuse ->cred_guard_mutex in threadgroup_lock() Oleg Nesterov
2013-03-09 20:01                   ` [PATCH 1/1] " Oleg Nesterov
2013-03-09 20:15                     ` Tejun Heo
2013-03-11  1:50                     ` Li Zefan
2013-03-21 16:21                   ` [PATCH] " Oleg Nesterov
2013-03-21 22:06                     ` Andrew Morton
2013-03-22 13:20                       ` Oleg Nesterov
2013-03-19 22:02                 ` [PATCH cgroup/for-3.10] cgroup: make cgroup_mutex outer to threadgroup_lock Tejun Heo
2013-03-20  0:58                   ` Li Zefan
2013-03-20 15:03                     ` Tejun Heo
2013-03-20 18:35                       ` Oleg Nesterov
2013-03-20 18:42                         ` Tejun Heo
2013-03-21 16:17                           ` Oleg Nesterov
2013-03-07 18:21     ` lockdep trace from prepare_bprm_creds Tejun Heo
2013-03-07 18:32       ` Oleg Nesterov
2013-03-07 19:33         ` Tejun Heo

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=513A9A67.60909@huawei.com \
    --to=lizefan@huawei.com \
    --cc=cgroups@vger.kernel.org \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).