From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752855AbdICCsX convert rfc822-to-8bit (ORCPT ); Sat, 2 Sep 2017 22:48:23 -0400 Received: from mout.gmx.net ([212.227.17.21]:49817 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752817AbdICCsW (ORCPT ); Sat, 2 Sep 2017 22:48:22 -0400 Message-ID: <1504406890.3054.3.camel@gmx.de> Subject: Re: v4.11.12-rt10 - hotplug lockdep splat From: Mike Galbraith To: Sebastian Andrzej Siewior Cc: Thomas Gleixner , LKML , linux-rt-users , Steven Rostedt Date: Sun, 03 Sep 2017 04:48:10 +0200 In-Reply-To: <20170831161834.t7ymwsnpbko6und5@linutronix.de> References: <20170818120939.b2rj2whb2hgfzjpm@linutronix.de> <1503482024.4970.5.camel@gmx.de> <20170831161834.t7ymwsnpbko6und5@linutronix.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 Mime-Version: 1.0 Content-Transfer-Encoding: 8BIT X-Provags-ID: V03:K0:vO83vJeVeGIi9b0U+o7MpCyUc2JljZ8EryXi4ZLuDMyXHRgnut2 pzBu9WTRdvc19mzrwiKveoLnMwnRDzfCOWrqsltkPCjp9lXCj8FFdB51hvw/UTGB5pC1JW1 QU9vNlPVp6G+gsqje8DK+IP3rHeY72cCVIL222TtrArbLmT84nJtxIvX7hFeQBFky1+5DJk 5t9H3Dt4um9r9rYAKsh1Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:hHDkGRu3+Gs=:vr/yb5y7XzDzY87yTNFHrd Jm4vfkiwJUvhS1CuJ/1C6G1uDFTfCoGDm09e5fgtwitBfosSTYrsdHyWCRYMg3iiYysoInVix 5mDFtlXIhxRAlKGZhKQXFOU/xVnAKs70SLQ0b3yXxrmmJPtNyI00AVwwR5i+10+co2VgCwIOY VlkUO9FdsHQhl9WhGd8UaEC5dP/03JLeQHpLCRGLHW1R8uRGHUlsQ4POk6waSV61i6LIWpGV9 3eXaMpkkGiNb7Pzwd5OfLlDgXrzHik/9lfYAhLPsyBsQZ6Hd223yfGj0ECIbT7KA3s5cZUTue SC/lgSGX1u1h7lrpV7VWaWRaxExzhapfS5zIe99zG8khHu763Ye48unV3cKzyf/rinCrUQDKS 0ttGb1qR9RS5rNpa5CB44GyHJSYLkIntmK+f2p7EUJbJB1OHefolV0Xgndli3llBAusBcUS6O LFfLGuG0GJVBWAMGejmEn/8w7lolj1S23+urnb0Ax7xSRLCJLTFpVBh7LuDgp8Mn6HEAJaqVx 2uzUamYN3Icz87AvV8mq5dAoIJL4/w5qH+CtEX6NuTJFyyDh/h8ycsRl4hgiMCls0C1O5go+C 7SolQoDUSh9siFhdRv0HzL/AqsrE+R9nDM+sU4BbyLLILW9q7KvpcQpwJFG3IkZ9MXB/DxjNr EiS1LDiQOI6CL3JW/oXIk2pIuPwVeKPk5/US4h8zK8l1sOLL0iwjFn3nWMxaHSGX2jc0DTw/d CdBBrVIWVNZIoAPCMcxZAqQ0Y9XCzFlNOj0ToYQMT/pZ4KP40j0ZBNkoPfrAKQNpVO5jU4B2E iIu6pljVuugvBGIlorhNEHxCwv+eGjYl6oardoyviNs29l83V0= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2017-08-31 at 18:18 +0200, Sebastian Andrzej Siewior wrote: > On 2017-08-23 11:53:44 [+0200], Mike Galbraith wrote: > > virt box reminded me this morning to report this gripe. > > if you can reproduce it, then this should make it go away: Missed a spot.  With this on top, lockdep went silent. kernel/hrtimer/hotplug: don't wake ktimersoftd while holding the hrtimer base lock 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 --- kernel/time/hrtimer.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1779,7 +1779,7 @@ int hrtimers_prepare_cpu(unsigned int cp #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; @@ -1809,15 +1809,19 @@ static void migrate_hrtimer_list(struct } #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); @@ -1833,13 +1837,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();