Received: by 10.223.176.5 with SMTP id f5csp3427069wra; Mon, 29 Jan 2018 13:01:56 -0800 (PST) X-Google-Smtp-Source: AH8x227ew+Ps/QUh32bDET8BUtxOi901RcQ/6mundcWEr5xPotSn2FnxjpMK1J4EpWGdAlB8CNq2 X-Received: by 2002:a17:902:788b:: with SMTP id q11-v6mr2966025pll.378.1517259716837; Mon, 29 Jan 2018 13:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517259716; cv=none; d=google.com; s=arc-20160816; b=ZW1da5olPjkkz8zNbLNyLF2P9v8nP5QfNM9Wiu6IfWLR8vJutrpJM2lYi6WRpkWnG/ A0TvhBGhAasAFy4qpLIHKuwcVTMt6+9CApQ4fum4gkIp/qu/dX5T64M24cTcmse63ny/ dLiDeL5+pat567BxjY4TXHAgq3G+4RJksFbrYWEL9ZnLDa6sLSIj0YcfEzcyB1MUnN3Q /ssH73xP8QM0rYchmrAgyin0/BhHE4PRFTIQjQ9QoMCAMQl8+5Eh/aY22NrXSeu4ayyZ 09JwPSHpOOk1ANkB53GyUxTwYGbChtdEpvWczi95po5cV/cIXa7qMF8XVal37Yt1B2dr 5iQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=BqUGYpTqox9cRDUQeW9TgxhD94RffDHZpAcq3yFEbdY=; b=KbTugtj6ZHHh6FoysG67T/fTFDZy/RkL5zY7SJ1fkq8a3iTSJgzqi+ko4HPBWi4XBk dGDusatf4b4m4Xaqd3H5XzxnUCtugInifho0e9IGIJohXJoN0NfZ1X3STJkUlfVfE47u 8I/oRleY6uXIIijhh5JKfY6QzaDbezRje8JJPb3BVDgBeOkztT58tCqS4woY+pkAU4HP HboBtzMlQuj2NMhY7WbNw7fQKRaBaDXOaZsQHiNLuY6GySAaPW1MvbzOaMMzYov/izCe J8EQYySmzWINghfUQE+01VHlg+CWqVWXC7WN1jphdZHeqvbUjVcVcxVoBfMoW/jZ3Sco 8JBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si1609962pgf.90.2018.01.29.13.01.41; Mon, 29 Jan 2018 13:01:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753071AbeA2UIU (ORCPT + 99 others); Mon, 29 Jan 2018 15:08:20 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52496 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753056AbeA2UIR (ORCPT ); Mon, 29 Jan 2018 15:08:17 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id F29782FB5; Mon, 29 Jan 2018 13:06:48 +0000 (UTC) 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.9 58/66] hrtimer: Reset hrtimer cpu base proper on CPU hotplug Date: Mon, 29 Jan 2018 13:57:22 +0100 Message-Id: <20180129123842.935660606@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-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 @@ -652,7 +652,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; } /* @@ -1610,6 +1612,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;