public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Rob van der Heij <rvdheij@gmail.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	john stultz <johnstul@us.ibm.com>,
	Andi Kleen <andi@firstfloor.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 1/2] idle profile hits with NOHZ
Date: Wed, 03 Jun 2009 17:22:24 +0200	[thread overview]
Message-ID: <20090603152313.281689482@de.ibm.com> (raw)
In-Reply-To: 20090603152223.083010123@de.ibm.com

[-- Attachment #1: profile-idle-tick.diff --]
[-- Type: text/plain, Size: 2989 bytes --]

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

On a NOHZ system the generic clock events code reports a maximum
of 1 tick to the kernel profiler. If the system slept for more than
a single tick or has not been woken by a timer interrupt the number
of ticks reported will be incorrect. This skewes the percentages in
the profile. A good place to report the profile ticks is in
tick_nohz_restart_sched_tick. We calculate the number of ticks for
the cpu accounting anyway. The only obstacle is that we need an
instruction address for the profile ticks. In order to get one
extend the tick_sched structure by an idle_pc field and set it in
tick_nohz_stop_idle which is called from tick_check_idle.
Note: this does not solve the same problem in oprofile.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 include/linux/tick.h     |    1 +
 kernel/time/tick-sched.c |   14 +++++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

Index: quilt-2.6/include/linux/tick.h
===================================================================
--- quilt-2.6.orig/include/linux/tick.h
+++ quilt-2.6/include/linux/tick.h
@@ -64,6 +64,7 @@ struct tick_sched {
 	unsigned long			last_jiffies;
 	unsigned long			next_jiffies;
 	ktime_t				idle_expires;
+	unsigned long			idle_pc;
 };
 
 extern void __init tick_init(void);
Index: quilt-2.6/kernel/time/tick-sched.c
===================================================================
--- quilt-2.6.orig/kernel/time/tick-sched.c
+++ quilt-2.6/kernel/time/tick-sched.c
@@ -166,6 +166,8 @@ static void tick_nohz_stop_idle(int cpu)
 		ts->idle_lastupdate = now;
 		ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
 		ts->idle_active = 0;
+		if (in_interrupt())
+			ts->idle_pc = profile_pc(get_irq_regs());
 
 		sched_clock_idle_wakeup_event(0);
 	}
@@ -419,9 +421,7 @@ void tick_nohz_restart_sched_tick(void)
 {
 	int cpu = smp_processor_id();
 	struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
-#ifndef CONFIG_VIRT_CPU_ACCOUNTING
 	unsigned long ticks;
-#endif
 	ktime_t now;
 
 	local_irq_disable();
@@ -443,19 +443,23 @@ void tick_nohz_restart_sched_tick(void)
 	tick_do_update_jiffies64(now);
 	cpumask_clear_cpu(cpu, nohz_cpu_mask);
 
+	ticks = jiffies - ts->idle_jiffies;
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING
 	/*
 	 * We stopped the tick in idle. Update process times would miss the
 	 * time we slept as update_process_times does only a 1 tick
 	 * accounting. Enforce that this is accounted to idle !
-	 */
-	ticks = jiffies - ts->idle_jiffies;
-	/*
+	 *
 	 * We might be one off. Do not randomly account a huge number of ticks!
 	 */
 	if (ticks && ticks < LONG_MAX)
 		account_idle_ticks(ticks);
 #endif
+#ifdef CONFIG_PROFILING
+	/* Create profile hits for all ticks we slept in idle. */
+	if (ticks && ticks < LONG_MAX)
+		profile_hits(CPU_PROFILING, (void *) ts->idle_pc, ticks);
+#endif
 
 	touch_softlockup_watchdog();
 	/*

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


  reply	other threads:[~2009-06-03 15:24 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-03 15:22 [patch 0/2] NOHZ vs. profile/oprofile v2 Martin Schwidefsky
2009-06-03 15:22 ` Martin Schwidefsky [this message]
2009-06-03 15:22 ` [patch 2/2] keep on ticking if oprofile is active Martin Schwidefsky
2009-06-09 20:52 ` [patch 0/2] NOHZ vs. profile/oprofile v2 Thomas Gleixner
2009-06-10 17:33   ` Martin Schwidefsky
2009-06-22 14:26   ` Martin Schwidefsky
2009-06-22 14:41     ` Ingo Molnar
2009-06-22 14:59       ` Martin Schwidefsky
2009-06-22 15:05         ` Ingo Molnar
2009-06-22 15:18           ` Martin Schwidefsky
2009-06-22 15:29             ` Ingo Molnar
2009-06-22 15:36               ` Martin Schwidefsky
2009-06-22 15:40                 ` Ingo Molnar
2009-06-22 16:37                   ` Martin Schwidefsky
2009-06-24 16:51                   ` Martin Schwidefsky
2009-06-24 17:47                     ` Ingo Molnar
2010-03-02 13:57                     ` Aaro Koskinen
2010-03-02 15:01                       ` Martin Schwidefsky
2010-03-02 15:08                         ` Thomas Gleixner
2010-03-02 15:25                           ` Martin Schwidefsky
2010-03-02 15:38                           ` Robert Richter
  -- strict thread matches above, loose matches on Subject: below --
2009-05-28 15:04 [patch 0/2] NOHZ vs. profile/oprofile Martin Schwidefsky
2009-05-28 15:04 ` [patch 1/2] idle profile hits with NOHZ Martin Schwidefsky
2009-05-28 20:19   ` Thomas Gleixner
2009-05-29 12:56     ` Martin Schwidefsky
2009-05-29 13:15       ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090603152313.281689482@de.ibm.com \
    --to=schwidefsky@de.ibm.com \
    --cc=andi@firstfloor.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rvdheij@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox