From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
john stultz <johnstul@us.ibm.com>,
linux-kernel@vger.kernel.org
Cc: Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 1/3] sched_clock: only update deltas with local reads.
Date: Wed, 09 Jul 2008 00:15:31 -0400 [thread overview]
Message-ID: <20080709041825.202101777@goodmis.org> (raw)
In-Reply-To: 20080709041530.668120406@goodmis.org
[-- Attachment #1: sched_clock-update-only-local-cpu.patch --]
[-- Type: text/plain, Size: 2264 bytes --]
Reading the CPU clock should try to stay accurate within the CPU.
By reading the CPU clock from another CPU and updating the deltas can
cause unneeded jumps when reading from the local CPU.
This patch changes the code to update the last read TSC only when read
from the local CPU.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/sched_clock.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
Index: linux-tip.git/kernel/sched_clock.c
===================================================================
--- linux-tip.git.orig/kernel/sched_clock.c 2008-07-07 19:29:40.000000000 -0400
+++ linux-tip.git/kernel/sched_clock.c 2008-07-08 11:03:05.000000000 -0400
@@ -124,7 +124,7 @@ static int check_max(struct sched_clock_
* - filter out backward motion
* - use jiffies to generate a min,max window to clip the raw values
*/
-static void __update_sched_clock(struct sched_clock_data *scd, u64 now)
+static void __update_sched_clock(struct sched_clock_data *scd, u64 now, u64 *time)
{
unsigned long now_jiffies = jiffies;
long delta_jiffies = now_jiffies - scd->tick_jiffies;
@@ -162,8 +162,12 @@ static void __update_sched_clock(struct
if (unlikely(clock < min_clock))
clock = min_clock;
- scd->prev_raw = now;
- scd->clock = clock;
+ if (time)
+ *time = clock;
+ else {
+ scd->prev_raw = now;
+ scd->clock = clock;
+ }
}
static void lock_double_clock(struct sched_clock_data *data1,
@@ -207,15 +211,18 @@ u64 sched_clock_cpu(int cpu)
now -= scd->tick_gtod;
__raw_spin_unlock(&my_scd->lock);
+
+ __update_sched_clock(scd, now, &clock);
+
+ __raw_spin_unlock(&scd->lock);
+
} else {
__raw_spin_lock(&scd->lock);
+ __update_sched_clock(scd, now, NULL);
+ clock = scd->clock;
+ __raw_spin_unlock(&scd->lock);
}
- __update_sched_clock(scd, now);
- clock = scd->clock;
-
- __raw_spin_unlock(&scd->lock);
-
return clock;
}
@@ -234,7 +241,7 @@ void sched_clock_tick(void)
now_gtod = ktime_to_ns(ktime_get());
__raw_spin_lock(&scd->lock);
- __update_sched_clock(scd, now);
+ __update_sched_clock(scd, now, NULL);
/*
* update tick_gtod after __update_sched_clock() because that will
* already observe 1 new jiffy; adding a new tick_gtod to that would
--
next prev parent reply other threads:[~2008-07-09 4:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-09 4:15 [PATCH 0/3] [PATCH] more sched_clock updates Steven Rostedt
2008-07-09 4:15 ` Steven Rostedt [this message]
2008-07-09 4:15 ` [PATCH 2/3] sched_clock: record TSC after gtod Steven Rostedt
2008-07-09 4:15 ` [PATCH 3/3] sched_clock: and multiplier for TSC to gtod drift Steven Rostedt
2008-07-11 13:56 ` [PATCH 0/3] [PATCH] more sched_clock updates Ingo Molnar
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=20080709041825.202101777@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=srostedt@redhat.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