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: <CAHk-=wjBiAqaWnXG_44ajMCqU3nNQOC1RQ6SUmKYC03Y1G=r1g@mail.gmail.com>
Date: Tue, 13 May 2025 12:46:29 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: dan.j.williams@...el.com, linux-cxl@...r.kernel.org, 
	linux-kernel@...r.kernel.org, David Lechner <dlechner@...libre.com>, 
	Ingo Molnar <mingo@...nel.org>, 
	"Fabio M. De Francesco" <fabio.maria.de.francesco@...ux.intel.com>, 
	Davidlohr Bueso <dave@...olabs.net>, Jonathan Cameron <jonathan.cameron@...wei.com>, 
	Dave Jiang <dave.jiang@...el.com>, Alison Schofield <alison.schofield@...el.com>, 
	Vishal Verma <vishal.l.verma@...el.com>, Ira Weiny <ira.weiny@...el.com>
Subject: Re: [PATCH 1/7] cleanup: Introduce DEFINE_ACQUIRE() a CLASS() for
 conditional locking

On Tue, 13 May 2025 at 01:50, Peter Zijlstra <peterz@...radead.org> wrote:
>
> +#define __GUARD_IS_ERR(_ptr) \
> +       ({ unsigned long _var = (__force unsigned long)(_ptr); \
> +          bool _s; \
> +          asm_inline volatile ("cmp %[val], %[var]" \
> +                               : "=@...s" (_s) \
> +                               : [val] "i" (-MAX_ERRNO), \
> +                                 [var] "r" (_var)); \
> +          unlikely(_s); })

I think that this might be acceptable if it was some actual common operation.

But for just the conditional guard test, I think it's cute, but I
don't think it's really worth it.

Put another way: if we actually used this for IS_ERR_OR_NULL(), it
might be a worthwhile thing to look at. We have lots of those - some
of them in important core places.

Right now IS_ERR_OR_NULL() generates pretty disgusting code, with
clang doing things like this:

        testq   %rdi, %rdi
        sete    %al
        cmpq    $-4095, %rdi                    # imm = 0xF001
        setae   %cl
        orb     %al, %cl
        je      .LBB3_1

in order to avoid two jumps, while gcc generates that

        testq   %rdi, %rdi
        je      .L189
        cmpq    $-4096, %rdi
        ja      .L189

pattern.

               Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ