mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	RT <linux-rt-users@vger.kernel.org>,
	Clark Williams <clark@redhat.com>, John Kacur <jkacur@redhat.com>,
	Carsten Emde <cbe@osadl.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH RT] seqlock/rt: Prevent livelocks with seqlocks in RT
Date: Tue, 6 Mar 2012 09:18:53 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.2.02.1203060911000.2742@ionos> (raw)
In-Reply-To: <1331006584.25686.362.camel@gandalf.stny.rr.com>

On Mon, 5 Mar 2012, Steven Rostedt wrote:

> Thomas,
> 
> I was running my cpu hotplug stress test along with a kernel compile and
> after about 40 minutes of running it locked up. It happened in the
> read_seqcount_begin() that is called by d_lookup().
> 
> ksoftirqd was caught here:
> 
> static __always_inline unsigned read_seqbegin(const seqlock_t *sl)
> {
> 	unsigned ret;
> 
> repeat:
> 	ret = ACCESS_ONCE(sl->sequence);
> 	if (unlikely(ret & 1)) {
> 		cpu_relax();
> 		goto repeat;
> 	}
> 	smp_rmb();
> 
> 	return ret;
> }
> 
> It preempted the holder of the seqlock that was held for write, and as
> that holder had migrate disabled, it couldn't be scheduled. Then
> ksoftirqd went into this infinite loop and the system locked up.
> 
> This patch fixes the issue by grabbing and releasing the write lock when
> it detects contention. It only works with seqlocks and not seqcounts
> that have their own locking. But we could add an api to include those
> too if needed.

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

> Because read_seqlocks are used in the VDSO area, a raw_read_seqcount_begin()
> was created to allow userspace tasks to access read_seqcount().
> As the grabbing of the write_lock() is not allowed in VDSO, nor
> is even referencing it.

This is completely bogus. The VDSO update write side runs with
interrupts disabled, so it cannot be preempted at all.

> Note, a live lock can still happen if the userspace task that
> does the read_seqlock is of higher priority than a user doing
> the write_lock, so userspace needs to be careful.

What the hell are you smoking?
 
Thanks,

	tglx

  reply	other threads:[~2012-03-06  8:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06  4:03 Steven Rostedt
2012-03-06  8:18 ` Thomas Gleixner [this message]
2012-03-06 12:17   ` Steven Rostedt
2012-03-06 13:19     ` Thomas Gleixner
2012-03-06 12:47   ` Steven Rostedt

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=alpine.LFD.2.02.1203060911000.2742@ionos \
    --to=tglx@linutronix.de \
    --cc=cbe@osadl.org \
    --cc=clark@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /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®