From: Ingo Molnar <mingo@elte.hu>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
Eric Dumazet <dada1@cosmosbay.com>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ulrich Drepper <drepper@redhat.com>,
linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH] pi-futex: set PF_EXITING without taking ->pi_lock
Date: Mon, 6 Aug 2007 09:30:40 +0200 [thread overview]
Message-ID: <20070806073040.GJ5359@elte.hu> (raw)
In-Reply-To: <20070721163947.GA1129@tv-sign.ru>
* Oleg Nesterov <oleg@tv-sign.ru> wrote:
> Question: should we make spinlock_t barrier-safe?
>
> Suppose that the task "p" does
>
> current->state = TASK_INTERRUPIBLE;
> mb();
>
> if (CONDITION)
> break;
>
> schedule();
>
> and another CPU does
>
> CONDITION = 1;
> try_to_wake_up(p);
>
>
> This is commonly used, but not correct _in theory_. If wake_up() happens
> when p->array != NULL, we have
>
> CONDITION = 1; // [1]
> spin_lock(rq->lock);
> task->state = TASK_RUNNING; // [2]
>
> and we can miss an event. Because in theory [1] may leak into the critical
> section, and could be re-ordered with [2].
>
> Another problem is that try_to_wake_up() first checks task->state and does
> nothing if it is TASK_RUNNING, so we need a full mb(), not just wmb().
>
> Should we change spin_lock(), or introduce smp_mb_before_spinlock(), or I
> missed something?
>
> NOTE: I do not pretend to know what kind of barrier spin_lock() provides
> in practice, but according to the documentation lock() is only a one-way
> barrier.
i think your worry is legitimate.
spin_lock() provides a full barrier on most platforms (certainly so on
x86). But ... ia64 might have it as a one-way barrier?
Ingo
next prev parent reply other threads:[~2007-08-06 7:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-21 11:57 [PATCH] pi-futex: set PF_EXITING without taking ->pi_lock Oleg Nesterov
2007-07-21 12:31 ` Ingo Molnar
2007-07-21 14:18 ` Oleg Nesterov
2007-07-21 15:02 ` [PATCH] fix theoretical ccids_{read,write}_lock() race Oleg Nesterov
2007-07-21 19:02 ` Andrew Morton
2007-07-21 19:11 ` Oleg Nesterov
2007-07-21 19:21 ` Andrew Morton
2007-07-21 20:06 ` Oleg Nesterov
2007-07-21 15:05 ` [PATCH] pi-futex: set PF_EXITING without taking ->pi_lock Ingo Molnar
2007-07-21 16:39 ` Oleg Nesterov
2007-08-06 7:30 ` Ingo Molnar [this message]
2007-07-22 0:31 ` Paul Mackerras
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=20070806073040.GJ5359@elte.hu \
--to=mingo@elte.hu \
--cc=acme@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dada1@cosmosbay.com \
--cc=drepper@redhat.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=rostedt@goodmis.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