From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6334217F3B for ; Sat, 26 Oct 2024 12:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729945086; cv=none; b=aqdBw3ofpBdtmh9fax+wlbMknOENAOG5JgNkQUagG0BmURPJzkIPSJyEgyJd3xsckkOGiduIaB+q5Bw2EBOmNUZQypO2C6lM1t50aciXOpMPD6ulMLNiyuQZvTylkoJgNVVkdnasTb2kbP/lvKH7HzDl3ZEz5a/P2uakWl3i+jM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729945086; c=relaxed/simple; bh=f+Yk5CtSNdB/1Lmu/zKBb9xb884EAaFAdkWSJ9+l47A=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=Psf2ckEbMXqJOeX8cJN6VAebko5SS5KfO07VHavdDPsEmZyB8t016Ba/e7L/2p6rI4U7jVIXaQvdsrxOFg1kAWzEqsDvMvZ1LJiDCguyDFP2FGsWIaRPlL8mcWKzueHmsEeokhRTicyuCUkWh8NptG82EXpZ1YBkJgKF2xOLLt4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Deg58Wpx; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Deg58Wpx" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e28fc60660dso4833475276.0 for ; Sat, 26 Oct 2024 05:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729945084; x=1730549884; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=fBcJl01TtjB1sQ+coZ3yEQeNcjr8kffC1BqiKyM+Ja4=; b=Deg58WpxuUdeldjva0WZ2Qi6mnOYfCjCqMrOeEpyh4hGln4wyn2LlpVI0xVdGVaHw0 HoKTCa0oORN1xR0yB890uag0h7AKpP5q+BUCuJ7SQkT9tAlGbeG56QDvkoNM6tpaK+dx mye8VYen+7tyQ/s61zeTIYrcfDVGt8oto+/l4W5Wf+QaQDBvAJ5DjDWUe14rmY9AeXSW hGM+ILPhaxBZVFWu3sci7epCegS0ff6JnpbKxu4IpxpL5IxP7rsM21TP7D4K5c11MJ+R onUCyzRLlNxQbKKmmBLCT2nnUa3inTLSSV0slXgMGJamqO1Qcv1VVIhSaDtK2Xm00+X/ ojww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729945084; x=1730549884; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fBcJl01TtjB1sQ+coZ3yEQeNcjr8kffC1BqiKyM+Ja4=; b=DGIXFeOuzL9az46hYwX4p+/ILFgLriUzOitWbbKuX6acYAhsZNkb9JNJ3nA6aiaGEq 42lwNgbothF19rRPcQ5eN/qKNKCfI+QML3yoAu8l29ybRxfjLUkdlWz70Zix21iqE8KP JpF6ix0jSCE4xWON89TxfcG/7AHcrlD7nu4lFS+FT84F1znY44xiepCqUms8efK1rKzc DJzZ7+UocMG4NuLAy4GIpzwm4C9m3jbAZWL14tDwgQmm2zowwIWnta+7cO25cOXlVBgF 6YB+3HOFv+Ked6lsrMgZyHDVbPrA8+Di9AkU1TQzLXCPLeZpgCgfwm6yO3Q35r5lfc3l 1oDA== X-Forwarded-Encrypted: i=1; AJvYcCUWNO2YBL6OZSiXCAhtDeFcAhDuUuoWRFhTH8bBEpAcHNHWsOOTTmxzRP60k1JSZyf5fb6bNkKvvC30LcKXNXZq@vger.kernel.org X-Gm-Message-State: AOJu0YzfZigQyzDUoCfQBjdV1kUs8qk9X7qcU6OVMbVbT5jzy9UEZLl2 76XydI7qnqxHA77b74FyRhhHyB7/mWiUCiG5d7zfOvwLyUpLIQC7SHgWGgPv93iFFBOfwO6JaNJ AnYCL1w== X-Google-Smtp-Source: AGHT+IE9zYMgTwSHLGYlj300YfFrmvke8frEqe5oUqwbyU39/+jljEJ0ran0v7PIwH2GumKW+rj4eS6UlTFR X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:4bc4:f7cc:83b4:dece]) (user=irogers job=sendgmr) by 2002:a25:a207:0:b0:e25:6701:410b with SMTP id 3f1490d57ef6-e3087b792abmr5358276.5.1729945083545; Sat, 26 Oct 2024 05:18:03 -0700 (PDT) Date: Sat, 26 Oct 2024 05:17:54 -0700 Message-Id: <20241026121758.143259-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v1 0/4] Prefer sysfs/JSON events also when no PMU is provided From: Ian Rogers To: Atish Patra , linux-riscv@lists.infradead.org, beeman@rivosinc.com, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Ze Gao , Weilin Wang , Ben Gainey , Dominique Martinet , Junhao He , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" At the RISC-V summit the topic of avoiding event data being in the RISC-V PMU kernel driver came up. There is a preference for sysfs/JSON events being the priority when no PMU is provided so that legacy events maybe supported via json. Originally Mark Rutland also expressed at LPC 2023 that doing this would resolve bugs on ARM Apple M? processors, but James Clark more recently tested this and believes the driver issues there may not have existed or have been resolved. In any case, it is inconsistent that with a PMU event names avoid legacy encodings, but when wildcarding PMUs (ie without a PMU with the event name) the legacy encodings have priority. The patch doing this work was reverted in a v6.10 release candidate as, even though the patch was posted for weeks and had been on linux-next for weeks without issue, Linus was in the habit of using explicit legacy events with unsupported precision options on his Neoverse-N1. This machine has SLC PMU events for bus and CPU cycles where ARM decided to call the events bus_cycles and cycles, the latter being also a legacy event name. ARM haven't renamed the cycles event to a more consistent cpu_cycles and avoided the problem. With these changes the problematic event will now be skipped, a large warning produced, and perf record will continue for the other PMU events. This solution was proposed by Arnaldo. Two minor changes have been added to help with the error message and to work around issues occurring with "perf stat metrics (shadow stat) test". The patches have only been tested on my x86 non-hybrid laptop. Ian Rogers (4): perf evsel: Add pmu_name helper perf stat: Fix find_stat for mixed legacy/non-legacy events perf record: Skip don't fail for events that don't open perf parse-events: Reapply "Prefer sysfs/JSON hardware events over legacy" tools/perf/builtin-record.c | 22 +++++++--- tools/perf/util/evsel.c | 10 +++++ tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 26 +++++++++--- tools/perf/util/parse-events.l | 76 +++++++++++++++++----------------- tools/perf/util/parse-events.y | 60 ++++++++++++++++++--------- tools/perf/util/pmus.c | 20 +++++++-- tools/perf/util/stat-shadow.c | 3 +- 8 files changed, 145 insertions(+), 73 deletions(-) -- 2.47.0.163.g1226f6d8fa-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EC6AD10BF7 for ; Sat, 26 Oct 2024 12:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:Mime-Version:Message-Id :Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=DD+DWr/glCrU9mz4sCX1+uHDFJCaNoPxC94D6ActScQ=; b=P8qV4WEqobAVD3 I2wy2jKEWc5cU+cttLBbH4SQ+5Nw6BQQIM59c7+VqFLdTNDk8xl4K6f1+NjObd5JgmeYimZnWPDDi 5tymGHGBZbeq1qnkQbi4muGjmY6Ew7bmu1gRMwMapvfxBXFa/5G0FNNQJqFCq7xvNr+jlevrzLJJ2 KzKnfM1Hnx9uVeXNI9TwkgJeM7ii+U8bS4WrMjTDpiVZtuPN1u3IXhkEuoc7QAmqgs7ZDRFwHE83K 0TCC8A1owHW3j2gmy46vKcYN0XMPMSvUAsToAyCLr3a12Pylfr3xc80kFM/PHSVZDL5XBSITVK0nr 52febVXhe5E/S+VINQBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t4fk7-00000006aXK-2KBg; Sat, 26 Oct 2024 12:18:07 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t4fk5-00000006aW6-2euj for linux-riscv@lists.infradead.org; Sat, 26 Oct 2024 12:18:06 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e28fc60660dso4833480276.0 for ; Sat, 26 Oct 2024 05:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729945084; x=1730549884; darn=lists.infradead.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=fBcJl01TtjB1sQ+coZ3yEQeNcjr8kffC1BqiKyM+Ja4=; b=fgAZMLdV8dwmOIi6xrBE2/dwTjlq0RNleI0XMJgIliJwmL1pK+HYwrx8gPpsfOB4mT SgvIKF1Q0UGfJLLCv2LlA/sBKYUvOhWLTAi8MlSHzmW7CiuiEFX1JH/c8rVjr31on+SS xXSsbqImqF31wIJ/g7VUJSjNrr7nEGWTz1sLpw6+5qchbq7e3LPRmLGiLOHw+CcNLQg+ BUS5l8b73o8+4Qx2WHNHHgEiW12XdXSiNhWqwfWyJbf9D1rU+abH5BxJJ9oyeF/YQh3g SpbiPmjLEvUH5usob3RLNTuUqqV+gNTKdxosdzrhDDB7gfbbpGtfWjGLmgXBGOEeGaIF C+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729945084; x=1730549884; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fBcJl01TtjB1sQ+coZ3yEQeNcjr8kffC1BqiKyM+Ja4=; b=QHhmVrZG5i2rVpAFczWmnqQuJOnG56NnL3TNDkxqp1NQpIBuM4NbhgTdUZ2gaaoaP3 2KzG3Q+bJhkCupN1+uFVc3Nq7xdJzVKF9F3pu3PCxa2cxubGmzNwUYZ8PAUz5jb8RO25 SbqPn8E6YurvAhl+SvXm7VAE5FuoQzzKo9YHltEFngy8JzGS/KDg7WIjl8qX7BzTG11b kzEAfRFCiMyxW8cTJN5jhoCxEoEyixIKmqDHPrKHJMZjXUkyWRMPloYOrPyB9xA65oQo oJ1Anq0D9f99Aoe4H3IWXHW42hP9HuhAagFJKXRKaRrIXPdZwUxAlxPemx6A0ZmpMOY2 WgDA== X-Forwarded-Encrypted: i=1; AJvYcCWWlNb2oiFNvZKG6sI+sfMT/VnGO+OUKepXdbQ0oLBPXInSRjw2i+Xd5I0JOV9G37KIlKjgMcBFZMa4Xg==@lists.infradead.org X-Gm-Message-State: AOJu0Yx4CIkuUwfmd7yGw2V13/zMKhk3cBeSalWPZIh62acPAe1/NlxA RIi0tmvnR1WRWKWDspo4yr4/sm9TtTYCyeS3nUVUcTPYEEINxjCBMxBVYsAY8/K8g6cvAxTm3Z1 pUL7wxQ== X-Google-Smtp-Source: AGHT+IE9zYMgTwSHLGYlj300YfFrmvke8frEqe5oUqwbyU39/+jljEJ0ran0v7PIwH2GumKW+rj4eS6UlTFR X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:4bc4:f7cc:83b4:dece]) (user=irogers job=sendgmr) by 2002:a25:a207:0:b0:e25:6701:410b with SMTP id 3f1490d57ef6-e3087b792abmr5358276.5.1729945083545; Sat, 26 Oct 2024 05:18:03 -0700 (PDT) Date: Sat, 26 Oct 2024 05:17:54 -0700 Message-Id: <20241026121758.143259-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v1 0/4] Prefer sysfs/JSON events also when no PMU is provided From: Ian Rogers To: Atish Patra , linux-riscv@lists.infradead.org, beeman@rivosinc.com, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Ze Gao , Weilin Wang , Ben Gainey , Dominique Martinet , Junhao He , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241026_051805_732487_CB0DEAD2 X-CRM114-Status: GOOD ( 16.28 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org At the RISC-V summit the topic of avoiding event data being in the RISC-V PMU kernel driver came up. There is a preference for sysfs/JSON events being the priority when no PMU is provided so that legacy events maybe supported via json. Originally Mark Rutland also expressed at LPC 2023 that doing this would resolve bugs on ARM Apple M? processors, but James Clark more recently tested this and believes the driver issues there may not have existed or have been resolved. In any case, it is inconsistent that with a PMU event names avoid legacy encodings, but when wildcarding PMUs (ie without a PMU with the event name) the legacy encodings have priority. The patch doing this work was reverted in a v6.10 release candidate as, even though the patch was posted for weeks and had been on linux-next for weeks without issue, Linus was in the habit of using explicit legacy events with unsupported precision options on his Neoverse-N1. This machine has SLC PMU events for bus and CPU cycles where ARM decided to call the events bus_cycles and cycles, the latter being also a legacy event name. ARM haven't renamed the cycles event to a more consistent cpu_cycles and avoided the problem. With these changes the problematic event will now be skipped, a large warning produced, and perf record will continue for the other PMU events. This solution was proposed by Arnaldo. Two minor changes have been added to help with the error message and to work around issues occurring with "perf stat metrics (shadow stat) test". The patches have only been tested on my x86 non-hybrid laptop. Ian Rogers (4): perf evsel: Add pmu_name helper perf stat: Fix find_stat for mixed legacy/non-legacy events perf record: Skip don't fail for events that don't open perf parse-events: Reapply "Prefer sysfs/JSON hardware events over legacy" tools/perf/builtin-record.c | 22 +++++++--- tools/perf/util/evsel.c | 10 +++++ tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 26 +++++++++--- tools/perf/util/parse-events.l | 76 +++++++++++++++++----------------- tools/perf/util/parse-events.y | 60 ++++++++++++++++++--------- tools/perf/util/pmus.c | 20 +++++++-- tools/perf/util/stat-shadow.c | 3 +- 8 files changed, 145 insertions(+), 73 deletions(-) -- 2.47.0.163.g1226f6d8fa-goog _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv