From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225C3G9zAxmXkgEC3zHm+LqYfsdJJ2IR2aJObkq3IjNbFrxhVlM9hnRTiPIs70l25NY8VDVA ARC-Seal: i=1; a=rsa-sha256; t=1517256850; cv=none; d=google.com; s=arc-20160816; b=DtlzXSQn9KzJf2h4aMFYqxYcrSGbx5BKjduPQoT3rGENPuqn2FzK4n3MduQRUrEBoc d6n0mo/u0DbEDBW5txS2LT68NXWug5qxdg5jYdyN9+eyzSZ/RQuuEMdoNl2k6Cn/9elO Ty7M2lJpRCS67Y7QreZChQ3QqFlcNRFSrRwb3k4P1TCxQYYCXzLopRUDQmtcT3mvt853 HYERlBMyi4tgw6hqKo2glKtDLLwljZTHLYwX7wr+DJQABNwLv19Gv5To8Li4PtR3VHtQ ti1QHzHeZmqBaOj9A/k0IZCAFOVlNv2KCmx/6zIzTWMoJKdohCKD5784xRtN3r+0Fd5+ JEtw== 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=NVI8BvHcFir7YJEKnoy3+1rWiJunJtcgqq50bh9HKX0=; b=dR4y/pXMmCxJTSUQo3xhcYNSbYMpPoR0ibLd9uO3hxqA71tXTZ0c69TFkksN9UFGYo R8wFZ9oB/T5VgyuVBWyzmrJikkcrL1lcRrks6yXHHicrGrMZvjba5U4gjbEuOUpK7n3v TBLaRi4iHxutdCXsYh1eU23egKXIOyhSYVX0plw4Hj45x8zuTdLMJL/nGyrdgSz8vd5b lzFChclCV0C5Wg/RMuBkr074X3bcYQyLbFDIdnOodH/Tsv5n78xd2wqRsfSWlTZmxpnv 0djYLZkweRyf56hthVSg/SBV3V0O5LE2cODlsWUFImTVQ7LJ3wyAo04q41nKgv5ttK0Z 8Z/g== 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.4 57/74] hrtimer: Reset hrtimer cpu base proper on CPU hotplug Date: Mon, 29 Jan 2018 13:57:02 +0100 Message-Id: <20180129123850.144331216@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123847.507563674@linuxfoundation.org> References: <20180129123847.507563674@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?1590959119534942744?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.4-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 @@ -669,7 +669,9 @@ static void hrtimer_reprogram(struct hrt static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base) { base->expires_next.tv64 = KTIME_MAX; + base->hang_detected = 0; base->hres_active = 0; + base->next_timer = NULL; } /* @@ -1615,6 +1617,7 @@ static void init_hrtimers_cpu(int cpu) timerqueue_init_head(&cpu_base->clock_base[i].active); } + cpu_base->active_bases = 0; cpu_base->cpu = cpu; hrtimer_init_hres(cpu_base); }