percpu: add percpu_variable_ptr()
PATCH 1/2 percpu: add percpu_variable_ptr()
The percpu variable and allocated percpu data are compatible witch each other, This patch adds a API, thus we can use per_cpu_ptr() for defined/declared percpu variable.
---
include/linux/percpu-defs.h +6 -0
@@ -81,6 +81,12 @@#endif /* +* Ptr of the declared/defined per-CPU variable. +* It is totally compatible with the return from alloc_percpu(). +*/ +#define percpu_variable_ptr (name) (&(name)) + +/* * Variant on the per-CPU variable declaration/definition theme used for * ordinary per-CPU variables. */
Tejun Heo
maintainerQuoted 11 lines · Lai Jiangshan
The percpu variable and allocated percpu data are compatible witch each other, This patch adds a API, thus we can use
per_cpu_ptr()for defined/declared percpu variable.Signed-off-by Lai Jiangshan <[email protected]>---
include/linux/percpu-defs.h +0
-0
include/linux/percpu-defs.h line 87
Quoted 7 lines
include/linux/percpu-defs.h +4
-0@@ -81,6 +81,12 @@#endif /* +* Ptr of the declared/defined per-CPU variable. +* It is totally compatible with the return from alloc_percpu(). +*/ +#define percpu_variable_ptr (name) (&(name))
Why not just use &name?
Thanks.
Signature · 1 line
tejun
Quoted 14 lines · Tejun Heo
Quoted 13 lines · Lai Jiangshan
The percpu variable and allocated percpu data are compatible witch each other, This patch adds a API, thus we can use
per_cpu_ptr()for defined/declared percpu variable.Signed-off-by Lai Jiangshan <[email protected]>---
include/linux/percpu-defs.h +0
-0@@ -81,6 +81,12 @@#endif
Quoted 8 lines
include/linux/percpu-defs.h line 87
Quoted 5 lines
include/linux/percpu-defs.h +4
-0/* +* Ptr of the declared/defined per-CPU variable. +* It is totally compatible with the return from alloc_percpu(). +*/ +#define percpu_variable_ptr (name) (&(name))Why not just use &name?
I remember the real variable name is hidden.
We can't expose the inner details of percpu, so I add a macro for it.
Thanks,
Lai
Tejun Heo
maintainerHello,
Quoted 4 lines · Lai Jiangshan
Quoted 1 line
Why not just use &name?
I remember the real variable name is hidden.
We can't expose the inner details of percpu, so I add a macro for it.
Yeah, the whole point was unifying static and dynamic ones into the same name / address space. &name is now guaranteed to work, so no need for indirection layer.
Thanks.
Signature · 1 line
tejun