From: "Christoph Lameter (Ampere)" <cl@gentwo.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Christoph Lameter via B4 Relay <devnull+cl.gentwo.org@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Waiman Long <longman@redhat.com>,
Boqun Feng <boqun.feng@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arch@vger.kernel.org
Subject: Re: [PATCH v2] Avoid memory barrier in read_seqcount() through load acquire
Date: Wed, 28 Aug 2024 10:15:33 -0700 (PDT) [thread overview]
Message-ID: <b0543714-9176-f3a3-1ca9-55bbedf6a0c3@gentwo.org> (raw)
In-Reply-To: <87ttfbeyqt.ffs@tglx>
On Fri, 23 Aug 2024, Thomas Gleixner wrote:
> This all can be done without the extra copies of the counter
> accessors. Uncompiled patch below.
Great. Thanks. Tried it too initially but could not make it work right.
One thing that we also want is the use of the smp_cond_load_acquire to
have the cpu power down while waiting for a cacheline change.
The code has several places where loops occur when the last bit is set in
the seqcount.
We could use smp_cond_load_acquire in load_sequence() but what do we do
about the loops at the higher level? Also this does not sync with the lock
checking logic.
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 68b3af8bd6c6..4442a97ffe9a 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -135,7 +135,7 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
static __always_inline unsigned __seqprop_load_sequence(const seqcount_t *s, bool acquire)
{
if (acquire && IS_ENABLED(CONFIG_ARCH_HAS_ACQUIRE_RELEASE))
- return smp_load_acquire(&s->sequence);
+ return smp_cond_load_acquire(&s->sequence, (s->sequence & 1) == 0);
else
return READ_ONCE(s->sequence);
}
next prev parent reply other threads:[~2024-08-28 17:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 18:30 Christoph Lameter via B4 Relay
2024-08-23 10:32 ` Will Deacon
2024-08-23 17:56 ` Christoph Lameter (Ampere)
2024-08-23 19:38 ` Christoph Lameter (Ampere)
2024-08-23 21:05 ` Thomas Gleixner
2024-08-28 17:15 ` Christoph Lameter (Ampere) [this message]
2024-09-02 11:55 ` Thomas Gleixner
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=b0543714-9176-f3a3-1ca9-55bbedf6a0c3@gentwo.org \
--to=cl@gentwo.org \
--cc=boqun.feng@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=devnull+cl.gentwo.org@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=will@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