Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1327708yba; Thu, 9 May 2019 14:47:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTheuiNQuoywr4zu1HYXRsifHYpx5u6mBy1BG20LJjSbGgYyIPmxjCHPPdgozDlX1iUdUz X-Received: by 2002:a65:6145:: with SMTP id o5mr8828390pgv.262.1557438435952; Thu, 09 May 2019 14:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557438435; cv=none; d=google.com; s=arc-20160816; b=XJtcPxwaO4f+Os0eYs+EwiyHUszRQ5OTRFk+3rzuS9fgNhsypRiV8eY1ZDFZsKUQRc i/y8wR9/1KKECso+1Xt3xiZLTzhhob8Qpp+6OM5NuoxmkggoGOlgNuxWmvInDJ9hnHr2 ahqmmWOWcaHp7hAtm4y869fkooJqOGDrTp3oj8NnVqhcNvuHowVgzGV/BWungEVffpIb gobOOSQBbv0psmnkajxleLw3R3qf/xviJh3tRVJfo+/ktrnR6RIJ6GEg+GoFgqexYITr zYVD1sBSnRq0z4+NR5zG1jWTnrLlWB494XYlnffHHRTI5FgDsaNUPyzb3aa9xChUALRZ BIsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=nL0d57hUSvuWMoFDn/5vE0YoiIh4JIjeGFoZupaY4Z0=; b=Euu61H0KgmwdaeMY8GZRNMBL7JF+6ni3zAlt9kVRrCNS7UR4oGNe2lEKbglWBYh8gn xELAj7paCB4jX50S/C8AChMOXwmpseT8I+b6dVLdPEuT5cJ9+fcIWGD7Vs24WOwLJ9SU 39A8quqlKzhGuwFkGBtk5bczNEh1jQoD4yt1B0ROrE2VWWX2NSTCOlQCtBAQ1q464mAn c7qSjGqPA90hl1pXK0+39Z2U8KYS5/qA60SDvf7lzE4oNF4eD9a/jf79kq3AU3eGK/Qg v47AKHO+F0Me0qamidW6Upr1B4HCBUb7krHTwL/ELehvUa3F+4xW0ens31P9OnsA5Bd5 GUwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=evtcUmo5; 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 z11si4484431pgv.333.2019.05.09.14.46.59; Thu, 09 May 2019 14:47:15 -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=evtcUmo5; 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 S1726862AbfEIVqJ (ORCPT + 99 others); Thu, 9 May 2019 17:46:09 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:35832 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbfEIVqJ (ORCPT ); Thu, 9 May 2019 17:46:09 -0400 Received: by mail-pl1-f202.google.com with SMTP id x5so2342067pll.2 for ; Thu, 09 May 2019 14:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=nL0d57hUSvuWMoFDn/5vE0YoiIh4JIjeGFoZupaY4Z0=; b=evtcUmo57VHXFRBIP0x3AWI/DRc3GoPZaqq5H22bjls+Q7ydyTuym6zn5aJsVRqI7b v/zJxW3n1+HyBoRCOg1Dy+7OAz/B2uwfI1yVI2zq3D43tv5+7W+hqrrGKqeLCNFi0PaY 14tdO/vksvtSvUg7+DuJibE3hr4PABy6ftpf7prdfwTPOSL9AiA6QR53jppQyadCeITX XT8iPNt6mWYzunPDsy28D0PTr4eh4C5LozBF/jjeVLFOX4uoSIN6co5vlToN95JXg50v Tuw2aHRraWK8zsKaxkPMM7VWLwL+xpH5BGTP5rDbtCt6QLrT+9KxgDwEQgZFhJaNK5br N9XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=nL0d57hUSvuWMoFDn/5vE0YoiIh4JIjeGFoZupaY4Z0=; b=Nk0I2nS447fESeQy5tjupUgG590uyGpzJa0NbHPqiC8IqAY5/k3h2VpOqiJmxpQd0g bDOS1LPZkN9BDcfoIhXbKBrc4XffGMaAhTTbrqs5pl92Rcc4OuC4Gjx/s3gEMVyg4D8f 0UsAeG8cot0956hcc/P5r4L24ZvQnp4xchRN2UZSoji1ThHnA34p5VjE2dqAADwS0S50 WuJPU0mNCvfckSA/A5bR1UIjK9xJK9bXu7Jex3iRe8NBLdPyy4AupyGcZSSEuBXqvENU PwX/eox5rfHCEH5yFWaFpsF6kDI7CYLlN9iKvi33zzzp0KHFjYUqzccQHw+W7xyBgSRe aN/w== X-Gm-Message-State: APjAAAWgs53iYwD1PXm1ZF2s/AclK1tsZo864HkvNA0IS4ThQX/0YKOP 5Djbvt9JbcohdGAugqQgFGyeeDYgT/ep3lrl6R8VKxXse+GFp+pWjLIfXjUceFlN31TALSMsHRX bmIrecDPDfrY1FkimG7kuZArglkUFaJ7p3pKb9l/tXkwK/pAKKGggQBLJ5leiw7zC8Z0xZffz X-Received: by 2002:a63:4a4f:: with SMTP id j15mr8738947pgl.338.1557438368607; Thu, 09 May 2019 14:46:08 -0700 (PDT) Date: Thu, 9 May 2019 14:45:56 -0700 Message-Id: <20190509214556.123493-1-eranian@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog Subject: [PATCH] perf/x86: fix INTEL_FLAGS_EVENT_CONSTRAINT* masking From: Stephane Eranian To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, ak@linux.intel.com, kan.liang@intel.com, mingo@elte.hu, jolsa@redhat.com, vincent.weaver@maine.edu 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 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 --- 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) /* Check only flags, but allow all event/umask */ #define INTEL_ALL_EVENT_CONSTRAINT(code, n) \ -- 2.21.0.1020.gf2820cf01a-goog