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>,
linux-kernel@vger.kernel.org
Cc: Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 1/3] sched_clock: record from last tick
Date: Mon, 07 Jul 2008 14:16:50 -0400 [thread overview]
Message-ID: <20080707182104.030313295@goodmis.org> (raw)
In-Reply-To: 20080707181649.942597764@goodmis.org
[-- Attachment #1: sched-clock-tick-jiffies.patch --]
[-- Type: text/plain, Size: 2626 bytes --]
The sched_clock code tries to keep within the gtod time by one tick (jiffy).
The current code mistakenly keeps track of the delta jiffies between
updates of the clock, where the the delta is used to compare with the
number of jiffies that have past since an update of the gtod. The gtod is
updated at each schedule tick not each sched_clock update. After one
jiffy passes the clock is updated fine. But the delta is taken from the
last update so if the next update happens before the next tick the delta
jiffies used will be incorrect.
This patch changes the code to check the delta of jiffies between ticks
and not updates to match the comparison of the updates with the gtod.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/sched_clock.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Index: linux-tip.git/kernel/sched_clock.c
===================================================================
--- linux-tip.git.orig/kernel/sched_clock.c 2008-07-06 01:24:43.000000000 -0400
+++ linux-tip.git/kernel/sched_clock.c 2008-07-06 22:35:35.000000000 -0400
@@ -40,7 +40,7 @@ struct sched_clock_data {
*/
raw_spinlock_t lock;
- unsigned long prev_jiffies;
+ unsigned long tick_jiffies;
u64 prev_raw;
u64 tick_raw;
u64 tick_gtod;
@@ -71,7 +71,7 @@ void sched_clock_init(void)
struct sched_clock_data *scd = cpu_sdc(cpu);
scd->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
- scd->prev_jiffies = now_jiffies;
+ scd->tick_jiffies = now_jiffies;
scd->prev_raw = 0;
scd->tick_raw = 0;
scd->tick_gtod = ktime_now;
@@ -90,7 +90,7 @@ void sched_clock_init(void)
static void __update_sched_clock(struct sched_clock_data *scd, u64 now)
{
unsigned long now_jiffies = jiffies;
- long delta_jiffies = now_jiffies - scd->prev_jiffies;
+ long delta_jiffies = now_jiffies - scd->tick_jiffies;
u64 clock = scd->clock;
u64 min_clock, max_clock;
s64 delta = now - scd->prev_raw;
@@ -119,7 +119,6 @@ static void __update_sched_clock(struct
clock = min_clock;
scd->prev_raw = now;
- scd->prev_jiffies = now_jiffies;
scd->clock = clock;
}
@@ -179,6 +178,7 @@ u64 sched_clock_cpu(int cpu)
void sched_clock_tick(void)
{
struct sched_clock_data *scd = this_scd();
+ unsigned long now_jiffies = jiffies;
u64 now, now_gtod;
if (unlikely(!sched_clock_running))
@@ -196,6 +196,7 @@ void sched_clock_tick(void)
* already observe 1 new jiffy; adding a new tick_gtod to that would
* increase the clock 2 jiffies.
*/
+ scd->tick_jiffies = now_jiffies;
scd->tick_raw = now;
scd->tick_gtod = now_gtod;
__raw_spin_unlock(&scd->lock);
--
next prev parent reply other threads:[~2008-07-07 18:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-07 18:16 [PATCH 0/3] sched_clock updates Steven Rostedt
2008-07-07 18:16 ` Steven Rostedt [this message]
2008-07-07 18:16 ` [PATCH 2/3] sched_clock: widen the max and min time Steven Rostedt
2008-07-07 18:16 ` [PATCH 3/3] sched_clock: stop maximum check on NO HZ Steven Rostedt
2008-07-16 11:14 ` Peter Zijlstra
2008-07-16 11:41 ` Steven Rostedt
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=20080707182104.030313295@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.