Re: [PATCH RT] seqlock/rt: Prevent livelocks with seqlocks in RT

From: Steven Rostedt
Date: Tue Mar 06 2012 - 07:17:40 EST


On Tue, 2012-03-06 at 09:18 +0100, Thomas Gleixner wrote:

> Errm. rt15 has
>
> /*
> * Starvation safe read side for RT
> */
> static inline unsigned read_seqbegin(seqlock_t *sl)
> {
> unsigned ret;
>
> repeat:
> ret = sl->seqcount.sequence;
> if (unlikely(ret & 1)) {
> /*
> * Take the lock and let the writer proceed (i.e. evtl
> * boost it), otherwise we could loop here forever.
> */
> spin_lock(&sl->lock);
> spin_unlock(&sl->lock);
> goto repeat;
> }
> return ret;
> }
> #endif

You're right it does!

I didn't see this as the lock up showed it was locked up in
read_seqcount_begin(), it was late and I was tired.

Here's the real fix then:

Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>

diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 723274d..29ffd4f 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -177,7 +177,7 @@ typedef struct {
/*
* Read side functions for starting and finalizing a read side section.
*/
-#ifndef CONFIG_PREEMPT_RT
+#ifndef CONFIG_PREEMPT_RT_FULL
static inline unsigned read_seqbegin(const seqlock_t *sl)
{
return read_seqcount_begin(&sl->seqcount);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/