Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5505514ybp; Tue, 15 Oct 2019 00:08:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYPvE4Y09swa99CDxBfbb/2mF1RKx3IOWuNrBTCwH47ALTSA9yqCBRWpfAsV0FEx4C/kUJ X-Received: by 2002:a05:6402:1511:: with SMTP id f17mr11562846edw.232.1571123306168; Tue, 15 Oct 2019 00:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571123306; cv=none; d=google.com; s=arc-20160816; b=eBmbyciORVrKybZgcgEt/CCqxDxSyObW5/+1jHqVjR3rzqcUXMY0DRKXsS13sFlgcG hMqcVSto/Yo11NrQt54ap3et4uIM5AwKOowIPs4qDSyXIm1izBk3htTDGrnwvHTuXCzS zqXxXmOh5KOBH6Oq72/4+22sfTmXb/vFNzTIpdENgUJUuyIcEeN1BtTF8WwhAGGdSsYD UczKdfRdZ/uBapzuxbUrG+XHSFF+tn7NStWFmIWdLEL6NV0q0qUQ+A3dlHNraTEtEWBn lh35gdgtB1n86MHugZLCXiZaU4zIay6+VJz9KiXUxVXDzeFeDte/6EmNRpU+s6owKBBF 5fqQ== 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=FecLaWizWS3cIq0Iv5jNQmiaVOhE3tBwSQ7ROgLFwMw=; b=WZ1fYV+TNIiCaPEReJK61kv8G8Pfm7RwRSxUE1P//iVm15AS6mf/Ph1OaaV8dYUre2 iAi7hIfF47mzBMZT5IGsz6idYyKe/PcFymoAeXUEVrYVt88fIpouKGMmkHoTsv8Yx0py wSl/Mwi2gtIyHGZaOzcZo5g6NsUFIL123yEiOCfH9/61EZs9akOLqdFEzZuOSkzMJQN/ D0VyD0S4uAzX9opT0V9JJkD/bgMICUWuJSnqDoGE45g2LlblCi9DrxCBjJaNaiDsztQg E4itYq76I+4Em49tuM8jPhrzABjihXxcW3BLHdceWiMyCakYI0X7M0wekRf6VaGK+xgU aUVA== 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 ck24si12437157ejb.400.2019.10.15.00.08.02; Tue, 15 Oct 2019 00:08:26 -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 S1727419AbfJOGeU (ORCPT + 99 others); Tue, 15 Oct 2019 02:34:20 -0400 Received: from mx132-tc.baidu.com ([61.135.168.132]:31970 "EHLO tc-sys-mailedm03.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726052AbfJOGeU (ORCPT ); Tue, 15 Oct 2019 02:34:20 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm03.tc.baidu.com (Postfix) with ESMTP id 1BFE34500035; Tue, 15 Oct 2019 14:34:07 +0800 (CST) From: Li RongQing To: akpm@linux-foundation.org, sergey.senozhatsky.work@gmail.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, Kan.liang@intel.com Subject: [PATCH][v2] watchdog/hardlockup: reassign last_timestamp when enable nmi event Date: Tue, 15 Oct 2019 14:34:07 +0800 Message-Id: <1571121247-19392-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 Signed-off-by: Zhang Yu --- v1-->v2: make it be able to be compiled on no CONFIG_HARDLOCKUP_CHECK_TIMESTAMP platform kernel/watchdog_hld.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 247bf0b1582c..f14d18280387 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -91,11 +91,24 @@ static bool watchdog_check_timestamp(void) __this_cpu_write(last_timestamp, now); return true; } + +static void watchdog_touch_timestamp(int cpu) +{ + + ktime_t now = ktime_get_mono_fast_ns(); + + per_cpu(last_timestamp, cpu) = now; +} #else static inline bool watchdog_check_timestamp(void) { return true; } + +static void watchdog_touch_timestamp(int cpu) +{ + +} #endif static struct perf_event_attr wd_hw_attr = { @@ -196,6 +209,7 @@ void hardlockup_detector_perf_enable(void) if (!atomic_fetch_inc(&watchdog_cpus)) pr_info("Enabled. Permanently consumes one hw-PMU counter.\n"); + watchdog_touch_timestamp(smp_processor_id()); perf_event_enable(this_cpu_read(watchdog_ev)); } @@ -274,8 +288,10 @@ 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) { + watchdog_touch_timestamp(cpu); perf_event_enable(event); + } } } -- 2.16.2