From: Viresh Kumar <viresh.kumar@linaro.org>
To: tglx@linutronix.de, fweisbec@gmail.com, peterz@infradead.org,
mingo@kernel.org, tj@kernel.org, lizefan@huawei.com
Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, Viresh Kumar <viresh.kumar@linaro.org>
Subject: [RFC 3/4] timer: create timer_quiesce_cpu() for cpusets.quiesce option
Date: Thu, 20 Mar 2014 19:19:00 +0530 [thread overview]
Message-ID: <f4089caeaef95cde80bbbf3afdb36dcd5122c558.1395322529.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1395322529.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1395322529.git.viresh.kumar@linaro.org>
Cpusets would be using timer migration code to isolate/quiese a CPU. And hence
that should be changed a bit as the CPU in question would be online now. Also we
need to make sure that we don't remove pinned timers.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
kernel/timer.c | 54 +++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 43 insertions(+), 11 deletions(-)
diff --git a/kernel/timer.c b/kernel/timer.c
index a7f8b99..81d64e0 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1602,18 +1602,27 @@ static int init_timers_cpu(int cpu)
return 0;
}
-#ifdef CONFIG_HOTPLUG_CPU
-static void migrate_timer_list(struct tvec_base *new_base, struct list_head *head)
+#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_CPUSETS)
+static void migrate_timer_list(struct tvec_base *new_base,
+ struct list_head *head, bool remove_pinned)
{
struct timer_list *timer;
+ struct list_head pinned_list;
int is_pinned;
+ INIT_LIST_HEAD(&pinned_list);
+
while (!list_empty(head)) {
timer = list_first_entry(head, struct timer_list, entry);
- /* We ignore the accounting on the dying cpu */
- detach_timer(timer, false);
is_pinned = tbase_get_pinned(timer->base);
+ if (!remove_pinned && is_pinned) {
+ list_move_tail(&timer->entry, &pinned_list);
+ continue;
+ } else {
+ /* We ignore the accounting on the dying cpu */
+ detach_timer(timer, false);
+ }
/* Check if CPU still has pinned timers */
if (is_pinned) {
@@ -1625,15 +1634,18 @@ static void migrate_timer_list(struct tvec_base *new_base, struct list_head *hea
timer_set_base(timer, new_base);
internal_add_timer(new_base, timer);
}
+
+ if (!list_empty(&pinned_list))
+ list_splice_tail(&pinned_list, head);
}
-static void migrate_timers(int cpu)
+/* Migrate timers from 'cpu' to this_cpu */
+static void __migrate_timers(int cpu, bool remove_pinned)
{
struct tvec_base *old_base;
struct tvec_base *new_base;
int i;
- BUG_ON(cpu_online(cpu));
old_base = per_cpu(tvec_bases, cpu);
new_base = get_cpu_var(tvec_bases);
/*
@@ -1646,20 +1658,40 @@ static void migrate_timers(int cpu)
BUG_ON(old_base->running_timer);
for (i = 0; i < TVR_SIZE; i++)
- migrate_timer_list(new_base, old_base->tv1.vec + i);
+ migrate_timer_list(new_base, old_base->tv1.vec + i,
+ remove_pinned);
for (i = 0; i < TVN_SIZE; i++) {
- migrate_timer_list(new_base, old_base->tv2.vec + i);
- migrate_timer_list(new_base, old_base->tv3.vec + i);
- migrate_timer_list(new_base, old_base->tv4.vec + i);
- migrate_timer_list(new_base, old_base->tv5.vec + i);
+ migrate_timer_list(new_base, old_base->tv2.vec + i,
+ remove_pinned);
+ migrate_timer_list(new_base, old_base->tv3.vec + i,
+ remove_pinned);
+ migrate_timer_list(new_base, old_base->tv4.vec + i,
+ remove_pinned);
+ migrate_timer_list(new_base, old_base->tv5.vec + i,
+ remove_pinned);
}
spin_unlock(&old_base->lock);
spin_unlock_irq(&new_base->lock);
put_cpu_var(tvec_bases);
}
+#endif /* CONFIG_HOTPLUG_CPU || CONFIG_CPUSETS */
+
+#ifdef CONFIG_HOTPLUG_CPU
+static void migrate_timers(int cpu)
+{
+ BUG_ON(cpu_online(cpu));
+ __migrate_timers(cpu, true);
+}
#endif /* CONFIG_HOTPLUG_CPU */
+#ifdef CONFIG_CPUSETS
+void timer_quiesce_cpu(void *data)
+{
+ __migrate_timers((int)data, false);
+}
+#endif /* CONFIG_CPUSETS */
+
static int timer_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
{
--
1.7.12.rc2.18.g61b472e
next prev parent reply other threads:[~2014-03-20 13:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-20 13:48 [RFC 0/4] Migrate timers away from cpuset on setting cpuset.quiesce Viresh Kumar
2014-03-20 13:48 ` [RFC 1/4] timer: track pinned timers with TIMER_PINNED flag Viresh Kumar
2014-03-20 13:48 ` [RFC 2/4] timer: don't migrate pinned timers Viresh Kumar
2014-03-31 15:56 ` Kevin Hilman
2014-04-01 4:32 ` Viresh Kumar
2014-04-04 15:15 ` Kevin Hilman
2014-03-20 13:49 ` Viresh Kumar [this message]
2014-03-20 13:49 ` [RFC 4/4] cpuset: Add cpusets.quiesce option Viresh Kumar
2014-03-27 2:47 ` Li Zefan
2014-03-27 4:29 ` Viresh Kumar
2014-04-24 7:25 ` [RFC 0/4] Migrate timers away from cpuset on setting cpuset.quiesce Daniel Sangorrin
2014-04-24 7:43 ` Viresh Kumar
2014-04-24 8:31 ` Daniel Sangorrin
2014-04-24 8:41 ` Viresh Kumar
2014-04-24 9:24 ` Daniel Sangorrin
2014-04-24 9:30 ` Viresh Kumar
2014-04-25 0:31 ` Daniel Sangorrin
2014-04-25 4:51 ` Viresh Kumar
2014-04-25 5:21 ` Daniel Sangorrin
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=f4089caeaef95cde80bbbf3afdb36dcd5122c558.1395322529.git.viresh.kumar@linaro.org \
--to=viresh.kumar@linaro.org \
--cc=cgroups@vger.kernel.org \
--cc=fweisbec@gmail.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.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
all inboxes | Powered by JetHome®