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: <1347459195-5491-2-git-send-email-eranian@google.com>
Date:	Wed, 12 Sep 2012 16:13:13 +0200
From:	Stephane Eranian <eranian@...gle.com>
To:	linux-kernel@...r.kernel.org
Cc:	peterz@...radead.org, mingo@...e.hu, ak@...ux.intel.com,
	zheng.z.yan@...el.com, robert.richter@....com
Subject: [PATCH v2 1/3] hrtimer: add hrtimer_init_cpu()

hrtimer_init() assumes it is called for the current CPU
as it accesses per-cpu variables (hrtimer_bases).

However, there can be cases where a hrtimer is initialized
from a different CPU, so add an entry point to make this
more explicit.

Signed-off-by: Stephane Eranian <eranian@...gle.com>
---
 include/linux/hrtimer.h |    3 +++
 kernel/hrtimer.c        |   17 ++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index cc07d27..9d07e93 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -337,6 +337,9 @@ DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
 /* Initialize timers: */
 extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
 			 enum hrtimer_mode mode);
+extern void hrtimer_init_cpu(int cpu, struct hrtimer *timer,
+			     clockid_t which_clock,
+			     enum hrtimer_mode mode);
 
 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
 extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 6db7a5e..cde7fc4 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -440,14 +440,14 @@ static inline void debug_hrtimer_free(struct hrtimer *timer)
 	debug_object_free(timer, &hrtimer_debug_descr);
 }
 
-static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
+static void __hrtimer_init(int cpu, struct hrtimer *timer, clockid_t clock_id,
 			   enum hrtimer_mode mode);
 
 void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id,
 			   enum hrtimer_mode mode)
 {
 	debug_object_init_on_stack(timer, &hrtimer_debug_descr);
-	__hrtimer_init(timer, clock_id, mode);
+	__hrtimer_init(smp_processor_id(), timer, clock_id, mode);
 }
 EXPORT_SYMBOL_GPL(hrtimer_init_on_stack);
 
@@ -1146,7 +1146,7 @@ ktime_t hrtimer_get_next_event(void)
 }
 #endif
 
-static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
+static void __hrtimer_init(int cpu, struct hrtimer *timer, clockid_t clock_id,
 			   enum hrtimer_mode mode)
 {
 	struct hrtimer_cpu_base *cpu_base;
@@ -1154,7 +1154,7 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
 
 	memset(timer, 0, sizeof(struct hrtimer));
 
-	cpu_base = &__raw_get_cpu_var(hrtimer_bases);
+	cpu_base = &per_cpu(hrtimer_bases, cpu);
 
 	if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS)
 		clock_id = CLOCK_MONOTONIC;
@@ -1180,10 +1180,17 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
 		  enum hrtimer_mode mode)
 {
 	debug_init(timer, clock_id, mode);
-	__hrtimer_init(timer, clock_id, mode);
+	__hrtimer_init(smp_processor_id(), timer, clock_id, mode);
 }
 EXPORT_SYMBOL_GPL(hrtimer_init);
 
+void hrtimer_init_cpu(int cpu, struct hrtimer *timer, clockid_t clock_id,
+		  enum hrtimer_mode mode)
+{
+	debug_init(timer, clock_id, mode);
+	__hrtimer_init(cpu, timer, clock_id, mode);
+}
+
 /**
  * hrtimer_get_res - get the timer resolution for a clock
  * @which_clock: which clock to query
-- 
1.7.5.4

--
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