Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp312597ybm; Mon, 20 May 2019 16:57:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/BSCkyqo0j1d5A2U7Y+5uzNIluZli7clx3DStmLWY4vFCLxQ8szsm2RFUkBDfyuyyrkUk X-Received: by 2002:a63:6fce:: with SMTP id k197mr79413470pgc.140.1558396630801; Mon, 20 May 2019 16:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558396630; cv=none; d=google.com; s=arc-20160816; b=JjxBKT3uQfJrFUuOYi/AUe1tqYFzp3Xwg3iRQtn9SppNGLMHOKi6sb1KgRNKB0/Skh 73tXqYKM9dkggkAeUofPc/xWrsV0sHxM+yDLxMmaeusA99q7jyXSzF4sjxnbyeogUzDP cROkg968Ir1I3pkUUci8oQw6U/dlwGpDskjN9Fbi7alYR5Nrfijs+LDyn4D8MVclz3Sw HpotE0Evt6RuwrfLRGfVTF+WHEtpFLwMVUy8wp0mIZdlLf192XZZgygY1gPTQ2x4JOd3 usH/lbMCneMNK0JmbcrhZ9pKpRePqywXJUIQcMOCwradtKHMnx4qsvCx9ifmMQpIf4ml Os7g== 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=pO+T3YM/eg4pYPScPkRyTQ6bvK/T9SG3Sddd2C72QZ4=; b=ryHPhHYm6cnj1/uDUTbM16B9tobkMDOz4tmNYPcU6+pKb1Xy2cMz+TGo59CrN+dXXp HheDmLXPTktK8yu+A5JV1PZsO0nJ0SSAxOz/q/3nbYugCofCRnq02s5DFJ9jyjkfPL5t QzXOi+k6K6OxpYwKjJB09VV0YiMWYmMeXgietagnACT1NUR+A1ogNTQNM7JnZgp2Pi1w fQZWda35gbUcGOnuqSqj2tZTjZiordRWF+OsPunoPZ5S6xz4hbJR8Vj2UmVd/EmyFOTJ GC5qAYdOLXsZDPFxzFE7o9UE7ul9g/Esojm0l0ZRriTv4tZcoOvwNUy/+43OF/PlXDhC cIQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nCPg27Kh; 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 33si19729931pgt.52.2019.05.20.16.56.55; Mon, 20 May 2019 16:57:10 -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=nCPg27Kh; 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 S1727348AbfETXyq (ORCPT + 99 others); Mon, 20 May 2019 19:54:46 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:46687 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbfETXyq (ORCPT ); Mon, 20 May 2019 19:54:46 -0400 Received: by mail-pg1-f201.google.com with SMTP id t16so10803890pgv.13 for ; Mon, 20 May 2019 16:54:45 -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=pO+T3YM/eg4pYPScPkRyTQ6bvK/T9SG3Sddd2C72QZ4=; b=nCPg27KhSaoV69UNbxgZeb4MsHG4oh6+KXAWftJW3FpQ/H3Z4RD31XVcnhrNgmCxcr 9PiV3wPS6vt9T6PMbFpHJQWx0bULg/TCwLdj2QTvOt3SB4W5OfEYuTlIBopBKFuZCUW5 XyxBQgzel0r98VphvtvGAJJBKLQ2S/zr1SGd/AMZwX8xlZGMg67TNp9+dcROd3GuCo7i ipApDrq3Bb1KQdKW/kgsOLa3btI3sQ+JBbw2AZlw/sn+N7Ej3bzMpJ0UQYriXgPU420y fmNNsDVM4hItmYdgIG/gX8qQ5Ar6QWrOcC8yiUb6yVqGdEkx9ATBZB9fhKJaImc5/bm/ A9Kg== 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=pO+T3YM/eg4pYPScPkRyTQ6bvK/T9SG3Sddd2C72QZ4=; b=TcZacGuIeaY5pn/3M9MrPAO+uzXCspIK9m04mrYnsh+ACxykjcPq0SDV97ivDbBP57 bnONLB8bX4U7PGyDgPJi1ukHz6LC0705iXwKp0jqklcZxV8v00VNVQXPwJhcwk8z7aSp UbqorykmwckpKGpNSstGgU0hM2qEWybKOPJS7T6Kt+Uwyxukf/3pTGvFVcJ50AmZuAMO +0piGbVeckXj7J6qKVu94sa+qQckT5EHvQyIirAS+rrwBVRWel4ln7C06FJ215SIiPAn t0Hv0CLmGeTn8DwwnxDz+rqpIHBVyNiwSNO8CTXgFUENwYO/x+aCuCzHnDzBgpLIl6YZ ulcw== X-Gm-Message-State: APjAAAXHmdnBzUlPreQdUg6PohL84WTT7oweRPV0vi+q/YOyqVQsQfNr Wz6uxplyGulcmhEWqmZzXrlrIo+onPSdjcC5kM4Vq6ptXh0iOmJvwKUv1VEKlvBQJKZ3Vm5IxiA UDU/rn8fNLVjTGJzR5WxzdBjZbXMf2f+vZyFFEq2zjvnSSIUAImNKWkodvlnNqFuaF6WSXZeP X-Received: by 2002:a63:1354:: with SMTP id 20mr76949322pgt.356.1558396485001; Mon, 20 May 2019 16:54:45 -0700 (PDT) Date: Mon, 20 May 2019 16:54:24 -0700 Message-Id: <20190520235424.196961-1-eranian@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog Subject: [PATCH] perf/x86/intel/ds: fix EVENT vs. UEVENT PEBS constraints From: Stephane Eranian To: linux-kernel@vger.kernel.org Cc: mingo@kernel.org, peterz@infradead.org, ak@linux.intel.com, kan.liang@intel.com, 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 This patch fixes an issue revealed by the following commit: Commit 6b89d4c1ae85 ("perf/x86/intel: Fix INTEL_FLAGS_EVENT_CONSTRAINT* masking") That patch modified INTEL_FLAGS_EVENT_CONSTRAINT() to only look at the event code when matching a constraint. If code+umask were needed, then the INTEL_FLAGS_UEVENT_CONSTRAINT() macro was needed instead. This broke with some of the constraints for PEBS events. Several of them, including the one used for cycles:p, cycles:pp, cycles:ppp fell in that category and caused the event to be rejected in PEBS mode. In other words, on some platforms a cmdline such as: $ perf top -e cycles:pp would fail with EINVAL. This patch fixes this issue by properly using INTEL_FLAGS_UEVENT_CONSTRAINT() when needed in the PEBS constraint tables. Reported-by: Ingo Molnar Signed-off-by: Stephane Eranian --- arch/x86/events/intel/ds.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index ea2cb6b7e456..88e73652a10c 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -743,7 +743,7 @@ struct event_constraint intel_westmere_pebs_event_constraints[] = { INTEL_FLAGS_EVENT_CONSTRAINT(0xcb, 0xf), /* MEM_LOAD_RETIRED.* */ INTEL_FLAGS_EVENT_CONSTRAINT(0xf7, 0xf), /* FP_ASSIST.* */ /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x0f), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108000c0, 0x0f), EVENT_CONSTRAINT_END }; @@ -752,7 +752,7 @@ struct event_constraint intel_snb_pebs_event_constraints[] = { INTEL_PLD_CONSTRAINT(0x01cd, 0x8), /* MEM_TRANS_RETIRED.LAT_ABOVE_THR */ INTEL_PST_CONSTRAINT(0x02cd, 0x8), /* MEM_TRANS_RETIRED.PRECISE_STORES */ /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c2, 0xf), INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOP_RETIRED.* */ INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */ INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */ @@ -767,9 +767,9 @@ struct event_constraint intel_ivb_pebs_event_constraints[] = { INTEL_PLD_CONSTRAINT(0x01cd, 0x8), /* MEM_TRANS_RETIRED.LAT_ABOVE_THR */ INTEL_PST_CONSTRAINT(0x02cd, 0x8), /* MEM_TRANS_RETIRED.PRECISE_STORES */ /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c2, 0xf), /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c0, 0x2), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c0, 0x2), INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOP_RETIRED.* */ INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */ INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */ @@ -783,9 +783,9 @@ struct event_constraint intel_hsw_pebs_event_constraints[] = { INTEL_FLAGS_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PRECDIST */ INTEL_PLD_CONSTRAINT(0x01cd, 0xf), /* MEM_TRANS_RETIRED.* */ /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c2, 0xf), /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c0, 0x2), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c0, 0x2), INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_NA(0x01c2, 0xf), /* UOPS_RETIRED.ALL */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_XLD(0x11d0, 0xf), /* MEM_UOPS_RETIRED.STLB_MISS_LOADS */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_XLD(0x21d0, 0xf), /* MEM_UOPS_RETIRED.LOCK_LOADS */ @@ -806,9 +806,9 @@ struct event_constraint intel_bdw_pebs_event_constraints[] = { INTEL_FLAGS_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PRECDIST */ INTEL_PLD_CONSTRAINT(0x01cd, 0xf), /* MEM_TRANS_RETIRED.* */ /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c2, 0xf), /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c0, 0x2), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c0, 0x2), INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_NA(0x01c2, 0xf), /* UOPS_RETIRED.ALL */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_UOPS_RETIRED.STLB_MISS_LOADS */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x21d0, 0xf), /* MEM_UOPS_RETIRED.LOCK_LOADS */ @@ -829,9 +829,9 @@ struct event_constraint intel_bdw_pebs_event_constraints[] = { struct event_constraint intel_skl_pebs_event_constraints[] = { INTEL_FLAGS_UEVENT_CONSTRAINT(0x1c0, 0x2), /* INST_RETIRED.PREC_DIST */ /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c0, 0x2), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c0, 0x2), /* INST_RETIRED.TOTAL_CYCLES_PS (inv=1, cmask=16) (cycles:p). */ - INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x0f), + INTEL_FLAGS_UEVENT_CONSTRAINT(0x108000c0, 0x0f), INTEL_PLD_CONSTRAINT(0x1cd, 0xf), /* MEM_TRANS_RETIRED.* */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_LOADS */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x12d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_STORES */ -- 2.21.0.1020.gf2820cf01a-goog