Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752631AbbHMJ3k (ORCPT ); Thu, 13 Aug 2015 05:29:40 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33823 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752537AbbHMJ3i (ORCPT ); Thu, 13 Aug 2015 05:29:38 -0400 Date: Thu, 13 Aug 2015 14:59:42 +0530 From: Vatika Harlalka To: mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de, rafael.j.wysocki@intel.com, fweisbec@gmail.com, schwidefsky@de.ibm.com, linux-kernel@vger.kernel.org, preetium@andrew.cmu.edu Subject: [PATCH 2/2] nohz_full: Offload task_tick to remote housekeeping cpu Message-ID: <20150813092942.GA17540@vatika-Inspiron-3443> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3692 Lines: 113 From: Vatika Harlalka To: mingo@redhat.com,peterz@infradead.org, tglx@linutronix.de, rafael.j.wysocki@intel.com, fweisbec@gmail.com,schwidefsky@de.ibm.com,linux-kernel@vger.kernel.org, mingo@redhat.com,peterz@infradead.org, preetium@andrew.cmu.edu Cc: preeti.murthy@gmail.com Bcc: Subject: [PATCH 2/2] nohz_full: Offload task_tick to remote housekeeping cpu Message-ID: <6c49894de23f55e72990eefbf48a1fc237168f13.1439454836.git.vatikaharlalka@gmail.com> Reply-To: In-Reply-To: Offload task_tick to remote housekeeping cpus for nohz_full cpus on which ticks are stopped. Signed-off-by: Vatika Harlalka --- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/