lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b0543714-9176-f3a3-1ca9-55bbedf6a0c3@gentwo.org>
Date: Wed, 28 Aug 2024 10:15:33 -0700 (PDT)
From: "Christoph Lameter (Ampere)" <cl@...two.org>
To: Thomas Gleixner <tglx@...utronix.de>
cc: Christoph Lameter via B4 Relay <devnull+cl.gentwo.org@...nel.org>, 
    Catalin Marinas <catalin.marinas@....com>, Will Deacon <will@...nel.org>, 
    Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
    Waiman Long <longman@...hat.com>, Boqun Feng <boqun.feng@...il.com>, 
    Linus Torvalds <torvalds@...ux-foundation.org>, linux-mm@...ck.org, 
    linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, 
    linux-arch@...r.kernel.org
Subject: Re: [PATCH v2] Avoid memory barrier in read_seqcount() through load
 acquire

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);
 }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ