[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180730220837.iojrnvdb3lippfj7@linux-r8p5>
Date: Mon, 30 Jul 2018 15:08:37 -0700
From: Davidlohr Bueso <dave@...olabs.net>
To: Manfred Spraul <manfred@...orfullife.com>
Cc: akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
Davidlohr Bueso <dbueso@...e.de>
Subject: Re: [PATCH -next] ipc/sem: prevent queue.status tearing in semop
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
Powered by blists - more mailing lists