Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1534732

Re: [patch 1/4] rtmutex: Prevent dequeue vs. unlock race

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [patch 1/4] rtmutex: Prevent dequeue vs. unlock race
Date 2016-12-02 09:30 +0100
Message-ID <sJRod-1bm-1@gated-at.bofh.it> (permalink)
References <sJkiB-2NQ-13@gated-at.bofh.it> <sJkiB-2NQ-11@gated-at.bofh.it> <sJEhk-8aj-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 1 Dec 2016, Peter Zijlstra wrote:

> On Wed, Nov 30, 2016 at 09:04:41PM -0000, Thomas Gleixner wrote:
> > It's remarkable that the test program provided by David triggers on ARM64
> > and MIPS64 really quick, but it refuses to reproduce on x8664, while the
> > problem exists there as well. That refusal might explain that this got not
> > discovered earlier despite the bug existing from day one of the rtmutex
> > implementation more than 10 years ago.
> 
> > -		clear_rt_mutex_waiters(lock);
> 
> So that compiles into:
> 
> 	andq   $0xfffffffffffffffe,0x48(%rbx)
> 
> With is a RmW memop. Now per the architecture documents we can decompose
> that into a normal load-store and the race exists. But I would not be
> surprised if that starts with the cacheline in exclusive mode (because
> it knows it will do the store). Which makes it a very tiny race indeed.

If it really takes the cacheline exclusive right away, then there is no
race because the cmpxchg has to wait for release and will see the store.
If the cmpxchg comes first the RmW will see the new value.

Fun stuff, isn't it?

	tglx

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[patch 1/4] rtmutex: Prevent dequeue vs. unlock race Thomas Gleixner <tglx@linutronix.de> - 2016-11-30 22:10 +0100
  Re: [patch 1/4] rtmutex: Prevent dequeue vs. unlock race Peter Zijlstra <peterz@infradead.org> - 2016-12-01 19:30 +0100
    Re: [patch 1/4] rtmutex: Prevent dequeue vs. unlock race Thomas Gleixner <tglx@linutronix.de> - 2016-12-02 09:30 +0100
  Re: [patch 1/4] rtmutex: Prevent dequeue vs. unlock race Steven Rostedt <rostedt@goodmis.org> - 2016-12-02 02:00 +0100
  [tip:locking/core] locking/rtmutex: Prevent dequeue vs. unlock race tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-12-02 11:50 +0100

csiph-web