Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2063765ybp; Sat, 12 Oct 2019 03:26:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3hkoHbzTI7nWAfWhEu05CCEz+R2jAuHaiy3OnpQrhBwIKclskM9cHcLCsfYxL6P8SiEwu X-Received: by 2002:a50:8b45:: with SMTP id l63mr18317710edl.31.1570876015456; Sat, 12 Oct 2019 03:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570876015; cv=none; d=google.com; s=arc-20160816; b=xBoMxgaYCIvJQgIoYCWPReigthAvX9dgucptJ76DVU2ejwYP+6QmDke/OFuebcfoTH DPdu+bImQ3CE9EPY6Kxnf5SEql0FTZpSzbwkrKsWOt08iImrzItJ7eRwUqJmUOeVacuf z8go7r4T9nQeZp6FCK6KD1cIdQKe8FrhYD88K4CIERbpJIPfne5c4kNb4KQzxSzm9kIY +tRT04QqyuyUoneW0zvG1ATUMbI2F/CGeEZwKRfnfser0TRSfWG9gj3P4Yom4+dcr5Y5 gHDPMPlfF8KxFOrns92NITb65e3GWPbm2BRxj66DpgKP6VXLcXuWYnHOQagD1dARGti7 /6Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from; bh=GQmfZkc5hVI/2udwrH30Lw96cQ0z6r1SQC4skR3ci1Q=; b=kY0EfkHXGSCDFPlR/PRdfYlLxoaIfPRwIxjmPDWZpYH1KJq0AuVhoHm/Ejy+RDMupv 6hyLJXQtdjsV5jzwyCZf2OSAYwEe18QyeyGgoW8grRzfCtkJX/tDWWhuyk86P+wFPaAx YLbNm9oKeJ/OZ+ap6OFUwKGNpUzmQlqEivuF7V3kSPGkTwb+JV8FXFtxi6N/aE4Rq5G0 dkCfkaJKY2BTL13Wo3CtWUA10cxaaMOFt8s+qw3sQudvyvzOAmIsTQzDhdAHuz7ia4xK WWQrKXkZYmY/Otc0W5nkdq+z/vkGw111tzSGUOIjORP11zN6nHIGPHSKRzsVLwFwY/8S /lgg== 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 w30si7686376edd.137.2019.10.12.03.26.32; Sat, 12 Oct 2019 03:26:55 -0700 (PDT) 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 S1728714AbfJLKZ7 (ORCPT + 99 others); Sat, 12 Oct 2019 06:25:59 -0400 Received: from mx140-tc.baidu.com ([61.135.168.140]:51115 "EHLO tc-sys-mailedm02.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727527AbfJLKX7 (ORCPT ); Sat, 12 Oct 2019 06:23:59 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm02.tc.baidu.com (Postfix) with ESMTP id BCB3111C004B; Sat, 12 Oct 2019 18:23:46 +0800 (CST) From: Li RongQing To: akpm@linux-foundation.org, sergey.senozhatsky.work@gmail.com, linux-kernel@vger.kernel.org, tglx@linutronix.de Subject: [PATCH] watchdog/hardlockup: reassign last_timestamp when enable nmi event Date: Sat, 12 Oct 2019 18:23:46 +0800 Message-Id: <1570875826-30491-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org last_timestamp is not initialized and is zero after boot, or stop to forward when nmi watchdog is disabled; and false positives still is possible when restart NMI timer after stopping 120 seconds so reassign last_timestamp always when enable nmi event Fixes: 7edaeb6841df ("kernel/watchdog: Prevent false positives with turbo modes") Signed-off-by: Li RongQing --- kernel/watchdog_hld.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 247bf0b1582c..fc3a5c7ccd82 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -189,6 +189,8 @@ static int hardlockup_detector_event_create(void) */ void hardlockup_detector_perf_enable(void) { + ktime_t now = ktime_get_mono_fast_ns(); + if (hardlockup_detector_event_create()) return; @@ -196,6 +198,7 @@ void hardlockup_detector_perf_enable(void) if (!atomic_fetch_inc(&watchdog_cpus)) pr_info("Enabled. Permanently consumes one hw-PMU counter.\n"); + this_cpu_write(last_timestamp, now); perf_event_enable(this_cpu_read(watchdog_ev)); } @@ -274,8 +277,12 @@ void __init hardlockup_detector_perf_restart(void) for_each_online_cpu(cpu) { struct perf_event *event = per_cpu(watchdog_ev, cpu); - if (event) + if (event) { + ktime_t now = ktime_get_mono_fast_ns(); + + per_cpu(last_timestamp, cpu) = now; perf_event_enable(event); + } } } -- 2.16.2