Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1946803img; Wed, 27 Feb 2019 08:07:05 -0800 (PST) X-Google-Smtp-Source: AHgI3IZJAak31PdnCLhlFppR4tyq6YTCtOrdE4iI3wzSiRAlUxWAElXh1lr+WXYbHm6SR7oVVZh2 X-Received: by 2002:a65:4784:: with SMTP id e4mr3620170pgs.12.1551283625254; Wed, 27 Feb 2019 08:07:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551283625; cv=none; d=google.com; s=arc-20160816; b=fPY4vRXoNiaz3hkm08e3SRpCBriItSfDY/EFyXR0jMfzPuTd2HHtp9Ru09Zo6G5FDN umny70f2a1nJI9h40ClF/WTctyI7UjaFV00h9Q2UlkH5+0oK+HTIWQ+SNnfA/9Zghrpk A/Ij/tLYI1K2uBL4D7Tz7m7G1vykhm42Sq4QF4bDr0dLsxIp1uOed3qnb5u+0k0Y0qap Q4WXJuTVS3XawRXW5d/agBiewYzajw/cJObzExRBE4gXndG7XXskqhLV0efTi4oJ7OsO ygoNS/CRdKbGJFoOM9HgwAWjvgSEESvwmO3BwtGK74N+9m8V0zy2KF56y8GrrDYaVySb USBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=2r05iB//DvReryg0sddiJbN1wc5akJxQLYhYG7jFmvc=; b=co7kH52SgiNZge2lYPtnxedk8s+neAQadkH7ADPCJZKHf1dkasJT2xiuKHUENMIRky uAWC+4ZHjua2eQtoTPF8lqYOZlWK6fJY5ec0U1U+ZRIysFTnmU/j+1yHefmyr3LCB5qY ElNHFI33lmhkBWa7tsw6fUYfss0HPRmFQ9hDoDG5poqF4vwtnbK9p3xWKTk1Ab37c2lw vS+ASz05cDBiOex6p3HsGXgDkLnfbAk+5fXq5trKjV0lDY7oznEcg+nb3XyaQwxa3KGw XmMJttSOKyiVNG60IvwwrRI1RhZ75f9M/1SGGjVQnULw2/Fubq43vnAg1OHu58eG2b9b yVtw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g127si14963006pgc.313.2019.02.27.08.06.48; Wed, 27 Feb 2019 08:07:05 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729984AbfB0QFy (ORCPT + 99 others); Wed, 27 Feb 2019 11:05:54 -0500 Received: from mga01.intel.com ([192.55.52.88]:6599 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729756AbfB0QFu (ORCPT ); Wed, 27 Feb 2019 11:05:50 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2019 08:05:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,420,1544515200"; d="scan'208";a="303011674" Received: from unknown (HELO luv-build.sc.intel.com) ([172.25.110.25]) by orsmga005.jf.intel.com with ESMTP; 27 Feb 2019 08:05:47 -0800 From: Ricardo Neri To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Ashok Raj , Andi Kleen , Peter Zijlstra , "Ravi V. Shankar" , x86@kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Ricardo Neri , "H. Peter Anvin" , Tony Luck , Don Zickus , Nicholas Piggin , Michael Ellerman , Frederic Weisbecker , Babu Moger , "David S. Miller" , Benjamin Herrenschmidt , Paul Mackerras , Mathieu Desnoyers , Masami Hiramatsu , Andrew Morton , Philippe Ombredanne , Colin Ian King , "Luis R. Rodriguez" , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH v2 07/14] watchdog/hardlockup: Define a generic function to detect hardlockups Date: Wed, 27 Feb 2019 08:05:11 -0800 Message-Id: <1551283518-18922-8-git-send-email-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com> References: <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The procedure to detect hardlockups is independent of the underlying mechanism that generated the non-maskable interrupt used to drive the detector. Thus, it can be put in a separate, generic function. In this manner, it can be invoked by various implementations of the NMI watchdog. For this purpose, move the bulk of watchdog_overflow_callback() to the new function inspect_for_hardlockups(). This function can then be called from the applicable NMI handlers. Cc: "H. Peter Anvin" Cc: Ashok Raj Cc: Andi Kleen Cc: Tony Luck Cc: Don Zickus Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Frederic Weisbecker Cc: Babu Moger Cc: "David S. Miller" Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Mathieu Desnoyers Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Andrew Morton Cc: Philippe Ombredanne Cc: Colin Ian King Cc: "Luis R. Rodriguez" Cc: "Ravi V. Shankar" Cc: x86@kernel.org Cc: sparclinux@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Ricardo Neri --- include/linux/nmi.h | 1 + kernel/watchdog_hld.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 9003e29cde46..5a8b19749769 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -212,6 +212,7 @@ extern int proc_watchdog_thresh(struct ctl_table *, int , void __user *, size_t *, loff_t *); extern int proc_watchdog_cpumask(struct ctl_table *, int, void __user *, size_t *, loff_t *); +void inspect_for_hardlockups(struct pt_regs *regs); #ifdef CONFIG_HAVE_ACPI_APEI_NMI #include diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 71381168dede..9724cd57307b 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -106,14 +106,8 @@ static struct perf_event_attr wd_hw_attr = { .disabled = 1, }; -/* Callback function for perf event subsystem */ -static void watchdog_overflow_callback(struct perf_event *event, - struct perf_sample_data *data, - struct pt_regs *regs) +void inspect_for_hardlockups(struct pt_regs *regs) { - /* Ensure the watchdog never gets throttled */ - event->hw.interrupts = 0; - if (__this_cpu_read(watchdog_nmi_touch) == true) { __this_cpu_write(watchdog_nmi_touch, false); return; @@ -162,6 +156,16 @@ static void watchdog_overflow_callback(struct perf_event *event, return; } +/* Callback function for perf event subsystem */ +static void watchdog_overflow_callback(struct perf_event *event, + struct perf_sample_data *data, + struct pt_regs *regs) +{ + /* Ensure the watchdog never gets throttled */ + event->hw.interrupts = 0; + inspect_for_hardlockups(regs); +} + static int hardlockup_detector_event_create(void) { unsigned int cpu = smp_processor_id(); -- 2.17.1