linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] dynticks: A few updates
@ 2014-02-14 12:12 Frederic Weisbecker
  2014-02-14 12:12 ` [PATCH 1/2] timer: Spare IPI when deferrable timer is queued on idle remote targets Frederic Weisbecker
  2014-02-14 12:12 ` [PATCH 2/2] nohz: ensure users are aware boot CPU is not NO_HZ_FULL Frederic Weisbecker
  0 siblings, 2 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2014-02-14 12:12 UTC (permalink / raw)
  To: LKML
  Cc: Frederic Weisbecker, Paul E. McKenney, Paul Gortmaker,
	Ingo Molnar, Peter Zijlstra, Steven Rostedt, Thomas Gleixner,
	Viresh Kumar

Hi,

A small pair of updates for the dynticks code. The patch from Viresh removes a
few scheduler IPIs that I have seen on boot which are there to wake up CPUs when some
deferrable timers are enqueued. Those were enqueued on all CPUs so there is a possible
big round of IPI. And those can be avoided with the first patch. On my machine the main
sources of these were MCE, vmstat/SLAB, cpufreq. They happen either on initcall or cpu hotplug.

But deferrable timers happen anytime, not just at boot. It depends on your config and
your load. So the positive impact of the first patch should be broader.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/dynticks-testing.git
	timers/core

Thanks.

---
Paul Gortmaker (1):
  nohz: ensure users are aware boot CPU is not NO_HZ_FULL

Viresh Kumar (1):
  timer: Spare IPI when deferrable timer is queued on idle remote
    targets

 kernel/time/Kconfig | 2 +-
 kernel/timer.c      | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] timer: Spare IPI when deferrable timer is queued on idle remote targets
  2014-02-14 12:12 [PATCH 0/2] dynticks: A few updates Frederic Weisbecker
@ 2014-02-14 12:12 ` Frederic Weisbecker
  2014-02-14 12:12 ` [PATCH 2/2] nohz: ensure users are aware boot CPU is not NO_HZ_FULL Frederic Weisbecker
  1 sibling, 0 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2014-02-14 12:12 UTC (permalink / raw)
  To: LKML
  Cc: Viresh Kumar, Ingo Molnar, Paul Gortmaker, Paul E. McKenney,
	Peter Zijlstra, Steven Rostedt, Thomas Gleixner,
	Frederic Weisbecker

From: Viresh Kumar <viresh.kumar@linaro.org>

When a timer is enqueued or modified on a remote target, the latter is
expected to see and handle this timer on its next tick. However if the
target is idle and CONFIG_NO_HZ_IDLE=y, the CPU may be sleeping tickless
and the timer may be ignored.

wake_up_nohz_cpu() takes care of that by setting TIF_NEED_RESCHED and
sending an IPI to idle targets so that the tick is reevaluated on the
idle loop through the tick_nohz_idle_*() APIs.

Now this is all performed regardless of the power properties of the
timer. If the timer is deferrable, idle targets don't need to be woken
up. Only the next buzy tick needs to care about it, and no IPI kick
is needed for that to happen.

So lets spare the IPI on idle targets when the timer is deferrable.

Meanwhile we keep the current behaviour on full dynticks targets. We can
spare IPIs on idle full dynticks targets as well but some tricky races
against idle_cpu() must be dealt all along to make sure that the timer
is well handled after idle exit. We can deal with that later since
NO_HZ_FULL already has more important powersaving issues.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/CAKohpomMZ0TAN2e6N76_g4ZRzxd5vZ1XfuZfxrP7GMxfTNiLVw@mail.gmail.com
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/timer.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index accfd24..881f883 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -939,8 +939,15 @@ void add_timer_on(struct timer_list *timer, int cpu)
 	 * with the timer by holding the timer base lock. This also
 	 * makes sure that a CPU on the way to stop its tick can not
 	 * evaluate the timer wheel.
+	 *
+	 * Spare the IPI for deferrable timers on idle targets though.
+	 * The next buzy ticks will take care of it. Except full dynticks
+	 * require special care against races with idle_cpu(), lets deal
+	 * with that later.
 	 */
-	wake_up_nohz_cpu(cpu);
+	if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(cpu))
+		wake_up_nohz_cpu(cpu);
+
 	spin_unlock_irqrestore(&base->lock, flags);
 }
 EXPORT_SYMBOL_GPL(add_timer_on);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] nohz: ensure users are aware boot CPU is not NO_HZ_FULL
  2014-02-14 12:12 [PATCH 0/2] dynticks: A few updates Frederic Weisbecker
  2014-02-14 12:12 ` [PATCH 1/2] timer: Spare IPI when deferrable timer is queued on idle remote targets Frederic Weisbecker
@ 2014-02-14 12:12 ` Frederic Weisbecker
  1 sibling, 0 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2014-02-14 12:12 UTC (permalink / raw)
  To: LKML
  Cc: Paul Gortmaker, Ingo Molnar, Paul E. McKenney, Peter Zijlstra,
	Steven Rostedt, Thomas Gleixner, Frederic Weisbecker

From: Paul Gortmaker <paul.gortmaker@windriver.com>

This bit of information is in the Kconfig help text:

  "Note the boot CPU will still be kept outside the range to
  handle the timekeeping duty."

However neither the variable NO_HZ_FULL_ALL, or the prompt
convey this important detail, so lets add it to the prompt
to make it more explicitly obvious to the average user.

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1391711781-7466-1-git-send-email-paul.gortmaker@windriver.com
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/time/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig
index 3ce6e8c..f448513 100644
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -124,7 +124,7 @@ config NO_HZ_FULL
 endchoice
 
 config NO_HZ_FULL_ALL
-       bool "Full dynticks system on all CPUs by default"
+       bool "Full dynticks system on all CPUs by default (except CPU 0)"
        depends on NO_HZ_FULL
        help
          If the user doesn't pass the nohz_full boot option to
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 1/2] timer: Spare IPI when deferrable timer is queued on idle remote targets
  2014-02-26 16:52 [GIT PULL] timers update for 3.15 Frederic Weisbecker
@ 2014-02-26 16:52 ` Frederic Weisbecker
  0 siblings, 0 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2014-02-26 16:52 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: LKML, Viresh Kumar, Paul Gortmaker, Paul E. McKenney,
	Peter Zijlstra, Steven Rostedt, Thomas Gleixner,
	Frederic Weisbecker

From: Viresh Kumar <viresh.kumar@linaro.org>

When a timer is enqueued or modified on a remote target, the latter is
expected to see and handle this timer on its next tick. However if the
target is idle and CONFIG_NO_HZ_IDLE=y, the CPU may be sleeping tickless
and the timer may be ignored.

wake_up_nohz_cpu() takes care of that by setting TIF_NEED_RESCHED and
sending an IPI to idle targets so that the tick is reevaluated on the
idle loop through the tick_nohz_idle_*() APIs.

Now this is all performed regardless of the power properties of the
timer. If the timer is deferrable, idle targets don't need to be woken
up. Only the next buzy tick needs to care about it, and no IPI kick
is needed for that to happen.

So lets spare the IPI on idle targets when the timer is deferrable.

Meanwhile we keep the current behaviour on full dynticks targets. We can
spare IPIs on idle full dynticks targets as well but some tricky races
against idle_cpu() must be dealt all along to make sure that the timer
is well handled after idle exit. We can deal with that later since
NO_HZ_FULL already has more important powersaving issues.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/CAKohpomMZ0TAN2e6N76_g4ZRzxd5vZ1XfuZfxrP7GMxfTNiLVw@mail.gmail.com
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/timer.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index accfd24..b75e789 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -939,8 +939,15 @@ void add_timer_on(struct timer_list *timer, int cpu)
 	 * with the timer by holding the timer base lock. This also
 	 * makes sure that a CPU on the way to stop its tick can not
 	 * evaluate the timer wheel.
+	 *
+	 * Spare the IPI for deferrable timers on idle targets though.
+	 * The next busy ticks will take care of it. Except full dynticks
+	 * require special care against races with idle_cpu(), lets deal
+	 * with that later.
 	 */
-	wake_up_nohz_cpu(cpu);
+	if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(cpu))
+		wake_up_nohz_cpu(cpu);
+
 	spin_unlock_irqrestore(&base->lock, flags);
 }
 EXPORT_SYMBOL_GPL(add_timer_on);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-26 16:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14 12:12 [PATCH 0/2] dynticks: A few updates Frederic Weisbecker
2014-02-14 12:12 ` [PATCH 1/2] timer: Spare IPI when deferrable timer is queued on idle remote targets Frederic Weisbecker
2014-02-14 12:12 ` [PATCH 2/2] nohz: ensure users are aware boot CPU is not NO_HZ_FULL Frederic Weisbecker
2014-02-26 16:52 [GIT PULL] timers update for 3.15 Frederic Weisbecker
2014-02-26 16:52 ` [PATCH 1/2] timer: Spare IPI when deferrable timer is queued on idle remote targets Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).