stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: Manfred Spraul <manfred@colorfullife.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	1vier1@web.de, Ingo Molnar <mingo@redhat.com>,
	felixh@informatik.uni-bremen.de, stable@vger.kernel.org
Subject: Re: [PATCH] ipc/sem.c: Fix complex_count vs. simple op race
Date: Mon, 4 Jan 2016 05:02:31 -0800	[thread overview]
Message-ID: <20160104130231.GA3013@linux-uzut.site> (raw)
In-Reply-To: <1451736291-8115-1-git-send-email-manfred@colorfullife.com>

On Sat, 02 Jan 2016, Manfred Spraul wrote:

>Commit 6d07b68ce16a ("ipc/sem.c: optimize sem_lock()") introduced a race:
>
>sem_lock has a fast path that allows parallel simple operations.
>There are two reasons why a simple operation cannot run in parallel:
>- a non-simple operations is ongoing (sma->sem_perm.lock held)
>- a complex operation is sleeping (sma->complex_count != 0)
>
>As both facts are stored independently, a thread can bypass the current
>checks by sleeping in the right positions. See below for more details
>(or kernel bugzilla 105651).
>
>The patch fixes that by creating one variable (complex_mode)
>that tracks both reasons why parallel operations are not possible.
>
>The patch also updates stale documentation regarding the locking.
>
>With regards to stable kernels:
>The patch is required for all kernels that include the commit 6d07b68ce16a
>("ipc/sem.c: optimize sem_lock()") (3.10?)
>
>The alternative is to revert the patch that introduced the race.

I am just now catching up with this, but a quick thought is that we probably
want to keep 6d07b68ce16a as waiting on unlocking all sem->lock should be
much worse for performance than keeping track of the complex 'mode'. Specially
if we have a large array.

Also, any idea what workload exposed this race? Anyway, will take a closer look
at the patch/issue.

Thanks,
Davidlohr

  reply	other threads:[~2016-01-04 13:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-02 12:04 [PATCH] ipc/sem.c: Fix complex_count vs. simple op race Manfred Spraul
2016-01-04 13:02 ` Davidlohr Bueso [this message]
2016-01-04 18:32   ` Manfred Spraul
  -- strict thread matches above, loose matches on Subject: below --
2016-07-21 17:54 Manfred Spraul
2016-07-21 20:16 ` Andrew Morton

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=20160104130231.GA3013@linux-uzut.site \
    --to=dave@stgolabs.net \
    --cc=1vier1@web.de \
    --cc=akpm@linux-foundation.org \
    --cc=felixh@informatik.uni-bremen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=mingo@redhat.com \
    --cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).