Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5297793ybl; Tue, 10 Dec 2019 03:50:10 -0800 (PST) X-Google-Smtp-Source: APXvYqyIUl8NrruGD6q1QbNaVcj9GxT1+nrix/JK85Zp45LH9FMaLQML2NRZ0E0mY1h/Mm4szeFV X-Received: by 2002:aca:ec45:: with SMTP id k66mr3565431oih.179.1575978610674; Tue, 10 Dec 2019 03:50:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575978610; cv=none; d=google.com; s=arc-20160816; b=NZ+hBwNBL+23BNCd+X+7DqTPkQlQi0hl1u92hVLVbWgUpMJVePJuZqDGWpuDCTmTJe 7WKSNbmfTHEe8ObEEdp3brmh6QgejOlyfash5Nv6vaeRfWJuTQXN3PFx7bZLqJeUUAwI 0omF2ZgBxRsLOLQpz8KJKuVIepkvlhbS7Gb8zL6+AxVF380e2ZWIRnsSesUqdwalWBHf rYxyHLyOWUNCSympOFRiThrC5PT5zf4vRyZqmyOn301z+cH5hKiUG4NwUT+ZS4I1eEN0 DkfGyHFVZF3psi+1K6KCwjwncKWTVHiIAVQoEbD54dAwrK9ODT2GagzeL77UAu4xc7Vx ha3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=U/5DA1eyGO0v6qHZ0HZKVg8kUJ5itXup5bm0c4LKLgE=; b=JgT9RAdlS0tL+zynLlFhWXlCNS0yBW1e+S3YKYrzUyeKnSUoTc7pdABXFBaFPFIikC ir7tpLxOc4eKwt5wbaBP2Nkh6Sxqb7hN/6zth+MCUhcHg4Is7tM8gCKpwCQS3t4OjwIx 2IrOitA+jA9zjzk82sxQ1WUO2O018usCp9Fd9DCiH6HyK3dSBsZ32iSlyvhNNbQx0zrw y8m4T40bbs82yWAQ5VD4iPTYDK/W/gGzXVOvQoXqF7DOJAh8Zbv+lf6VD6aCY42CAAPX PhT4jOb3wlvuFPZ/3tzs/2fOQrGUOW9H0n56mSxPjl3B06OB9H/JLKB2OQ3SDZQQOqwe R2BA== 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 x24si1746859otk.188.2019.12.10.03.49.58; Tue, 10 Dec 2019 03:50:10 -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 S1727500AbfLJLtc (ORCPT + 99 others); Tue, 10 Dec 2019 06:49:32 -0500 Received: from mga11.intel.com ([192.55.52.93]:4591 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbfLJLtc (ORCPT ); Tue, 10 Dec 2019 06:49:32 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2019 03:49:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,299,1571727600"; d="scan'208";a="295868192" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP; 10 Dec 2019 03:49:31 -0800 Received: from [10.125.252.242] (abudanko-mobl.ccr.corp.intel.com [10.125.252.242]) by linux.intel.com (Postfix) with ESMTP id 01EEA580A3B; Tue, 10 Dec 2019 03:49:29 -0800 (PST) Subject: Re: [PATCH] perf/x86/intel: Fix PT PMI handling To: Alexander Shishkin , Peter Zijlstra Cc: Arnaldo Carvalho de Melo , Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa , Vitaly Slobodskoy , stable@vger.kernel.org References: <20191210105101.77210-1-alexander.shishkin@linux.intel.com> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Tue, 10 Dec 2019 14:49:28 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191210105101.77210-1-alexander.shishkin@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10.12.2019 13:51, Alexander Shishkin wrote: > Commit: > > ccbebba4c6bf ("perf/x86/intel/pt: Bypass PT vs. LBR exclusivity if the core supports it") > > skips the PT/LBR exclusivity check on CPUs where PT and LBRs coexist, but > also inadvertently skips the active_events bump for PT in that case, which > is a bug. If there aren't any hardware events at the same time as PT, the > PMI handler will ignore PT PMIs, as active_events reads zero in that case, > resulting in the "Uhhuh" spurious NMI warning and PT data loss. > > Fix this by always increasing active_events for PT events. > > Signed-off-by: Alexander Shishkin > Fixes: ccbebba4c6bf ("perf/x86/intel/pt: Bypass PT vs. LBR exclusivity if the core supports it") > Reported-by: Vitaly Slobodskoy > Cc: stable@vger.kernel.org # v4.7 > --- > arch/x86/events/core.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) Acked-by: Alexey Budankov > > diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c > index 6e3f0c18908e..5a736197dfa4 100644 > --- a/arch/x86/events/core.c > +++ b/arch/x86/events/core.c > @@ -375,7 +375,7 @@ int x86_add_exclusive(unsigned int what) > * LBR and BTS are still mutually exclusive. > */ > if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt) > - return 0; > + goto out; > > if (!atomic_inc_not_zero(&x86_pmu.lbr_exclusive[what])) { > mutex_lock(&pmc_reserve_mutex); > @@ -387,6 +387,7 @@ int x86_add_exclusive(unsigned int what) > mutex_unlock(&pmc_reserve_mutex); > } > > +out: > atomic_inc(&active_events); > return 0; > > @@ -397,11 +398,15 @@ int x86_add_exclusive(unsigned int what) > > void x86_del_exclusive(unsigned int what) > { > + atomic_dec(&active_events); > + > + /* > + * See the comment in x86_add_exclusive(). > + */ > if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt) > return; > > atomic_dec(&x86_pmu.lbr_exclusive[what]); > - atomic_dec(&active_events); > } > > int x86_setup_perfctr(struct perf_event *event) >