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]
Message-ID: <496FAFC7.8040205@kernel.org>
Date:	Fri, 16 Jan 2009 06:51:03 +0900
From:	Tejun Heo <tj@...nel.org>
To:	roel kluin <roel.kluin@...il.com>
CC:	Ingo Molnar <mingo@...e.hu>, "H. Peter Anvin" <hpa@...or.com>,
	Brian Gerst <brgerst@...il.com>, ebiederm@...ssion.com,
	cl@...ux-foundation.org, rusty@...tcorp.com.au, travis@....com,
	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	steiner@....com, hugh@...itas.com
Subject: Re: [patch] add optimized generic percpu accessors

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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ