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-next>] [day] [month] [year] [list]
Message-ID: <20110817160759.GA3482@sgi.com>
Date:	Wed, 17 Aug 2011 11:07:59 -0500
From:	Dimitri Sivanich <sivanich@....com>
To:	linux-kernel@...r.kernel.org
Cc:	Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...e.hu>
Subject: [PATCH] specific do_timer_cpu value for nohz off mode

Reposting this, as this was posted 2 weeks ago with no replies.

Jiffies updates are currently done by the tick_do_timer_cpu.  This has a
non-deterministic value that can be any running cpu on the system.  It
changes dynamically in nohz mode.  When nohz mode is off, it gets set to
a more static, but still non-deterministic value.

While the nohz behavior is necessary, is there a reason why the nohz off
case can't have a specific value, say 0 as it was on earlier kernels?
If the cpu is offlined, let the value change at that time (note that the
x86 arch disallows offlining cpu 0).

There are certain cases where this would be advantageous, especially where
timely jiffies updates may not necessarily occur on specific processors.

The following sample patch presents one way that this could be done.
Processors wait for the selected cpu to enter high resolution mode before
they do so.

Note that this patch is not hotplug aware (however, should the
tick_static_do_timer_cpu be offlined, the tick_do_timer_cpu simply becomes
another cpu anyway).

Comments on this idea, or the sample patch?

Signed-off-by: Dimitri Sivanich <sivanich@....com>
---
 Documentation/kernel-parameters.txt |    8 +++++
 kernel/time/tick-sched.c            |   46 ++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

Index: linux/kernel/time/tick-sched.c
===================================================================
--- linux.orig/kernel/time/tick-sched.c
+++ linux/kernel/time/tick-sched.c
@@ -30,11 +30,54 @@
  */
 static DEFINE_PER_CPU(struct tick_sched, tick_cpu_sched);
 
+DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
+
 /*
  * The time, when the last jiffy update happened. Protected by xtime_lock.
  */
 static ktime_t last_jiffies_update;
 
+/*
+ * Static tick_do_timer_cpu
+ */
+static int tick_static_do_timer_cpu __read_mostly = -1;
+
+/*
+ * Set tick_do_timer_cpu to a static cpu.
+ *
+ * Supported on systems w/nohz=off only.
+ * Selected cpu can be offlined.  If this is done, another cpu will be chosen,
+ * but will not revert back if selected cpu is onlined again.
+ */
+static int __init setup_static_do_timer_cpu(char *s)
+{
+	if (kstrtoint(s, 0, &tick_static_do_timer_cpu) < 0) {
+		printk(KERN_WARNING "Invalid tick_static_do_timer_cpu specified\n");
+		return 0;
+	}
+	printk(KERN_INFO "Set tick_static_do_timer_cpu %d\n",
+		tick_static_do_timer_cpu);
+
+	return 1;
+}
+__setup("do_timer_cpu=", setup_static_do_timer_cpu);
+
+/*
+ * Check to see if we need to wait for the selected static do_timer_cpu
+ * to enter high res mode first.
+ */
+static int wait_for_static_do_timer_cpu(void)
+{
+	if (tick_static_do_timer_cpu == -1)
+		return 0;
+
+	if (smp_processor_id() != tick_static_do_timer_cpu &&
+	    !*per_cpu_ptr(&hrtimer_bases.hres_active, tick_static_do_timer_cpu))
+		return 1;
+
+	return 0;
+}
+
 struct tick_sched *tick_get_tick_sched(int cpu)
 {
 	return &per_cpu(tick_cpu_sched, cpu);
@@ -848,6 +891,9 @@ int tick_check_oneshot_change(int allow_
 {
 	struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
 
+	if (!allow_nohz && !tick_nohz_enabled && wait_for_static_do_timer_cpu())
+		return 0;
+
 	if (!test_and_clear_bit(0, &ts->check_clocks))
 		return 0;
 
Index: linux/Documentation/kernel-parameters.txt
===================================================================
--- linux.orig/Documentation/kernel-parameters.txt
+++ linux/Documentation/kernel-parameters.txt
@@ -665,6 +665,14 @@ bytes respectively. Such letter suffixes
 			The filter can be disabled or changed to another
 			driver later using sysfs.
 
+	do_timer_cpu=<cpu number>
+			This selects the cpu to process jiffies updates
+			when nohz mode is disabled.
+			Works only with high resolution mode enabled.
+			The selected cpu can be offlined.  If this is done,
+			another cpu will be chosen, but will not revert back
+			if the selected cpu is onlined again.
+
 	dscc4.setup=	[NET]
 
 	earlycon=	[KNL] Output early console device and options.
--
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