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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 4 Dec 2015 14:05:49 -0800
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Waiman Long <waiman.long@....com>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	Will Deacon <will.deacon@....com>,
	Ingo Molnar <mingo@...nel.org>,
	Oleg Nesterov <oleg@...hat.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Paul McKenney <paulmck@...ux.vnet.ibm.com>,
	Boqun Feng <boqun.feng@...il.com>,
	Jonathan Corbet <corbet@....net>,
	Michal Hocko <mhocko@...nel.org>,
	David Howells <dhowells@...hat.com>,
	Paul Turner <pjt@...gle.com>
Subject: Re: [PATCH 3/4] locking: Introduce smp_cond_acquire()

On Fri, Dec 4, 2015 at 12:51 PM, Waiman Long <waiman.long@....com> wrote:
>
> Will the following work?

Are we trying to win some obfuscated C contest here?

Just make it do something like (skipping backslashes to make it easier
to type and read)

 #define smp_cond_load_acquire(ptr, cond_expr) ({
     typeof(*ptr) VAL;
     for (;;) {
          VAL = READ_ONCE(*ptr);
          if (cond_expr) break;
          cpu_relax();
     }
     smp_rmb();
     VAL;
  })

and then you'd have it be

    val = smp_cond_load_acquire(&lock->val.counter,
               !(VAL & _Q_LOCKED_PENDING_MASK));

which is at least halfway legible. Not some odd "fragments of
expressions" interfaces unless absolutely required, please.

Of course, I suspect we should not use READ_ONCE(), but some
architecture-overridable version that just defaults to READ_ONCE().
Same goes for that "smp_rmb()". Because maybe some architectures will
just prefer an explicit acquire, and I suspect we do *not* want
architectures having to recreate and override that crazy loop.

How much does this all actually end up mattering, btw?

               Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ