From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752495AbdLBAEq (ORCPT ); Fri, 1 Dec 2017 19:04:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:44290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752072AbdLBAE3 (ORCPT ); Fri, 1 Dec 2017 19:04:29 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04F3E219AA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Message-Id: <20171202000428.043767679@goodmis.org> User-Agent: quilt/0.63-1 Date: Fri, 01 Dec 2017 19:01:58 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-rt-users Cc: Thomas Gleixner , Carsten Emde , Sebastian Andrzej Siewior , John Kacur , Paul Gortmaker , Julia Cartwright , Daniel Wagner , tom.zanussi@linux.intel.com, Alex Shi , Mike Galbraith Subject: [PATCH RT 09/15] kernel/hrtimer/hotplug: dont wake ktimersoftd while holding the hrtimer base lock References: <20171202000149.842718953@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0009-kernel-hrtimer-hotplug-don-t-wake-ktimersoftd-while-.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9.65-rt57-rc2 stable review patch. If anyone has any objections, please let me know. ------------------ From: Mike Galbraith kernel/hrtimer: don't wakeup a process while holding the hrtimer base lock missed a path, namely hrtimers_dead_cpu() -> migrate_hrtimer_list(). Defer raising softirq until after base lock has been released there as well. Signed-off-by: Mike Galbraith Signed-off-by: Sebastian Andrzej Siewior --- kernel/time/hrtimer.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 8a20ef6919d9..369203af6406 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1837,7 +1837,7 @@ int hrtimers_prepare_cpu(unsigned int cpu) #ifdef CONFIG_HOTPLUG_CPU -static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base, +static int migrate_hrtimer_list(struct hrtimer_clock_base *old_base, struct hrtimer_clock_base *new_base) { struct hrtimer *timer; @@ -1867,15 +1867,19 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base, } #ifdef CONFIG_PREEMPT_RT_BASE list_splice_tail(&old_base->expired, &new_base->expired); - if (!list_empty(&new_base->expired)) - raise_softirq_irqoff(HRTIMER_SOFTIRQ); + /* + * Tell the caller to raise HRTIMER_SOFTIRQ. We can't safely + * acquire ktimersoftd->pi_lock while the base lock is held. + */ + return !list_empty(&new_base->expired); #endif + return 0; } int hrtimers_dead_cpu(unsigned int scpu) { struct hrtimer_cpu_base *old_base, *new_base; - int i; + int i, raise = 0; BUG_ON(cpu_online(scpu)); tick_cancel_sched_timer(scpu); @@ -1891,13 +1895,16 @@ int hrtimers_dead_cpu(unsigned int scpu) raw_spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) { - migrate_hrtimer_list(&old_base->clock_base[i], - &new_base->clock_base[i]); + raise |= migrate_hrtimer_list(&old_base->clock_base[i], + &new_base->clock_base[i]); } raw_spin_unlock(&old_base->lock); raw_spin_unlock(&new_base->lock); + if (raise) + raise_softirq_irqoff(HRTIMER_SOFTIRQ); + /* Check, if we got expired work to do */ __hrtimer_peek_ahead_timers(); local_irq_enable(); -- 2.13.2