From: tip-bot for John Stultz <johnstul@us.ibm.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
a.p.zijlstra@chello.nl, johnstul@us.ibm.com, jengelh@inai.de,
tglx@linutronix.de, prarit@redhat.com
Subject: [tip:timers/urgent] hrtimer: Provide clock_was_set_delayed()
Date: Wed, 11 Jul 2012 14:40:41 -0700 [thread overview]
Message-ID: <tip-f55a6faa384304c89cfef162768e88374d3312cb@git.kernel.org> (raw)
In-Reply-To: <1341960205-56738-2-git-send-email-johnstul@us.ibm.com>
Commit-ID: f55a6faa384304c89cfef162768e88374d3312cb
Gitweb: http://git.kernel.org/tip/f55a6faa384304c89cfef162768e88374d3312cb
Author: John Stultz <johnstul@us.ibm.com>
AuthorDate: Tue, 10 Jul 2012 18:43:19 -0400
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 11 Jul 2012 23:34:37 +0200
hrtimer: Provide clock_was_set_delayed()
clock_was_set() cannot be called from hard interrupt context because
it calls on_each_cpu().
For fixing the widely reported leap seconds issue it is necessary to
call it from hard interrupt context, i.e. the timer tick code, which
does the timekeeping updates.
Provide a new function which denotes it in the hrtimer cpu base
structure of the cpu on which it is called and raise the hrtimer
softirq. We then execute the clock_was_set() notificiation from
softirq context in run_hrtimer_softirq(). The hrtimer softirq is
rarely used, so polling the flag there is not a performance issue.
[ tglx: Made it depend on CONFIG_HIGH_RES_TIMERS. We really should get
rid of all this ifdeffery ASAP ]
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Reported-by: Jan Engelhardt <jengelh@inai.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Prarit Bhargava <prarit@redhat.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1341960205-56738-2-git-send-email-johnstul@us.ibm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/hrtimer.h | 9 ++++++++-
kernel/hrtimer.c | 20 ++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index fd0dc30..c9ec940 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -165,6 +165,7 @@ enum hrtimer_base_type {
* @lock: lock protecting the base and associated clock bases
* and timers
* @active_bases: Bitfield to mark bases with active timers
+ * @clock_was_set: Indicates that clock was set from irq context.
* @expires_next: absolute time of the next event which was scheduled
* via clock_set_next_event()
* @hres_active: State of high resolution mode
@@ -177,7 +178,8 @@ enum hrtimer_base_type {
*/
struct hrtimer_cpu_base {
raw_spinlock_t lock;
- unsigned long active_bases;
+ unsigned int active_bases;
+ unsigned int clock_was_set;
#ifdef CONFIG_HIGH_RES_TIMERS
ktime_t expires_next;
int hres_active;
@@ -286,6 +288,8 @@ extern void hrtimer_peek_ahead_timers(void);
# define MONOTONIC_RES_NSEC HIGH_RES_NSEC
# define KTIME_MONOTONIC_RES KTIME_HIGH_RES
+extern void clock_was_set_delayed(void);
+
#else
# define MONOTONIC_RES_NSEC LOW_RES_NSEC
@@ -306,6 +310,9 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
{
return 0;
}
+
+static inline void clock_was_set_delayed(void) { }
+
#endif
extern void clock_was_set(void);
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index ae34bf5..3c24fb2 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -717,6 +717,19 @@ static int hrtimer_switch_to_hres(void)
return 1;
}
+/*
+ * Called from timekeeping code to reprogramm the hrtimer interrupt
+ * device. If called from the timer interrupt context we defer it to
+ * softirq context.
+ */
+void clock_was_set_delayed(void)
+{
+ struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
+
+ cpu_base->clock_was_set = 1;
+ __raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+}
+
#else
static inline int hrtimer_hres_active(void) { return 0; }
@@ -1395,6 +1408,13 @@ void hrtimer_peek_ahead_timers(void)
static void run_hrtimer_softirq(struct softirq_action *h)
{
+ struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
+
+ if (cpu_base->clock_was_set) {
+ cpu_base->clock_was_set = 0;
+ clock_was_set();
+ }
+
hrtimer_peek_ahead_timers();
}
next prev parent reply other threads:[~2012-07-11 21:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-10 22:43 [PATCH 0/6] Fix for leapsecond caused hrtimer/futex issue (updated) John Stultz
2012-07-10 22:43 ` [PATCH 1/6] hrtimer: Provide clock_was_set_delayed() John Stultz
2012-07-11 12:15 ` Prarit Bhargava
2012-07-11 12:45 ` Thomas Gleixner
2012-07-11 13:05 ` Peter Zijlstra
2012-07-11 15:18 ` Thomas Gleixner
2012-07-11 15:56 ` Peter Zijlstra
2012-07-11 16:47 ` John Stultz
2012-07-12 7:44 ` Jan Ceuleers
2012-07-12 12:29 ` Prarit Bhargava
2012-07-11 13:05 ` Prarit Bhargava
2012-07-11 13:38 ` Peter Zijlstra
2012-07-11 21:40 ` tip-bot for John Stultz [this message]
2012-07-10 22:43 ` [PATCH 2/6] timekeeping: Fix leapsecond triggered load spike issue John Stultz
2012-07-11 21:41 ` [tip:timers/urgent] " tip-bot for John Stultz
2012-07-10 22:43 ` [PATCH 3/6] timekeeping: Maintain ktime_t based offsets for hrtimers John Stultz
2012-07-11 21:42 ` [tip:timers/urgent] " tip-bot for Thomas Gleixner
2012-07-10 22:43 ` [PATCH 4/6] hrtimer: Move lock held region in hrtimer_interrupt() John Stultz
2012-07-10 22:43 ` [PATCH 4/6] hrtimers: " John Stultz
2012-07-11 21:43 ` [tip:timers/urgent] " tip-bot for Thomas Gleixner
2012-07-10 22:43 ` [PATCH 5/6] timekeeping: Provide hrtimer update function John Stultz
2012-07-11 21:44 ` [tip:timers/urgent] " tip-bot for Thomas Gleixner
2012-07-10 22:43 ` [PATCH 6/6] hrtimer: Update hrtimer base offsets each hrtimer_interrupt John Stultz
2012-07-11 21:45 ` [tip:timers/urgent] " tip-bot for John Stultz
2012-07-15 15:22 ` [PATCH 6/6] " Andreas Schwab
2012-07-15 20:28 ` Rafael J. Wysocki
[not found] ` <m2y5mlnj5z.fsf__49536.0585897744$1342365803$gmane$org@igel.home>
2012-07-15 16:02 ` Andreas Schwab
2012-07-10 22:53 ` [PATCH 0/6] Fix for leapsecond caused hrtimer/futex issue (updated) John Stultz
2012-07-12 22:43 ` Jiri Bohac
2012-07-12 23:58 ` John Stultz
2012-07-10 23:00 ` John Stultz
2012-07-13 0:43 ` John Stultz
2012-07-11 10:59 ` Peter Zijlstra
2012-07-11 11:17 ` Ingo Molnar
2012-07-12 12:32 ` Prarit Bhargava
2012-07-11 12:16 ` Prarit Bhargava
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=tip-f55a6faa384304c89cfef162768e88374d3312cb@git.kernel.org \
--to=johnstul@us.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=jengelh@inai.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=prarit@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;
as well as URLs for NNTP newsgroup(s).