[PATCH 2/2] nohz_full: Offload task_tick to remote housekeeping cpu
From: Vatika Harlalka
Date: Thu Aug 13 2015 - 05:29:43 EST
From: Vatika Harlalka <vatikaharlalka@xxxxxxxxx>
To: mingo@xxxxxxxxxx,peterz@xxxxxxxxxxxxx, tglx@xxxxxxxxxxxxx, rafael.j.wysocki@xxxxxxxxx, fweisbec@xxxxxxxxx,schwidefsky@xxxxxxxxxx,linux-kernel@xxxxxxxxxxxxxxx, mingo@xxxxxxxxxx,peterz@xxxxxxxxxxxxx, preetium@xxxxxxxxxxxxxx
Cc: preeti.murthy@xxxxxxxxx
Bcc:
Subject: [PATCH 2/2] nohz_full: Offload task_tick to remote housekeeping cpu
Message-ID: <6c49894de23f55e72990eefbf48a1fc237168f13.1439454836.git.vatikaharlalka@xxxxxxxxx>
Reply-To:
In-Reply-To: <cover.1439454836.git.vatikaharlalka@xxxxxxxxx>
Offload task_tick to remote housekeeping cpus for nohz_full cpus on which
ticks are stopped.
Signed-off-by: Vatika Harlalka <vatikaharlalka@xxxxxxxxx>
---
include/linux/tick.h | 2 ++
kernel/sched/tick.c | 42 ++++++++++++++++++++++++++++++++++++++++++
kernel/time/tick-sched.c | 5 +++++
3 files changed, 49 insertions(+)
diff --git a/include/linux/tick.h b/include/linux/tick.h
index f8492da5..42faf5f 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -92,6 +92,7 @@ static inline void tick_broadcast_exit(void)
#ifdef CONFIG_NO_HZ_COMMON
extern int tick_nohz_tick_stopped(void);
+extern int tick_nohz_remote_tick_stopped(int cpu);
extern void tick_nohz_idle_enter(void);
extern void tick_nohz_idle_exit(void);
extern void tick_nohz_irq_exit(void);
@@ -100,6 +101,7 @@ extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time);
extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time);
#else /* !CONFIG_NO_HZ_COMMON */
static inline int tick_nohz_tick_stopped(void) { return 0; }
+static inline int tick_nohz_remote_tick_stopped(int cpu) { return 0; }
static inline void tick_nohz_idle_enter(void) { }
static inline void tick_nohz_idle_exit(void) { }
diff --git a/kernel/sched/tick.c b/kernel/sched/tick.c
index 3bc32c7..f2b1f9f 100644
--- a/kernel/sched/tick.c
+++ b/kernel/sched/tick.c
@@ -41,3 +41,45 @@ void scheduler_tick(void)
rq_last_tick_reset(rq);
}
+#ifdef CONFIG_NO_HZ_FULL
+
+static struct delayed_work work;
+
+/*
+ * Offload task_tick() to remote housekeeping cpus for
+ * nohz_full cpus. This is in the direction of stopping
+ * ticks on nohz_full cpus altogether.
+ */
+
+static void remote_task_tick(struct work_struct *dwork)
+{
+ int cpu;
+
+ get_online_cpus();
+ for_each_cpu_and(cpu, tick_nohz_full_mask, cpu_online_mask) {
+ struct rq *rq = cpu_rq(cpu);
+ unsigned long flags;
+ struct task_struct *curr;
+
+ raw_spin_lock_irqsave(&rq->lock, flags);
+ curr = rq->curr;
+
+ if (tick_nohz_remote_tick_stopped(cpu) && !is_idle_task(curr))
+ curr->sched_class->task_tick(rq, curr, 0);
+
+ raw_spin_unlock_irqrestore(&rq->lock, flags);
+ }
+ put_online_cpus();
+ schedule_delayed_work(&work, HZ);
+}
+static int __init queue_remote_task_tick(void)
+{
+ if (tick_nohz_full_running) {
+ INIT_DELAYED_WORK(&work, remote_task_tick);
+ schedule_delayed_work(&work, HZ);
+ }
+ return 0;
+}
+core_initcall(queue_remote_task_tick);
+#endif
+
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 9142591..5de79b3 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -421,6 +421,11 @@ int tick_nohz_tick_stopped(void)
return __this_cpu_read(tick_cpu_sched.tick_stopped);
}
+int tick_nohz_remote_tick_stopped(int cpu)
+{
+ return per_cpu(tick_cpu_sched, cpu).tick_stopped;
+}
+
/**
* tick_nohz_update_jiffies - update jiffies when idle was interrupted
*
--
2.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/