linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] tick: Some consolidation cleanups
@ 2012-10-15 16:59 Frederic Weisbecker
  2012-10-15 16:59 ` [PATCH 1/3] tick: Consolidate timekeeping handling code Frederic Weisbecker
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2012-10-15 16:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Peter Zijlstra

Ingo, Thomas,

I guess those patches are not controversial so I'm joining a
pull request on the first take, just in case.

This can be pulled from:

git://github.com/fweisbec/linux-dynticks.git
	nohz/core

Thanks.

Frederic Weisbecker (3):
  tick: Consolidate timekeeping handling code
  tick: Consolidate tick handling for high and low res handlers
  tick: Conditionally build nohz specific code in tick handler

 kernel/time/tick-sched.c |  111 ++++++++++++++++++++--------------------------
 1 files changed, 48 insertions(+), 63 deletions(-)

-- 
1.7.5.4


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

* [PATCH 1/3] tick: Consolidate timekeeping handling code
  2012-10-15 16:59 [GIT PULL] tick: Some consolidation cleanups Frederic Weisbecker
@ 2012-10-15 16:59 ` Frederic Weisbecker
  2012-10-15 16:59 ` [PATCH 2/3] tick: Consolidate tick handling for high and low res handlers Frederic Weisbecker
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2012-10-15 16:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Peter Zijlstra

Unify the duplicated timekeeping handling code of low and high res tick
sched handlers.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 kernel/time/tick-sched.c |   54 ++++++++++++++++++++-------------------------
 1 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index a402608..360674c 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -98,6 +98,28 @@ static ktime_t tick_init_jiffy_update(void)
 	return period;
 }
 
+
+static void tick_sched_do_timer(ktime_t now)
+{
+	int cpu = smp_processor_id();
+
+#ifdef CONFIG_NO_HZ
+	/*
+	 * Check if the do_timer duty was dropped. We don't care about
+	 * concurrency: This happens only when the cpu in charge went
+	 * into a long sleep. If two cpus happen to assign themself to
+	 * this duty, then the jiffies update is still serialized by
+	 * xtime_lock.
+	 */
+	if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE))
+		tick_do_timer_cpu = cpu;
+#endif
+
+	/* Check, if the jiffies need an update */
+	if (tick_do_timer_cpu == cpu)
+		tick_do_update_jiffies64(now);
+}
+
 /*
  * NOHZ - aka dynamic tick functionality
  */
@@ -648,24 +670,11 @@ static void tick_nohz_handler(struct clock_event_device *dev)
 {
 	struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
 	struct pt_regs *regs = get_irq_regs();
-	int cpu = smp_processor_id();
 	ktime_t now = ktime_get();
 
 	dev->next_event.tv64 = KTIME_MAX;
 
-	/*
-	 * Check if the do_timer duty was dropped. We don't care about
-	 * concurrency: This happens only when the cpu in charge went
-	 * into a long sleep. If two cpus happen to assign themself to
-	 * this duty, then the jiffies update is still serialized by
-	 * xtime_lock.
-	 */
-	if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE))
-		tick_do_timer_cpu = cpu;
-
-	/* Check, if the jiffies need an update */
-	if (tick_do_timer_cpu == cpu)
-		tick_do_update_jiffies64(now);
+	tick_sched_do_timer(now);
 
 	/*
 	 * When we are idle and the tick is stopped, we have to touch
@@ -802,23 +811,8 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
 		container_of(timer, struct tick_sched, sched_timer);
 	struct pt_regs *regs = get_irq_regs();
 	ktime_t now = ktime_get();
-	int cpu = smp_processor_id();
 
-#ifdef CONFIG_NO_HZ
-	/*
-	 * Check if the do_timer duty was dropped. We don't care about
-	 * concurrency: This happens only when the cpu in charge went
-	 * into a long sleep. If two cpus happen to assign themself to
-	 * this duty, then the jiffies update is still serialized by
-	 * xtime_lock.
-	 */
-	if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE))
-		tick_do_timer_cpu = cpu;
-#endif
-
-	/* Check, if the jiffies need an update */
-	if (tick_do_timer_cpu == cpu)
-		tick_do_update_jiffies64(now);
+	tick_sched_do_timer(now);
 
 	/*
 	 * Do not call, when we are not in irq context and have
-- 
1.7.5.4


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

* [PATCH 2/3] tick: Consolidate tick handling for high and low res handlers
  2012-10-15 16:59 [GIT PULL] tick: Some consolidation cleanups Frederic Weisbecker
  2012-10-15 16:59 ` [PATCH 1/3] tick: Consolidate timekeeping handling code Frederic Weisbecker
@ 2012-10-15 16:59 ` Frederic Weisbecker
  2012-10-15 16:59 ` [PATCH 3/3] tick: Conditionally build nohz specific code in tick handler Frederic Weisbecker
  2012-10-21 16:15 ` [GIT PULL] tick: Some consolidation cleanups Ingo Molnar
  3 siblings, 0 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2012-10-15 16:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Peter Zijlstra

Besides unifying code, this also adds the idle check before
processing idle accounting specifics on the low res handler.
This way we also generalize this part of the nohz code for
!CONFIG_HIGH_RES_TIMERS to prepare for the adaptive tickless
features.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 kernel/time/tick-sched.c |   55 ++++++++++++++++++---------------------------
 1 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 360674c..68a873a 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -120,6 +120,25 @@ static void tick_sched_do_timer(ktime_t now)
 		tick_do_update_jiffies64(now);
 }
 
+static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
+{
+	/*
+	 * When we are idle and the tick is stopped, we have to touch
+	 * the watchdog as we might not schedule for a really long
+	 * time. This happens on complete idle SMP systems while
+	 * waiting on the login prompt. We also increment the "start of
+	 * idle" jiffy stamp so the idle accounting adjustment we do
+	 * when we go busy again does not account too much ticks.
+	 */
+	if (ts->tick_stopped) {
+		touch_softlockup_watchdog();
+		if (is_idle_task(current))
+			ts->idle_jiffies++;
+	}
+	update_process_times(user_mode(regs));
+	profile_tick(CPU_PROFILING);
+}
+
 /*
  * NOHZ - aka dynamic tick functionality
  */
@@ -675,22 +694,7 @@ static void tick_nohz_handler(struct clock_event_device *dev)
 	dev->next_event.tv64 = KTIME_MAX;
 
 	tick_sched_do_timer(now);
-
-	/*
-	 * When we are idle and the tick is stopped, we have to touch
-	 * the watchdog as we might not schedule for a really long
-	 * time. This happens on complete idle SMP systems while
-	 * waiting on the login prompt. We also increment the "start
-	 * of idle" jiffy stamp so the idle accounting adjustment we
-	 * do when we go busy again does not account too much ticks.
-	 */
-	if (ts->tick_stopped) {
-		touch_softlockup_watchdog();
-		ts->idle_jiffies++;
-	}
-
-	update_process_times(user_mode(regs));
-	profile_tick(CPU_PROFILING);
+	tick_sched_handle(ts, regs);
 
 	while (tick_nohz_reprogram(ts, now)) {
 		now = ktime_get();
@@ -818,23 +822,8 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
 	 * Do not call, when we are not in irq context and have
 	 * no valid regs pointer
 	 */
-	if (regs) {
-		/*
-		 * When we are idle and the tick is stopped, we have to touch
-		 * the watchdog as we might not schedule for a really long
-		 * time. This happens on complete idle SMP systems while
-		 * waiting on the login prompt. We also increment the "start of
-		 * idle" jiffy stamp so the idle accounting adjustment we do
-		 * when we go busy again does not account too much ticks.
-		 */
-		if (ts->tick_stopped) {
-			touch_softlockup_watchdog();
-			if (is_idle_task(current))
-				ts->idle_jiffies++;
-		}
-		update_process_times(user_mode(regs));
-		profile_tick(CPU_PROFILING);
-	}
+	if (regs)
+		tick_sched_handle(ts, regs);
 
 	hrtimer_forward(timer, now, tick_period);
 
-- 
1.7.5.4


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

* [PATCH 3/3] tick: Conditionally build nohz specific code in tick handler
  2012-10-15 16:59 [GIT PULL] tick: Some consolidation cleanups Frederic Weisbecker
  2012-10-15 16:59 ` [PATCH 1/3] tick: Consolidate timekeeping handling code Frederic Weisbecker
  2012-10-15 16:59 ` [PATCH 2/3] tick: Consolidate tick handling for high and low res handlers Frederic Weisbecker
@ 2012-10-15 16:59 ` Frederic Weisbecker
  2012-10-21 16:15 ` [GIT PULL] tick: Some consolidation cleanups Ingo Molnar
  3 siblings, 0 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2012-10-15 16:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Peter Zijlstra

This optimize a bit the high res tick sched handler.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 kernel/time/tick-sched.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 68a873a..766d4c4 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -122,6 +122,7 @@ static void tick_sched_do_timer(ktime_t now)
 
 static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
 {
+#ifdef CONFIG_NO_HZ
 	/*
 	 * When we are idle and the tick is stopped, we have to touch
 	 * the watchdog as we might not schedule for a really long
@@ -135,6 +136,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
 		if (is_idle_task(current))
 			ts->idle_jiffies++;
 	}
+#endif
 	update_process_times(user_mode(regs));
 	profile_tick(CPU_PROFILING);
 }
-- 
1.7.5.4


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

* Re: [GIT PULL] tick: Some consolidation cleanups
  2012-10-15 16:59 [GIT PULL] tick: Some consolidation cleanups Frederic Weisbecker
                   ` (2 preceding siblings ...)
  2012-10-15 16:59 ` [PATCH 3/3] tick: Conditionally build nohz specific code in tick handler Frederic Weisbecker
@ 2012-10-21 16:15 ` Ingo Molnar
  3 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2012-10-21 16:15 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: Thomas Gleixner, LKML, Peter Zijlstra


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> Ingo, Thomas,
> 
> I guess those patches are not controversial so I'm joining a
> pull request on the first take, just in case.
> 
> This can be pulled from:
> 
> git://github.com/fweisbec/linux-dynticks.git
> 	nohz/core
> 
> Thanks.
> 
> Frederic Weisbecker (3):
>   tick: Consolidate timekeeping handling code
>   tick: Consolidate tick handling for high and low res handlers
>   tick: Conditionally build nohz specific code in tick handler
> 
>  kernel/time/tick-sched.c |  111 ++++++++++++++++++++--------------------------
>  1 files changed, 48 insertions(+), 63 deletions(-)

Pulled, thanks Frederic!

	Ingo

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

end of thread, other threads:[~2012-10-21 16:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-15 16:59 [GIT PULL] tick: Some consolidation cleanups Frederic Weisbecker
2012-10-15 16:59 ` [PATCH 1/3] tick: Consolidate timekeeping handling code Frederic Weisbecker
2012-10-15 16:59 ` [PATCH 2/3] tick: Consolidate tick handling for high and low res handlers Frederic Weisbecker
2012-10-15 16:59 ` [PATCH 3/3] tick: Conditionally build nohz specific code in tick handler Frederic Weisbecker
2012-10-21 16:15 ` [GIT PULL] tick: Some consolidation cleanups Ingo Molnar

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