Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1612932

Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h

From Mark Rutland <mark.rutland@arm.com>
Newsgroups linux.kernel
Subject Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h
Date 2017-03-30 12:50 +0200
Message-ID <tqFOp-55A-9@gated-at.bofh.it> (permalink)
References <tq20H-1Mi-39@gated-at.bofh.it> <tq20H-1Mi-49@gated-at.bofh.it> <tqpqj-1xr-25@gated-at.bofh.it> <tqC4a-2hn-33@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Mar 30, 2017 at 08:43:39AM +0200, Ingo Molnar wrote:
> 
> * Mark Rutland <mark.rutland@arm.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?

Yes; my bad.

> > 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.

Great. I'll follow the above pattern when adding the ordering variants.

> 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.

Sure, that makes sense to me.

Thanks,
Mark.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 4/8] asm-generic: add atomic-instrumented.h Dmitry Vyukov <dvyukov@google.com> - 2017-03-28 18:20 +0200
  Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h Matthew Wilcox <willy@infradead.org> - 2017-03-28 23:40 +0200
    Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h Dmitry Vyukov <dvyukov@google.com> - 2017-03-29 10:30 +0200
    Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h Mark Rutland <mark.rutland@arm.com> - 2017-03-29 15:30 +0200
  Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h Mark Rutland <mark.rutland@arm.com> - 2017-03-29 19:20 +0200
    Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h Ingo Molnar <mingo@kernel.org> - 2017-03-30 08:50 +0200
      Re: [PATCH 4/8] asm-generic: add atomic-instrumented.h Mark Rutland <mark.rutland@arm.com> - 2017-03-30 12:50 +0200

csiph-web