From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226vn8XZk3s1uB4K6zjqiz9Ns988E/J9jUBEeu/IecR6XubukpYDGTdeyyUX2wtgZ1HK3AJY ARC-Seal: i=1; a=rsa-sha256; t=1517256383; cv=none; d=google.com; s=arc-20160816; b=IYuXT+OfEuKyJDxmTttX/ryj2ezU83C7cg04j7Fbsp94hNyjIQCr0BX6jL+aTunf9j H5Z37Z1djcqw3eBneyJdncqFv5kkn5WzecBcz2KXLoi7FJAtrA7cd3JiEu/MGciHo0/w JeusaDx3/fTO/K36EVYW70cQugWXhf2mXsmi7b55MzhWL6Twvu3cwR8Vx7V2iiS3RaXx AZjoV/URHdD2/bHQw8XxiHZoo9ti4BfAzq69lQCkdUtlKXylNeQIrNS7Sz8/vlZLmB5I W16y9TjdAYeygq1qBLBWo2k0wpT6k4gWgDK47eejEzD9cU7+ipa9D9CvRoPsxK3uIgTv iAAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=NxVrdJrwDJr91GD5Hs7ibZFUWL0MwydvSnciWWMsMX4=; b=C7VzEiqPSUTmO0yshlxZSXjKldj70FyWvX6adbsfuoRdTngXfROeQ4Yl1NhWYXMJQz Vs2uF9E6ZGq6w07OND+skbgPStdxZRunkixOWdQLVIzxzjFwnJcVfM6Cv1gLnzYfcUoS 4/pz6q0rkmHBJv58bRPsyFKdRNv45nODlNFVlvJ5ff4Z+Eh+fRyfy7YUoTazc3l/FyBg yX7l1+7p+XvuHpwRkwJSIv+w1ri9/Ll48Mwn8z6byY9wKoChNx4Pcsk5E5+FF4+KDXWJ J6EBZdvLRpsEXlFJv5UJUkarSRb+md02lptvYfMxUPUUEkFfBtU5NKHhaUF9TkqNh40Y D/cQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Paul E. McKenney" , Thomas Gleixner , Peter Zijlstra , Sebastian Sewior , Anna-Maria Gleixner Subject: [PATCH 4.14 64/71] hrtimer: Reset hrtimer cpu base proper on CPU hotplug Date: Mon, 29 Jan 2018 13:57:32 +0100 Message-Id: <20180129123831.898060947@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958629354901288?= X-GMAIL-MSGID: =?utf-8?q?1590958629354901288?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit d5421ea43d30701e03cadc56a38854c36a8b4433 upstream. The hrtimer interrupt code contains a hang detection and mitigation mechanism, which prevents that a long delayed hrtimer interrupt causes a continous retriggering of interrupts which prevent the system from making progress. If a hang is detected then the timer hardware is programmed with a certain delay into the future and a flag is set in the hrtimer cpu base which prevents newly enqueued timers from reprogramming the timer hardware prior to the chosen delay. The subsequent hrtimer interrupt after the delay clears the flag and resumes normal operation. If such a hang happens in the last hrtimer interrupt before a CPU is unplugged then the hang_detected flag is set and stays that way when the CPU is plugged in again. At that point the timer hardware is not armed and it cannot be armed because the hang_detected flag is still active, so nothing clears that flag. As a consequence the CPU does not receive hrtimer interrupts and no timers expire on that CPU which results in RCU stalls and other malfunctions. Clear the flag along with some other less critical members of the hrtimer cpu base to ensure starting from a clean state when a CPU is plugged in. Thanks to Paul, Sebastian and Anna-Maria for their help to get down to the root cause of that hard to reproduce heisenbug. Once understood it's trivial and certainly justifies a brown paperbag. Fixes: 41d2e4949377 ("hrtimer: Tune hrtimer_interrupt hang logic") Reported-by: Paul E. McKenney Signed-off-by: Thomas Gleixner Cc: Peter Zijlstra Cc: Sebastian Sewior Cc: Anna-Maria Gleixner Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801261447590.2067@nanos Signed-off-by: Greg Kroah-Hartman --- kernel/time/hrtimer.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -655,7 +655,9 @@ static void hrtimer_reprogram(struct hrt static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base) { base->expires_next = KTIME_MAX; + base->hang_detected = 0; base->hres_active = 0; + base->next_timer = NULL; } /* @@ -1591,6 +1593,7 @@ int hrtimers_prepare_cpu(unsigned int cp timerqueue_init_head(&cpu_base->clock_base[i].active); } + cpu_base->active_bases = 0; cpu_base->cpu = cpu; hrtimer_init_hres(cpu_base); return 0;