From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
RT-users <linux-rt-users@vger.kernel.org>,
Carsten Emde <cbe@osadl.org>
Subject: [patch RT 2/7] Latency histograms: Adjust timer, if already elapsed when programmed
Date: Wed, 11 Jul 2012 22:05:18 -0000 [thread overview]
Message-ID: <20120711215611.727482885@linutronix.de> (raw)
In-Reply-To: 20120711214552.036760674@linutronix.de
[-- Attachment #1: latency-histograms-adjust-timer-if-already-elapsed-when-programmed.patch --]
[-- Type: text/plain, Size: 2150 bytes --]
Nothing prevents a programmer from calling clock_nanosleep() with an
already elapsed wakeup time in absolute time mode or with a too small
delay in relative time mode. Such timers cannot wake up in time and,
thus, should be corrected when entered into the missed timers latency
histogram (CONFIG_MISSED_TIMERS_HIST).
This patch marks such timers and uses a corrected expiration time.
Signed-off-by: Carsten Emde <C.Emde@osadl.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/hrtimer.h | 3 +++
kernel/hrtimer.c | 16 ++++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
Index: linux-3.4.2-rt10-64+/include/linux/hrtimer.h
===================================================================
--- linux-3.4.2-rt10-64+.orig/include/linux/hrtimer.h
+++ linux-3.4.2-rt10-64+/include/linux/hrtimer.h
@@ -113,6 +113,9 @@ struct hrtimer {
unsigned long state;
struct list_head cb_entry;
int irqsafe;
+#ifdef CONFIG_MISSED_TIMER_OFFSETS_HIST
+ ktime_t praecox;
+#endif
#ifdef CONFIG_TIMER_STATS
int start_pid;
void *start_site;
Index: linux-3.4.2-rt10-64+/kernel/hrtimer.c
===================================================================
--- linux-3.4.2-rt10-64+.orig/kernel/hrtimer.c
+++ linux-3.4.2-rt10-64+/kernel/hrtimer.c
@@ -1021,6 +1021,17 @@ int __hrtimer_start_range_ns(struct hrti
#endif
}
+#ifdef CONFIG_MISSED_TIMER_OFFSETS_HIST
+ {
+ ktime_t now = new_base->get_time();
+
+ if (ktime_to_ns(tim) < ktime_to_ns(now))
+ timer->praecox = now;
+ else
+ timer->praecox = ktime_set(0, 0);
+ }
+#endif
+
hrtimer_set_expires_range_ns(timer, tim, delta_ns);
timer_stats_hrtimer_set_start_info(timer);
@@ -1458,8 +1469,9 @@ retry:
timer = container_of(node, struct hrtimer, node);
trace_hrtimer_interrupt(raw_smp_processor_id(),
- ktime_to_ns(ktime_sub(
- hrtimer_get_expires(timer), basenow)),
+ ktime_to_ns(ktime_sub(ktime_to_ns(timer->praecox) ?
+ timer->praecox : hrtimer_get_expires(timer),
+ basenow)),
current,
timer->function == hrtimer_wakeup ?
container_of(timer, struct hrtimer_sleeper,
next prev parent reply other threads:[~2012-07-11 22:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 22:05 [patch RT 0/7] Various fixes for the stable RT series - part I Thomas Gleixner
2012-07-11 22:05 ` [patch RT 1/7] Latency histogramms: Cope with backwards running local trace clock Thomas Gleixner
2012-07-11 22:05 ` [patch RT 3/7] Disable RT_GROUP_SCHED in PREEMPT_RT_FULL Thomas Gleixner
2012-07-12 2:36 ` Mike Galbraith
2012-07-11 22:05 ` Thomas Gleixner [this message]
2012-07-11 22:05 ` [patch RT 5/7] slab: Prevent local lock deadlock Thomas Gleixner
2012-07-11 22:05 ` [patch RT 4/7] Latency histograms: Detect another yet overlooked sharedprio condition Thomas Gleixner
2012-07-11 22:05 ` [patch RT 6/7] fs, jbd: pull your plug when waiting for space Thomas Gleixner
2012-07-11 22:05 ` [patch RT 7/7] perf: Make swevent hrtimer run in irq instead of softirq Thomas Gleixner
2012-07-11 23:31 ` [patch RT 0/7] Various fixes for the stable RT series - part I Steven Rostedt
2012-07-12 8:49 ` 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=20120711215611.727482885@linutronix.de \
--to=tglx@linutronix.de \
--cc=cbe@osadl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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;
as well as URLs for NNTP newsgroup(s).