[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140210125245.1afc834d@gandalf.local.home>
Date: Mon, 10 Feb 2014 12:52:45 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Nicholas Mc Guire <der.herr@...r.at>
Cc: linux-rt-users@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Carsten Emde <C.Emde@...dl.org>,
Thomas Gleixner <tglx@...utronix.de>,
Andreas Platschek <platschek@....tuwien.ac.at>
Subject: Re: allow preemption in check_task_state
On Mon, 10 Feb 2014 18:17:12 +0100
Nicholas Mc Guire <der.herr@...r.at> wrote:
> >
> > In rtmutex.c we have:
> >
> > pi_lock(&self->pi_lock);
> > __set_current_state(self->saved_state);
> > self->saved_state = TASK_RUNNING;
> > pi_unlock(&self->pi_lock);
> >
> > As there is no wmb() here, it can be very possible that another CPU
> > will see saved_state as TASK_RUNNING, and current state as
> > TASK_RUNNING, and miss the update completely.
> >
> > I would not want to add a wmb() unless there is a real bug with the
> > check state, as the above is in a very fast path and the check state is
> > in a slower path.
> >
> maybe I'm missing/missunderstanding something here but
> pi_unlock -> arch_spin_unlock is a full mb()
> so once any task did an update of the state the loop should be catching
> this update ? if the loop exits before the updat takes effect (pi_unlock)
> would that be ncorrect ?
Even if the spin locks were full memory barriers, it is still buggy.
The fact that we set current_state to saved_state, and then saved_state
to TASK_RUNNING without any memory barriers in between those two
statements, means that the reader (even with a rmb()) can still see
both as TASK_RUNNING.
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists