linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
	linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Carsten Emde <C.Emde@osadl.org>, John Kacur <jkacur@redhat.com>
Subject: [PATCH RT 02/11] Latency histograms: Adjust timer, if already elapsed when programmed
Date: Mon, 16 Jul 2012 14:43:12 -0400	[thread overview]
Message-ID: <20120716184353.853883147@goodmis.org> (raw)
In-Reply-To: 20120716184310.223095720@goodmis.org

[-- Attachment #1: 0002-Latency-histograms-Adjust-timer-if-already-elapsed-w.patch --]
[-- Type: text/plain, Size: 2129 bytes --]

From: Carsten Emde <C.Emde@osadl.org>

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>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/hrtimer.h |    3 +++
 kernel/hrtimer.c        |   16 ++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 0e37086..7408760 100644
--- a/include/linux/hrtimer.h
+++ b/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;
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 3991464..a080e62 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -1021,6 +1021,17 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
 #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,
-- 
1.7.10.4

  parent reply	other threads:[~2012-07-16 18:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-16 18:43 [PATCH RT 00/11] [ANNOUNCE] 3.4.4-rt14-rc1 stable review Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 01/11] Latency histogramms: Cope with backwards running local trace clock Steven Rostedt
2012-07-16 18:43 ` Steven Rostedt [this message]
2012-07-16 18:43 ` [PATCH RT 03/11] Disable RT_GROUP_SCHED in PREEMPT_RT_FULL Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 04/11] Latency histograms: Detect another yet overlooked sharedprio condition Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 05/11] slab: Prevent local lock deadlock Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 06/11] fs, jbd: pull your plug when waiting for space Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 07/11] perf: Make swevent hrtimer run in irq instead of softirq Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 08/11] cpu/rt: Rework cpu down for PREEMPT_RT Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 09/11] workqueue: Revert workqueue: Fix PF_THREAD_BOUND abuse Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 10/11] workqueue: Revert workqueue: Fix cpuhotplug trainwreck Steven Rostedt
2012-07-16 18:43 ` [PATCH RT 11/11] Linux 3.4.4-rt14-rc1 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=20120716184353.853883147@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=C.Emde@osadl.org \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).