Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2074925ybp; Thu, 10 Oct 2019 01:44:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWVNpCGQsVILTUr1xYMgMBivLRe0TtZTLBGaiEjdFcysrlHRaX6sR68JAWfv4uXHvHSo+l X-Received: by 2002:a17:907:41e1:: with SMTP id nb1mr6890289ejb.323.1570697042774; Thu, 10 Oct 2019 01:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697042; cv=none; d=google.com; s=arc-20160816; b=CX9kwkc6qyevliN6/4r6kA99rsmhEe4aTHKXFvk1ArkoYRPlMmOw94kjVLbsGnI84j Ucf+e4uFnfbmVpBPyNLh41Mpda7YMGJexUBaFSMNXj74Xk1d57c3VG4g6i42Me16gTZc vGrr4mKjUg+mSsN34gl8tBMj7Cj1/P8TQl9Gnp4ELFMXhPBkKtfvhH1iYC+4FwFUPTBv GTXS0tevcIm+ifhTvFDeUJUMGJtOeOCRoJnl89DolQyvFonxdrC7YUBRcv9HxFx2oSwX jf7DdTVfcOHKAufBp8VTCtui6xfSXl0saLsrQx7+uTj/JbOZEaC/mtdVFQF3wcoYW73l voZA== 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=EKVUDnkLFRWRhGizy/UBWr17/PHSTcoBxherUvsD8KY=; b=yDs6jnohYqR+0UIY5JTfV3TmPx2vB7rRkjR1+FTPtRe5dZ/6Ann5tjkSl3zcO37E+d qVt9020XKd8v60ch0OOrNp4GWbXTB1Eh7bTNAfrGexm0fao0UKhkpL7/jsoPKwlu6/D8 JL6wFk48aB2yLc1OHCDo4FgFbZK4F1IpvCP4nq+7EBgCyr1yFWOXYytC6RyhJTp3b6W0 Tv4F/1IKci7WFLY52jqETtmlKZ1cKfKZUS6bIG2xu8Wm4UWLgfy1XujonOSMLsyxB1ps uz7k+YplTwbOpfWEiNJb754AHVdtU7YEHVu5gw+TywK5UUX/JTaGMsKXIlMH2herI2lZ CARg== 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 i17si2674087ejy.374.2019.10.10.01.43.39; Thu, 10 Oct 2019 01:44:02 -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 S2388438AbfJJIl6 (ORCPT + 99 others); Thu, 10 Oct 2019 04:41:58 -0400 Received: from mx133-tc.baidu.com ([61.135.168.133]:26301 "EHLO tc-sys-mailedm03.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733108AbfJJIlw (ORCPT ); Thu, 10 Oct 2019 04:41:52 -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 76F3F4500033; Thu, 10 Oct 2019 16:41:39 +0800 (CST) From: Li RongQing To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][RFC] perf/x86: avoid false-positives hard lockup Date: Thu, 10 Oct 2019 16:41:38 +0800 Message-Id: <1570696898-13169-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 if perf counter is used as nmi watchdog, and twice nmi in soft watchdog sample period will trigger hard lockup make sure left time is not less than soft watchdog period by compared with 3/5 period to skip forward, since soft watchdog sample period is 2/5 of watchdog_thresh, nmi watchdog sample period, computed by set_sample_period Signed-off-by: Li RongQing --- arch/x86/events/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 7b21455d7504..1f5309456d4c 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1196,7 +1196,11 @@ int x86_perf_event_set_period(struct perf_event *event) /* * If we are way outside a reasonable range then just skip forward: */ +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF + if (unlikely(left <= -(period * 3 / 5))) { +#else if (unlikely(left <= -period)) { +#endif left = period; local64_set(&hwc->period_left, left); hwc->last_period = period; -- 2.16.2