mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	Paul E McKenney <paulmck@linux.vnet.ibm.com>,
	Nick Piggin <npiggin@suse.de>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: futex code and barriers
Date: Tue, 29 Apr 2008 17:13:22 +0400	[thread overview]
Message-ID: <20080429131322.GB128@tv-sign.ru> (raw)
In-Reply-To: <1209470236.13978.55.camel@twins>

On 04/29, Peter Zijlstra wrote:
> Hi All,
> 
> While looking through the futex code I stumbled upon the following bit:
> 
> kernel/futex.c:
> 
> 	/* add_wait_queue is the barrier after __set_current_state. */

As for me, the comment is very confusing at least.

> 	__set_current_state(TASK_INTERRUPTIBLE);
> 	add_wait_queue(&q.waiters, &wait);

Not sure I understand this code, but probably it is correct.

Yes, add_wait_queue() is not a barrier, and both __set_current_state()
and the "!plist_node_empty()" check below can leak into the
add_wait_queue's critical section.

But wake_futex()->wake_up_all() has to lock/unlock the same q->lock,
so I think we can't miss the event.

IOW, when wake_futex()->wake_up_all() takes q->lock, it must see
TASK_INTERRUPTIBLE.

If wake_futex() takes q->lock before us, we must see the result
of plist_del() after add_wait_queue() (more precisely, after
add_wait_queue()->spin_lock(q->lock).

But I'd like to know maintainer's opinion, I don't trust myself ;)

Oleg.


      parent reply	other threads:[~2008-04-29 13:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-29 11:57 Peter Zijlstra
2008-04-29 12:43 ` Jiri Kosina
2008-04-29 12:49   ` Peter Zijlstra
2008-04-29 13:13 ` Oleg Nesterov [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=20080429131322.GB128@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=npiggin@suse.de \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®