From: Davidlohr Bueso <dave@stgolabs.net>
To: Manfred Spraul <manfred@colorfullife.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH -next] ipc/sem: prevent queue.status tearing in semop
Date: Mon, 30 Jul 2018 15:08:37 -0700 [thread overview]
Message-ID: <20180730220837.iojrnvdb3lippfj7@linux-r8p5> (raw)
In-Reply-To: <7909e12b-6dd7-e28a-010c-003545a8e4b5@colorfullife.com>
On Wed, 18 Jul 2018, Manfred Spraul wrote:
>sma->use_global_lock is sometimes used with smp_load_acquire(),
>sometimes without.
>So far, I assumed that this is safe.
>
>The same applies for nf_conntrack_locks_all, in nf_conntrack_all_lock()
So the netfilter code is safe wrt tearing as _all_ accesses are done with
barriers and/or under spinlock.
However, this isn't always the case for sma->use_global_lock, albeit harmless.
- sem_lock(): It doesn't matter if we get the first check right as we
end up rechecking with locks held.
/*
* Initial check for use_global_lock. Just an optimization,
* no locking, no memory barrier.
*/
if (!sma->use_global_lock) {
- complexmode_enter/tryleave() are called under the ipc object lock, so that
is safe:
spin_lock()
complexmode_enter()
...
complexmode_tryleave()
spin_unlock()
- newary(): Init, no concurrency, of course.
So while I also like READ/WRITE_ONCE() calls in that it helps document the
code, I don't think we need/want want this. There's a comment there in the
first place.
Thanks,
Davidlohr
prev parent reply other threads:[~2018-07-30 22:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-17 5:26 [PATCH -next] ipc/sem: prevent queue.status tearing in semop Davidlohr Bueso
2018-07-17 5:28 ` Davidlohr Bueso
2018-07-18 3:55 ` Manfred Spraul
2018-07-20 18:25 ` Davidlohr Bueso
2018-07-30 22:08 ` Davidlohr Bueso [this message]
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=20180730220837.iojrnvdb3lippfj7@linux-r8p5 \
--to=dave@stgolabs.net \
--cc=akpm@linux-foundation.org \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
/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).