Re: [PATCH v2] ALSA: emu10k1: macro-ize snd_emu10k1_ptr_{read,write}()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 08 May 2023 14:02:29 +0200,
Oswald Buddenhagen wrote:
> 
> The idea to encode the bitfield manipulation in the register address is
> quite clever, but it's somewhat wasteful to do these calculations at
> runtime, given that they are all constants. So change that. This yields
> a marginal saving in runtime cost at a marginal cost in code side (less
> than 400 bytes).
> 
> The call sites where the read/write is done with a non-constant register
> needed adjustment, so there is a bit of churn involved. On the upside,
> this makes the various use cases more obvious, and makes it easier to
> grep for them.
> 
> snd_emu10k1_ptr_{read,write}() must be macros, as they check the
> constness of the passed register argument, and the C language has no
> provisions for doing this differently.

There are __builtin_constant_p(), if we inevitably need to check the
constant in a static inline function.

But, I still doubt whether we can measure any significant runtime cost
saving.  Do we have numbers?
(OTOH, the cost of memory bloat could be measured easily, though.)

I'm very much for introducing macros to define the registers instead
of magical combos; it'll be a good code simplification and make it
easier to read.  But for the additional complexity of code just for
some micro optimization... I'm not sure whether it's wroth.
(If the numbers are convincing, we can go for it, of course.)


thanks,

Takashi



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux