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>,
Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 1/2] idle profile hits with NOHZ
Date: Thu, 28 May 2009 17:04:48 +0200 [thread overview]
Message-ID: <20090528150502.044210490@de.ibm.com> (raw)
In-Reply-To: 20090528150447.152019714@de.ibm.com
[-- Attachment #1: profile-idle-tick.diff --]
[-- Type: text/plain, Size: 2963 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 | 13 ++++++++-----
2 files changed, 9 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,7 @@ 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;
+ ts->idle_pc = profile_pc(get_irq_regs());
sched_clock_idle_wakeup_event(0);
}
@@ -419,9 +420,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 +442,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.
next prev parent reply other threads:[~2009-05-28 15:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-28 15:04 [patch 0/2] NOHZ vs. profile/oprofile Martin Schwidefsky
2009-05-28 15:04 ` Martin Schwidefsky [this message]
2009-05-28 20:19 ` [patch 1/2] idle profile hits with NOHZ Thomas Gleixner
2009-05-29 12:56 ` Martin Schwidefsky
2009-05-29 13:15 ` Thomas Gleixner
2009-05-28 15:04 ` [patch 2/2] keep on ticking if oprofile is active Martin Schwidefsky
2009-05-28 20:29 ` Thomas Gleixner
2009-05-29 12:57 ` Martin Schwidefsky
2009-05-29 13:14 ` Thomas Gleixner
2009-06-01 8:09 ` Andi Kleen
2009-06-01 10:22 ` Martin Schwidefsky
-- strict thread matches above, loose matches on Subject: below --
2009-06-03 15:22 [patch 0/2] NOHZ vs. profile/oprofile v2 Martin Schwidefsky
2009-06-03 15:22 ` [patch 1/2] idle profile hits with NOHZ Martin Schwidefsky
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=20090528150502.044210490@de.ibm.com \
--to=schwidefsky@de.ibm.com \
--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