From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161069AbcIGKvV (ORCPT ); Wed, 7 Sep 2016 06:51:21 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:34901 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933190AbcIGKvT (ORCPT ); Wed, 7 Sep 2016 06:51:19 -0400 From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org Cc: Wanpeng Li , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Frederic Weisbecker Subject: [PATCH] tick/nohz: Fix the intention to stop full tick for offline CPU Date: Wed, 7 Sep 2016 18:51:13 +0800 Message-Id: <1473245473-4463-1-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li Interrupt exit is the place to stop the tick: it happens after all events happening before and during the irq which are liable to update the dependency on the tick occurred. However, tick_nohz_stop_sched_tick() try to stop the full tick instead of bailing out in advance. As a result: WARNING: CPU: 3 PID: 31 at kernel/irq_work.c:124 irq_work_needs_cpu+0x86/0x90 CPU: 3 PID: 31 Comm: migration/3 Not tainted 4.8.0-rc5+ #46 Call Trace: [] dump_stack+0x99/0xd0 [] __warn+0xd1/0xf0 [] warn_slowpath_null+0x1d/0x20 [] irq_work_needs_cpu+0x86/0x90 [] tick_nohz_stop_sched_tick+0x2ad/0x430 [] ? tick_nohz_irq_exit+0x10e/0x150 [] ? kvm_clock_read+0x25/0x30 [] tick_nohz_irq_exit+0x10e/0x150 [] irq_exit+0x81/0xf0 [] do_IRQ+0x6c/0x120 [] common_interrupt+0x96/0x96 [] ? multi_cpu_stop+0xa2/0x160 [] ? cpu_stop_park+0x40/0x40 [] cpu_stopper_thread+0x74/0x100 [] smpboot_thread_fn+0x117/0x1d0 [] ? sort_range+0x30/0x30 [] kthread+0x101/0x120 [] ? complete+0x1d/0x50 [] ret_from_fork+0x1f/0x40 [] ? kthread_create_on_node+0x250/0x250 Commit f7ea0fd639c2c4 (tick: Don't invoke tick_nohz_stop_sched_tick() if the cpu is offline) fixes stop idle tick for offline cpu, this patch adds the similar method to fix the intention to stop full tick for offline cpu. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Frederic Weisbecker Signed-off-by: Wanpeng Li --- kernel/time/tick-sched.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 2ec7c00..3bcb61b 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -186,10 +186,13 @@ static bool check_tick_dependency(atomic_t *dep) return false; } -static bool can_stop_full_tick(struct tick_sched *ts) +static bool can_stop_full_tick(int cpu, struct tick_sched *ts) { WARN_ON_ONCE(!irqs_disabled()); + if (unlikely(!cpu_online(cpu))) + return false; + if (check_tick_dependency(&tick_dep_mask)) return false; @@ -843,7 +846,7 @@ static void tick_nohz_full_update_tick(struct tick_sched *ts) if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE) return; - if (can_stop_full_tick(ts)) + if (can_stop_full_tick(cpu, ts)) tick_nohz_stop_sched_tick(ts, ktime_get(), cpu); else if (ts->tick_stopped) tick_nohz_restart_sched_tick(ts, ktime_get()); -- 1.9.1