From: tip-bot for Viresh Kumar <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
fweisbec@gmail.com, viresh.kumar@linaro.org, tglx@linutronix.de
Subject: [tip:timers/core] timer: Kick dynticks targets on mod_timer*() calls
Date: Mon, 23 Jun 2014 02:34:01 -0700 [thread overview]
Message-ID: <tip-9f6d9baaa8ca94b48aea495261cadaf2967c7784@git.kernel.org> (raw)
In-Reply-To: <1403393357-2070-3-git-send-email-fweisbec@gmail.com>
Commit-ID: 9f6d9baaa8ca94b48aea495261cadaf2967c7784
Gitweb: http://git.kernel.org/tip/9f6d9baaa8ca94b48aea495261cadaf2967c7784
Author: Viresh Kumar <viresh.kumar@linaro.org>
AuthorDate: Sun, 22 Jun 2014 01:29:14 +0200
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 23 Jun 2014 11:23:47 +0200
timer: Kick dynticks targets on mod_timer*() calls
When a timer is enqueued or modified on a dynticks target, that CPU
must re-evaluate the next tick to service that timer.
The tick re-evaluation is performed by an IPI kick on the target.
Now while we correctly call wake_up_nohz_cpu() from add_timer_on(), the
mod_timer*() API family doesn't support so well dynticks targets.
The reason for this is likely that __mod_timer() isn't supposed to
select an idle target for a timer, unless that target is the current
CPU, in which case a dynticks idle kick isn't actually needed.
But there is a small race window lurking behind that assumption: the
elected target has all the time to turn dynticks idle between the call
to get_nohz_timer_target() and the locking of its base. Hence a risk
that we enqueue a timer on a dynticks idle destination without kicking
it. As a result, the timer might be serviced too late in the future.
Also a target elected by __mod_timer() can be in full dynticks mode
and thus require to be kicked as well. And unlike idle dynticks, this
concern both local and remote targets.
To fix this whole issue, lets centralize the dynticks kick to
internal_add_timer() so that it is well handled for all sort of timer
enqueue. Even timer migration is concerned so that a full dynticks target
is correctly kicked as needed when timers are migrating to it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1403393357-2070-3-git-send-email-fweisbec@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/time/timer.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 9e5f4f2..aca5dfe 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -410,6 +410,22 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
base->next_timer = timer->expires;
}
base->all_timers++;
+
+ /*
+ * Check whether the other CPU is in dynticks mode and needs
+ * to be triggered to reevaluate the timer wheel.
+ * We are protected against the other CPU fiddling
+ * with the timer by holding the timer base lock. This also
+ * makes sure that a CPU on the way to stop its tick can not
+ * evaluate the timer wheel.
+ *
+ * Spare the IPI for deferrable timers on idle targets though.
+ * The next busy ticks will take care of it. Except full dynticks
+ * require special care against races with idle_cpu(), lets deal
+ * with that later.
+ */
+ if (!tbase_get_deferrable(base) || tick_nohz_full_cpu(base->cpu))
+ wake_up_nohz_cpu(base->cpu);
}
#ifdef CONFIG_TIMER_STATS
@@ -949,22 +965,6 @@ void add_timer_on(struct timer_list *timer, int cpu)
timer_set_base(timer, base);
debug_activate(timer, timer->expires);
internal_add_timer(base, timer);
- /*
- * Check whether the other CPU is in dynticks mode and needs
- * to be triggered to reevaluate the timer wheel.
- * We are protected against the other CPU fiddling
- * with the timer by holding the timer base lock. This also
- * makes sure that a CPU on the way to stop its tick can not
- * evaluate the timer wheel.
- *
- * Spare the IPI for deferrable timers on idle targets though.
- * The next busy ticks will take care of it. Except full dynticks
- * require special care against races with idle_cpu(), lets deal
- * with that later.
- */
- if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(cpu))
- wake_up_nohz_cpu(cpu);
-
spin_unlock_irqrestore(&base->lock, flags);
}
EXPORT_SYMBOL_GPL(add_timer_on);
next prev parent reply other threads:[~2014-06-23 9:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-21 23:29 [PATCH 0/5] timer: Fix missing dynticks kick v2 Frederic Weisbecker
2014-06-21 23:29 ` [PATCH 1/5] timer: Store cpu-number in 'struct tvec_base' Frederic Weisbecker
2014-06-23 9:33 ` [tip:timers/core] timer: Store cpu-number in struct tvec_base tip-bot for Viresh Kumar
2014-06-21 23:29 ` [PATCH 2/5] timer: Kick dynticks targets on mod_timer*() calls Frederic Weisbecker
2014-06-23 9:34 ` tip-bot for Viresh Kumar [this message]
2014-06-21 23:29 ` [PATCH 3/5] hrtimer: Store cpu-number in 'struct hrtimer_cpu_base' Frederic Weisbecker
2014-06-23 9:34 ` [tip:timers/core] hrtimer: Store cpu-number in struct hrtimer_cpu_base tip-bot for Viresh Kumar
2014-06-21 23:29 ` [PATCH 4/5] hrtimer: Kick lowres dynticks targets on timer enqueue Frederic Weisbecker
2014-06-22 13:36 ` Thomas Gleixner
2014-06-23 4:44 ` Viresh Kumar
2014-06-23 8:09 ` [PATCH V2 " Viresh Kumar
2014-06-23 9:34 ` [tip:timers/core] " tip-bot for Viresh Kumar
2014-06-21 23:29 ` [PATCH 5/5] hrtimer: Remove hrtimer_enqueue_reprogram() Frederic Weisbecker
2014-06-23 9:34 ` [tip:timers/core] " tip-bot for Viresh Kumar
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-9f6d9baaa8ca94b48aea495261cadaf2967c7784@git.kernel.org \
--to=tipbot@zytor.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=viresh.kumar@linaro.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