summaryrefslogtreecommitdiff
path: root/include/linux/percpu.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-07-03 08:29:51 -0500
committerThomas Gleixner <tglx@linutronix.de>2009-07-20 15:45:38 +0200
commit15868172b33ea9006afd98b0089e5b4fdb3da2c7 (patch)
treeb866796f58f99db77a7e72c2b17871cdd970c2d9 /include/linux/percpu.h
parent78af08d90b8f745044b1274430bc4bc6b2b27aca (diff)
downloadlwn-15868172b33ea9006afd98b0089e5b4fdb3da2c7.tar.gz
lwn-15868172b33ea9006afd98b0089e5b4fdb3da2c7.zip
percpu: add percpu locked infrastructure
RT needs per cpu data structures protected by per cpu locks instead of disabling preemption. Add the infrastructure for per cpu locked data. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/percpu.h')
-rw-r--r--include/linux/percpu.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 26fd9d12f050..39c4f01d2cd4 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -32,6 +32,29 @@
&__get_cpu_var(var); }))
#define put_cpu_var(var) preempt_enable()
+/*
+ * Per-CPU data structures with an additional lock - useful for
+ * PREEMPT_RT code that wants to reschedule but also wants
+ * per-CPU data structures.
+ *
+ * 'cpu' gets updated with the CPU the task is currently executing on.
+ *
+ * NOTE: on normal !PREEMPT_RT kernels these per-CPU variables
+ * are the same as the normal per-CPU variables, so there no
+ * runtime overhead.
+ */
+#define get_cpu_var_locked(var, cpuptr) \
+(*({ \
+ int __cpu = raw_smp_processor_id(); \
+ \
+ *(cpuptr) = __cpu; \
+ spin_lock(&__get_cpu_lock(var, __cpu)); \
+ &__get_cpu_var_locked(var, __cpu); \
+}))
+
+#define put_cpu_var_locked(var, cpu) \
+ do { (void)cpu; spin_unlock(&__get_cpu_lock(var, cpu)); } while (0)
+
#ifdef CONFIG_SMP
#ifdef CONFIG_HAVE_DYNAMIC_PER_CPU_AREA