public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* what is_single_threaded() does?
@ 2009-03-31 20:57 Oleg Nesterov
  2009-04-02 11:07 ` David Howells
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2009-03-31 20:57 UTC (permalink / raw)
  To: David Howells, James Morris; +Cc: linux-kernel

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.


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

end of thread, other threads:[~2009-04-02 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-31 20:57 what is_single_threaded() does? Oleg Nesterov
2009-04-02 11:07 ` David Howells
2009-04-02 14:43   ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox