From: Oleg Nesterov <oleg@redhat.com>
To: David Howells <dhowells@redhat.com>, James Morris <jmorris@namei.org>
Cc: linux-kernel@vger.kernel.org
Subject: what is_single_threaded() does?
Date: Tue, 31 Mar 2009 22:57:03 +0200 [thread overview]
Message-ID: <20090331205703.GA21030@redhat.com> (raw)
I found this helper by accident, and I am puzzled.
/**
* is_single_threaded - Determine if a thread group is single-threaded or not
* @p: A task in the thread group in question
*
* This returns true if the thread group to which a task belongs is single
* threaded, false if it is not.
*/
But this is not what the code does? The "t->mm == mm" check below means
it also returns false if ->mm is shared with another CLONE_VM process ?
Could you explain what is right, the comment or the code?
bool is_single_threaded(struct task_struct *p)
{
struct task_struct *g, *t;
struct mm_struct *mm = p->mm;
if (atomic_read(&p->signal->count) != 1)
goto no;
Is this correct? Let's suppose the main thread dies, and the thread group
has only one live thread. In that case signal->count == 2.
if (atomic_read(&p->mm->mm_users) != 1) {
read_lock(&tasklist_lock);
do_each_thread(g, t) {
Why do_each_thread() ? for_each_process() is enough, all sub-threads use
the same ->mm.
if (t->mm == mm && t != p)
goto no_unlock;
What about use_mm() ? Looks like this needs PF_KTHREAD check.
} while_each_thread(g, t);
read_unlock(&tasklist_lock);
}
return true;
Perhaps it should be current_is_single_thread(void) ...
Oleg.
next reply other threads:[~2009-03-31 21:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-31 20:57 Oleg Nesterov [this message]
2009-04-02 11:07 ` what is_single_threaded() does? David Howells
2009-04-02 14:43 ` Oleg Nesterov
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=20090331205703.GA21030@redhat.com \
--to=oleg@redhat.com \
--cc=dhowells@redhat.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
/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