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


Groups > linux.kernel > #1610511

Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations
Date 2017-03-28 12:00 +0200
Message-ID <tpW4W-5IO-11@gated-at.bofh.it> (permalink)
References (3 earlier) <torFU-6sZ-7@gated-at.bofh.it> <tov6P-la-29@gated-at.bofh.it> <towPg-1DH-11@gated-at.bofh.it> <tpUcN-4ow-1@gated-at.bofh.it> <tpVBU-5sY-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Peter Zijlstra <peterz@infradead.org> wrote:

> On Tue, Mar 28, 2017 at 09:52:32AM +0200, Ingo Molnar wrote:
> 
> > No, regular C code.
> > 
> > I don't see the point of generating all this code via CPP - it's certainly not 
> > making it more readable to me. I.e. this patch I commented on is a step backwards 
> > for readability.
> 
> Note that much of the atomic stuff we have today is all CPP already.

Yeah, but there it's implementational: we pick up arch primitives depending on 
whether they are defined, such as:

#ifndef atomic_read_acquire
# define atomic_read_acquire(v)		smp_load_acquire(&(v)->counter)
#endif

> x86 is the exception because its 'weird', but most other archs are
> almost pure CPP -- check Alpha for example, or asm-generic/atomic.h.

include/asm-generic/atomic.h looks pretty clean and readable overall.

> Also, look at linux/atomic.h, its a giant maze of CPP.

Nah, that's OK, much of is is essentially __weak inlines implemented via CPP - 
i.e. CPP is filling in a missing compiler feature.

But this patch I replied to appears to add instrumentation wrappery via CPP which 
looks like excessive and avoidable obfuscation to me.

If it's much more readable and much more compact than the C version then maybe, 
but I'd like to see the C version first and see ...

> The CPP help us generate functions, reduces endless copy/paste (which induces 
> random differences -- read bugs) and construct variants depending on the 
> architecture input.
> 
> Yes, the CPP is a pain, but writing all that out explicitly is more of a
> pain.

So I'm not convinced that it's true in this case.

Could we see the C version and compare? I could be wrong about it all.

Thanks,

	Ingo

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


Thread

Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations Ingo Molnar <mingo@kernel.org> - 2017-03-28 10:00 +0200
  Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations Peter Zijlstra <peterz@infradead.org> - 2017-03-28 11:30 +0200
    Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-28 11:50 +0200
    Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-28 12:00 +0200
      Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations Ingo Molnar <mingo@kernel.org> - 2017-03-28 12:20 +0200
        Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-28 18:40 +0200
    Re: [PATCH 2/3] asm-generic, x86: wrap atomic operations Ingo Molnar <mingo@kernel.org> - 2017-03-28 12:00 +0200

csiph-web