Skip to contentSkip to conversation

percpu: add percpu_variable_ptr()

PATCH In review Lai Jiangshan 2 participants 4 messages Jun 23, 2010 Per-CPU memory allocator

lore
Share & tools
lore
#0 lore raw

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
index ce2dc65..d5c8d7f 100644
@@ -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.
  */
maintainer
#1 lore raw
Quoted 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.

---

include/linux/percpu-defs.h +0 -0
index ce2dc65..d5c8d7f 100644

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
#2 lore raw
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.

---

include/linux/percpu-defs.h +0 -0
index ce2dc65..d5c8d7f 100644
@@ -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

maintainer
#3 lore raw

Hello,

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