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]
Date:   Thu, 30 Mar 2017 08:43:39 +0200
From:   Ingo Molnar <mingo@...nel.org>
To:     Mark Rutland <mark.rutland@....com>
Cc:     Dmitry Vyukov <dvyukov@...gle.com>, peterz@...radead.org,
        mingo@...hat.com, akpm@...ux-foundation.org, will.deacon@....com,
        aryabinin@...tuozzo.com, kasan-dev@...glegroups.com,
        linux-kernel@...r.kernel.org, x86@...nel.org, linux-mm@...ck.org
Subject: Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h


* Mark Rutland <mark.rutland@....com> wrote:

> With some minimal CPP, it can be a lot more manageable:
> 
> ----
> #define INSTR_ATOMIC_XCHG(order)					\
> static __always_inline int atomic_xchg##order(atomic_t *v, int i)	\
> {									\
> 	kasan_check_write(v, sizeof(*v));				\
> 	arch_atomic_xchg##order(v, i);					\
> }
> 
> #define INSTR_ATOMIC_XCHG()
> 
> #ifdef arch_atomic_xchg_relaxed
> INSTR_ATOMIC_XCHG(_relaxed)
> #define atomic_xchg_relaxed atomic_xchg_relaxed
> #endif
> 
> #ifdef arch_atomic_xchg_acquire
> INSTR_ATOMIC_XCHG(_acquire)
> #define atomic_xchg_acquire atomic_xchg_acquire
> #endif
> 
> #ifdef arch_atomic_xchg_relaxed
> INSTR_ATOMIC_XCHG(_relaxed)
> #define atomic_xchg_relaxed atomic_xchg_relaxed
> #endif

Yeah, small detail: the third one wants to be _release, right?

> Is there any objection to some light CPP usage as above for adding the
> {relaxed,acquire,release} variants?

No objection from me to that way of writing it, this still looks very readable, 
and probably more readable than the verbose variants. It's similar in style to 
linux/atomic.h which has a good balance of C versus CPP.

What I objected to was the deep nested code generation approach in the original 
patch.

CPP is fine in many circumstances, but there's a level of (ab-)use where it 
becomes counterproductive.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ