Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3493472yba; Sat, 18 May 2019 18:58:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxq9Src9ClPQcRh15kwnF1Q5fcfSMarZ4ycl8EcVbTokN1AJip2136JYeSxh0/kN20QDEP+ X-Received: by 2002:a63:534f:: with SMTP id t15mr68270553pgl.445.1558231100566; Sat, 18 May 2019 18:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558231100; cv=none; d=google.com; s=arc-20160816; b=Co/rOstgpMMsvKEAA8FbX4Dw8Fb5ZbH7c66fyR+t2jmE+SsujDdaNgwB3fn5bA1SC5 Wg0nc/KhHPydmDNqc4+TVzp8xaHc6fgdR/3Godj0vJ17hj/A0ngsxxLiRRiQYCOd/Upi Ysw/AlQyPSiySFjTzyJx9mHzgreL/GtPKI56NWceskHSbvR966HUwh3HK9L/7QXm/WnV /E6LvwcIotqugv8CKb/DRn8jOABsxSNJVTk4Mjl10YEDERKL9I0UNALc98Rtf+wsy82V 4DXFG3kzTFt0//WbW8KI19OK6sZSdMeeCKva3pmEoa2A7eXbv6BA2OPJevzIaYy3RzCt /vYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=B+HeqwAEcCZlxTlN2fPsPmRvYlA8UMTWELs3MdTDPTY=; b=ath5wbCW3mDW64b2f4n3WzlDU/f2SCCUKHWmbk5VvPf0sudCqPhUaIcYuCZAekAgX/ H82h5GcDflHLLu7Bf8EkdshTJA7C45h+6ePLLeqRLffUpA1nbKh+C7bdHAg84rFui7j+ 3jIvi20QCLaZJcmn+fHmiezCttbv20c22JK6RsWnMuhiSFN5Rbwfuu+D48eJMMP1Sonj nuFEGoTqcZFx9fdksRDvXAcrBet4rDF2f7lSaJPQgGUDoGnbMLMcOHf8SzvW4IcmeSpb 6ulMzTQEefYdIu/rifG1sFMmUKA5ig8hkgEbP8q1YKo6Pr7uMphd6x89JS+nF5R/SOgG DKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="FWlFD/3e"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si15403246pfa.180.2019.05.18.18.58.05; Sat, 18 May 2019 18:58:20 -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; dkim=pass header.i=@google.com header.s=20161025 header.b="FWlFD/3e"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729655AbfESBli (ORCPT + 99 others); Sat, 18 May 2019 21:41:38 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:39034 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbfESBli (ORCPT ); Sat, 18 May 2019 21:41:38 -0400 Received: by mail-io1-f67.google.com with SMTP id m7so8401692ioa.6 for ; Sat, 18 May 2019 18:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B+HeqwAEcCZlxTlN2fPsPmRvYlA8UMTWELs3MdTDPTY=; b=FWlFD/3ebRRLCywonkK1V5QyHaUWgp5+enX7C4DTPmQq/+0ZOddkFJv8wtfJozlPD7 PdWr96cjJh0exNAtBjPS0bTYeRJdxVsLiP6m0kUEtobZSygqFw+ItjXcgXEWo9QyI+6t fXrGhg7LQlDs64VGOfh96k1ZXK70QND8msR6K/rY3ni8qJ4ZAqzMHoc1m4+f1w2rVzJo V/WFiCxX0Eq5ngh0DQy9e9ooY2MWmHuNUHodaJLn6u1xddzAwwNexabtGE5739t+YVLo uRqQ5B3xsFm2lPEVnBZauIF6ma/iXrYcLusEvSKiT+O8Ubeaew1MBk3z5zL3XKmv96mr 79QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=B+HeqwAEcCZlxTlN2fPsPmRvYlA8UMTWELs3MdTDPTY=; b=K6tcRV9Z+MlNNnVgixqTUB+hXNr2sS6kcN490VtGICVHtHI+jxmq+cSfd4nprlaGBq VdqMMtdru/ieIMBZmJc94HDxNSLS51nSf1s0lFxQ7FEVTfeL4TN75n866hjpA9hdlj3I a8PzoXNjDSQD7YFuGCzKioA169N955N4oToK7oNcACOHEzk+MfaV4y+66QGOpjdVZJVV wJivveyhCCVN5k2/F2CbMGKkg+Ft1KlpYaPwEWO3zjh8tCJh6FrkCeEGOx61lh27wxYp KDENgEev8usScrsiMyesOcdSxkQRJc8fGLZn+gxfP9Qjw3/BQuZ84UP0gDiLB02sxnRI MpeQ== X-Gm-Message-State: APjAAAW0aR/0JKl/ByxfvOq8k5MCn7mu2A2s659G84LUVwQOwqj2Qi+o Fwbr88XQApH31oFFo9tkE+JwLkT6x3bLqSCbf8wGpg== X-Received: by 2002:a5d:96c4:: with SMTP id r4mr10137168iol.193.1558230096974; Sat, 18 May 2019 18:41:36 -0700 (PDT) MIME-Version: 1.0 References: <20190509214556.123493-1-eranian@google.com> <20190518211630.GC51669@gmail.com> In-Reply-To: <20190518211630.GC51669@gmail.com> From: Stephane Eranian Date: Sat, 18 May 2019 18:41:25 -0700 Message-ID: Subject: Re: [tip:perf/urgent] perf/x86/intel: Fix INTEL_FLAGS_EVENT_CONSTRAINT* masking To: Ingo Molnar Cc: "H. Peter Anvin" , Vince Weaver , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , LKML , Linus Torvalds , Thomas Gleixner , Peter Zijlstra , linux-tip-commits@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 18, 2019 at 2:16 PM Ingo Molnar wrote: > > > * tip-bot for Stephane Eranian wrote: > > > Commit-ID: 6b89d4c1ae8596a8c9240f169ef108704de373f2 > > Gitweb: https://git.kernel.org/tip/6b89d4c1ae8596a8c9240f169ef108704de373f2 > > Author: Stephane Eranian > > AuthorDate: Thu, 9 May 2019 14:45:56 -0700 > > Committer: Ingo Molnar > > CommitDate: Fri, 10 May 2019 08:04:17 +0200 > > > > perf/x86/intel: Fix INTEL_FLAGS_EVENT_CONSTRAINT* masking > > > > On Intel Westmere, a cmdline as follows: > > > > $ perf record -e cpu/event=0xc4,umask=0x2,name=br_inst_retired.near_call/p .... > > > > was failing. Yet the event+ umask support PEBS. > > > > It turns out this is due to a bug in the the PEBS event constraint table for > > westmere. All forms of BR_INST_RETIRED.* support PEBS. Therefore the constraint > > mask should ignore the umask. The name of the macro INTEL_FLAGS_EVENT_CONSTRAINT() > > hint that this is the case but it was not. That macros was checking both the > > event code and event umask. Therefore, it was only matching on 0x00c4. > > There are code+umask macros, they all have *UEVENT*. > > > > This bug fixes the issue by checking only the event code in the mask. > > Both single and range version are modified. > > > > Signed-off-by: Stephane Eranian > > Cc: Alexander Shishkin > > Cc: Arnaldo Carvalho de Melo > > Cc: Jiri Olsa > > Cc: Linus Torvalds > > Cc: Peter Zijlstra > > Cc: Thomas Gleixner > > Cc: Vince Weaver > > Cc: kan.liang@intel.com > > Link: http://lkml.kernel.org/r/20190509214556.123493-1-eranian@google.com > > Signed-off-by: Ingo Molnar > > --- > > arch/x86/events/perf_event.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h > > index 07fc84bb85c1..a6ac2f4f76fc 100644 > > --- a/arch/x86/events/perf_event.h > > +++ b/arch/x86/events/perf_event.h > > @@ -394,10 +394,10 @@ struct cpu_hw_events { > > > > /* Event constraint, but match on all event flags too. */ > > #define INTEL_FLAGS_EVENT_CONSTRAINT(c, n) \ > > - EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS) > > + EVENT_CONSTRAINT(c, n, ARCH_PERFMON_EVENTSEL_EVENT|X86_ALL_EVENT_FLAGS) > > > > #define INTEL_FLAGS_EVENT_CONSTRAINT_RANGE(c, e, n) \ > > - EVENT_CONSTRAINT_RANGE(c, e, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS) > > + EVENT_CONSTRAINT_RANGE(c, e, n, ARCH_PERFMON_EVENTSEL_EVENT|X86_ALL_EVENT_FLAGS) > > This commit broke one of my testboxes - and unfortunately I noticed this > too late and the commit is now upstream. > > The breakage is that 'perf top' stops working altogether, it errors out > in the event creation: > > $ perf top --stdio > Error: > The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles). > > I bisected it back to this commit: > > 6b89d4c1ae8596a8c9240f169ef108704de373f2 is the first bad commit > commit 6b89d4c1ae8596a8c9240f169ef108704de373f2 > Author: Stephane Eranian > Date: Thu May 9 14:45:56 2019 -0700 > > perf/x86/intel: Fix INTEL_FLAGS_EVENT_CONSTRAINT* masking > > The system is IvyBridge model 62, running a defconfig-ish kernel, and > with perf_event_paranoid set to -1: > > [ 3.756600] Performance Events: PEBS fmt1+, IvyBridge events, 16-deep LBR, full-width counters, Intel PMU driver. > > processor : 39 > vendor_id : GenuineIntel > cpu family : 6 > model : 62 > model name : Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz > stepping : 4 > microcode : 0x428 > > If I revert the commit 'perf top' starts working again. > I have some ivybridge systems, let me debug this. This is likely related to cycles:ppp stuff given what perf top does. I think my patch is right, but there may be assumptions or bugs elsewhere exposed by the fix. > > Thanks, > > Ingo