Re: [patch] add optimized generic percpu accessors

From: Tejun Heo
Date: Thu Jan 15 2009 - 16:52:01 EST


Hello, Roel.

roel kluin wrote:
>> +#ifndef percpu_read
>> +# define percpu_read(var) \
>> + ({ \
>> + typeof(per_cpu_var(var)) __tmp_var__; \
>> + __tmp_var__ = get_cpu_var(var); \
>> + put_cpu_var(var); \
>> + __tmp_var__; \
>> + })
>> +#endif
>
> I'm sorry for your eyes, but since var occurs twice, isn't it better to do:
>
> # define percpu_read(var) \
> ({ \
> typeof(var) __pcpu_read_var__ = var;
> \
> typeof(per_cpu_var(__pcpu_read_var__)) __tmp_var__; \
> __tmp_var__ = get_cpu_var(__pcpu_read_var__); \
> put_cpu_var(__pcpu_read_var__); \
> __tmp_var__; \
> })
>
>> +
>> +#define __percpu_generic_to_op(var, val, op) \
>> +do { \
>> + get_cpu_var(var) op val; \
>> + put_cpu_var(var); \
>> +} while (0)
>
> and:
>
> #define __percpu_generic_to_op(var, val, op) \
> do { \
> typeof(var) __pcpu_gto_var__ = var;
> \
> get_cpu_var(__pcpu_gto_var__) op val;
> \
> put_cpu_var(__pcpu_gto_var__);
> \
> } while (0)

@var has to be simple identifier as it ends up getting concatenated to
a string. There's even a check for it in get_cpu_var() macro. Please
also note that lack of any protecting ()'s around @var for the same
reason. So, basically, typeof(var) just doesn't exist.

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/