linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] nohz: Remove update_ts_time_stat from tick_nohz_start_idle
@ 2012-01-24 17:59 Frederic Weisbecker
  2012-01-24 17:59 ` [PATCH 2/3] nohz: Remove ts->inidle checks before restarting the tick Frederic Weisbecker
  2012-01-24 17:59 ` [PATCH 3/3] timer: Fix bad idle check on irq entry Frederic Weisbecker
  0 siblings, 2 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2012-01-24 17:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: LKML, Michal Hocko, Arjan van de Ven, Peter Zijlstra,
	John Stultz, Frederic Weisbecker

From: Michal Hocko <mhocko@suse.cz>

There is no reason to call update_ts_time_stat from tick_nohz_start_idle
anymore (after e0e37c20 sched: Eliminate the ts->idle_lastupdate field)
when we updated idle_lastupdate unconditionally.

We haven't set idle_active yet and do not provide last_update_time so
the whole call end up being just 2 wasted branches.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
CC: Arjan van de Ven <arjan@linux.intel.com>
CC: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: John Stultz <john.stultz@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/time/tick-sched.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 7656642..85a67e8 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -186,8 +186,6 @@ static ktime_t tick_nohz_start_idle(int cpu, struct tick_sched *ts)
 
 	now = ktime_get();
 
-	update_ts_time_stats(cpu, ts, now, NULL);
-
 	ts->idle_entrytime = now;
 	ts->idle_active = 1;
 	sched_clock_idle_sleep_event();
-- 
1.7.5.4


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

* [PATCH 2/3] nohz: Remove ts->inidle checks before restarting the tick
  2012-01-24 17:59 [PATCH 1/3] nohz: Remove update_ts_time_stat from tick_nohz_start_idle Frederic Weisbecker
@ 2012-01-24 17:59 ` Frederic Weisbecker
  2012-02-15 19:38   ` [tip:timers/core] nohz: Remove ts-> Einidle " tip-bot for Frederic Weisbecker
  2012-01-24 17:59 ` [PATCH 3/3] timer: Fix bad idle check on irq entry Frederic Weisbecker
  1 sibling, 1 reply; 5+ messages in thread
From: Frederic Weisbecker @ 2012-01-24 17:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: LKML, Frederic Weisbecker, Peter Zijlstra, John Stultz

ts->inidle is set by tick_nohz_idle_enter() and unset by
tick_nohz_idle_exit(). However These two calls are assumed
to be always paired. This means that by the time we call
tick_nohz_idle_exit(), ts->inidle is supposed to be always
set to 1.

Remove the checks for ts->inidle in tick_nohz_idle_exit().
This simplifies a bit the code and improves its debuggability
(ie: ensure the call is paired with a tick_nohz_idle_enter()
call).

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Reviewed-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
---
 kernel/time/tick-sched.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 85a67e8..6aecf74 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -560,20 +560,21 @@ void tick_nohz_idle_exit(void)
 
 	local_irq_disable();
 
-	if (ts->idle_active || (ts->inidle && ts->tick_stopped))
+	WARN_ON_ONCE(!ts->inidle);
+
+	ts->inidle = 0;
+
+	if (ts->idle_active || ts->tick_stopped)
 		now = ktime_get();
 
 	if (ts->idle_active)
 		tick_nohz_stop_idle(cpu, now);
 
-	if (!ts->inidle || !ts->tick_stopped) {
-		ts->inidle = 0;
+	if (!ts->tick_stopped) {
 		local_irq_enable();
 		return;
 	}
 
-	ts->inidle = 0;
-
 	/* Update jiffies first */
 	select_nohz_load_balancer(0);
 	tick_do_update_jiffies64(now);
-- 
1.7.5.4


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

* [PATCH 3/3] timer: Fix bad idle check on irq entry
  2012-01-24 17:59 [PATCH 1/3] nohz: Remove update_ts_time_stat from tick_nohz_start_idle Frederic Weisbecker
  2012-01-24 17:59 ` [PATCH 2/3] nohz: Remove ts->inidle checks before restarting the tick Frederic Weisbecker
@ 2012-01-24 17:59 ` Frederic Weisbecker
  2012-02-15 19:39   ` [tip:timers/core] " tip-bot for Frederic Weisbecker
  1 sibling, 1 reply; 5+ messages in thread
From: Frederic Weisbecker @ 2012-01-24 17:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: LKML, Frederic Weisbecker, Peter Zijlstra, John Stultz

idle_cpu() is called on irq entry to guess if
we need to call tick_check_idle(). This way we can
catch up with jiffies if the tick was stopped, stop
accounting idle time during the interrupt and maintain
the sched clock if it is unstable.

But if we are going to exit the idle loop to schedule
a new task (ie: if we have a task in the runqueue or a
remotely enqueued ttwu to perform), the idle_cpu() check
will return 0 such that we miss the call to tick_check_idle()
for all interrupts happening before we schedule the new task.

As a result these interrupts and the softirqs coming
along may deal with stale jiffies values, bad sched clock
values, and won't substract their time from the idle time
accounting.

Fix this with using is_idle_task() instead that strictly
checks that we are running the idle task, without caring
about the fact we are going to schedule a task soon.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: John Stultz <john.stultz@linaro.org>
---
 kernel/softirq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 4eb3a0f..5ace266 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -297,7 +297,7 @@ void irq_enter(void)
 	int cpu = smp_processor_id();
 
 	rcu_irq_enter();
-	if (idle_cpu(cpu) && !in_interrupt()) {
+	if (is_idle_task(current) && !in_interrupt()) {
 		/*
 		 * Prevent raise_softirq from needlessly waking up ksoftirqd
 		 * here, as softirq will be serviced on return from interrupt.
-- 
1.7.5.4


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

* [tip:timers/core] nohz: Remove ts-> Einidle checks before restarting the tick
  2012-01-24 17:59 ` [PATCH 2/3] nohz: Remove ts->inidle checks before restarting the tick Frederic Weisbecker
@ 2012-02-15 19:38   ` tip-bot for Frederic Weisbecker
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2012-02-15 19:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, john.stultz, fweisbec,
	tglx, yong.zhang0, mingo

Commit-ID:  15f827be93928890bba965bc175caee50c4406d2
Gitweb:     http://git.kernel.org/tip/15f827be93928890bba965bc175caee50c4406d2
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Tue, 24 Jan 2012 18:59:43 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 15 Feb 2012 15:23:09 +0100

nohz: Remove ts->Einidle checks before restarting the tick

ts->inidle is set by tick_nohz_idle_enter() and unset by
tick_nohz_idle_exit(). However these two calls are assumed
to be always paired. This means that by the time we call
tick_nohz_idle_exit(), ts->inidle is supposed to be always
set to 1.

Remove the checks for ts->inidle in tick_nohz_idle_exit().
This simplifies a bit the code and improves its debuggability
(ie: ensure the call is paired with a tick_nohz_idle_enter()
call).

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Reviewed-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Ingo Molnar <mingo@elte.hu>
Link: http://lkml.kernel.org/r/1327427984-23282-2-git-send-email-fweisbec@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/tick-sched.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 8cfffd9..3526038 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -558,20 +558,21 @@ void tick_nohz_idle_exit(void)
 
 	local_irq_disable();
 
-	if (ts->idle_active || (ts->inidle && ts->tick_stopped))
+	WARN_ON_ONCE(!ts->inidle);
+
+	ts->inidle = 0;
+
+	if (ts->idle_active || ts->tick_stopped)
 		now = ktime_get();
 
 	if (ts->idle_active)
 		tick_nohz_stop_idle(cpu, now);
 
-	if (!ts->inidle || !ts->tick_stopped) {
-		ts->inidle = 0;
+	if (!ts->tick_stopped) {
 		local_irq_enable();
 		return;
 	}
 
-	ts->inidle = 0;
-
 	/* Update jiffies first */
 	select_nohz_load_balancer(0);
 	tick_do_update_jiffies64(now);

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

* [tip:timers/core] timer: Fix bad idle check on irq entry
  2012-01-24 17:59 ` [PATCH 3/3] timer: Fix bad idle check on irq entry Frederic Weisbecker
@ 2012-02-15 19:39   ` tip-bot for Frederic Weisbecker
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2012-02-15 19:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, john.stultz, fweisbec,
	tglx, mingo

Commit-ID:  0a8a2e78b7eece7c65884fcff9f98dc0fce89ee4
Gitweb:     http://git.kernel.org/tip/0a8a2e78b7eece7c65884fcff9f98dc0fce89ee4
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Tue, 24 Jan 2012 18:59:44 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 15 Feb 2012 15:23:09 +0100

timer: Fix bad idle check on irq entry

idle_cpu() is called on irq entry to guess if we need to call
tick_check_idle(). This way we can catch up with jiffies if the tick
was stopped, stop accounting idle time during the interrupt and
maintain the sched clock if it is unstable.

But if we are going to exit the idle loop to schedule a new task (ie:
if we have a task in the runqueue or a remotely enqueued ttwu to
perform), the idle_cpu() check will return 0 such that we miss the
call to tick_check_idle() for all interrupts happening before we
schedule the new task.

As a result these interrupts and the softirqs coming along may deal
with stale jiffies values, bad sched clock values, and won't substract
their time from the idle time accounting.

Fix this with using is_idle_task() instead that strictly checks that
we are running the idle task, without caring about the fact we are
going to schedule a task soon.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Ingo Molnar <mingo@elte.hu>
Link: http://lkml.kernel.org/r/1327427984-23282-3-git-send-email-fweisbec@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/softirq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 4eb3a0f..5ace266 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -297,7 +297,7 @@ void irq_enter(void)
 	int cpu = smp_processor_id();
 
 	rcu_irq_enter();
-	if (idle_cpu(cpu) && !in_interrupt()) {
+	if (is_idle_task(current) && !in_interrupt()) {
 		/*
 		 * Prevent raise_softirq from needlessly waking up ksoftirqd
 		 * here, as softirq will be serviced on return from interrupt.

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

end of thread, other threads:[~2012-02-15 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 17:59 [PATCH 1/3] nohz: Remove update_ts_time_stat from tick_nohz_start_idle Frederic Weisbecker
2012-01-24 17:59 ` [PATCH 2/3] nohz: Remove ts->inidle checks before restarting the tick Frederic Weisbecker
2012-02-15 19:38   ` [tip:timers/core] nohz: Remove ts-> Einidle " tip-bot for Frederic Weisbecker
2012-01-24 17:59 ` [PATCH 3/3] timer: Fix bad idle check on irq entry Frederic Weisbecker
2012-02-15 19:39   ` [tip:timers/core] " tip-bot for 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).