From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 7CFF613D531 for ; Sat, 21 Dec 2024 19:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734809221; cv=none; b=FpnvYrPnmuIFzEPL1aZaouNHHsn6JBL3yquDNl23ev2HquVbkWv2d8UgRfQnGcDedBW0l2UnBuFNWV9q4JJBS3o2QN4ILbtso+r8RqYHnJy/ToqeLKtfKvCIF7+4lx9oKSO+EsiP/fBEOiwPnfUuNRKMId2c5h+0MFsn0XZzeLM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734809221; c=relaxed/simple; bh=CYhbP77Y+itdUk9EZRAHbUqOOAzcfzJ5Z6fc96Q2VVY=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=ofzamEhf4mrLjEnRnvp+z7kbIpBZgVfRO1vbls3n+qsTp7wr/wAodSs0eExetS5KZ4rmjcz1S5gLDIPI2HDUf0zojaxo61IuALsMSImzKcUJaD9YL58V81vO4YD6av0ENXMbu42n4dHYzCp6z63BTnHgzrHPr2smMi617WK+MIQ= 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=duvjJAKM; arc=none smtp.client-ip=209.85.128.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="duvjJAKM" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6f2bdb560ecso37356317b3.1 for ; Sat, 21 Dec 2024 11:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734809218; x=1735414018; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=khbaf3YPAMV9CfglLchWYjPoJjw6OVX8mcR2dtFxUQs=; b=duvjJAKMAkFPP1NGKT7xZBCbLR866WvazlZE6pwjDxP06WiaLVCI/YUUEo2BMiqzJg AiFDjvNpE/6v7EOthlyIHhDb3B0BbYx2HUHX+tFJ0nwmqvCAXZ7fWoxjWuXnKOdsTXkb MgwDor7YLBhdZ6DFPiRuWbieLNM6W/HMtd47AxL7qvbMJJoR+Rz61sUNBgoNoSoFAoGr WKg9PMCdoSPO3mJ0AXQBG9MbfljBcAx7M+x9ic1ZHkOOGfnaNB8bWRxqTJ9xa9GiKST2 hq9J2P6nAoNh3OELqMt1KW3UGwEe51KBEZQ1QBtnKF9gdofvXa9E538lTgVlTOb4B/7o k8cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734809218; x=1735414018; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=khbaf3YPAMV9CfglLchWYjPoJjw6OVX8mcR2dtFxUQs=; b=gaBdHdYk7Dx6gFv4e/CwrUjdRBrNaEQUyYLRW42278wClOQbdotpl55/B0MGEVvE+X OrxJCoR7zC9+XgoqUZLaNJA+syU3xT4YNJCNfeQc/Joo1AMP0IxgaTtgdBCD9we/fuUW pYOb3ujZp+NMdJW2qvRrPWnn4kTKq6qDrzjzeXfSTxDKUpmTmjiuQe9CAjoCX8UF6ycz yFz8g4FWDtDlOushqyfOTnO1FGV1GqCI5RrpvkJePlv03c7aKIcOCvHATYN104qfstGu skDhgHwKti69B4OKcTM8YizalYActcTjf2EXodFXF8i6A4MHRTKiLxU69SFHkmr6m69n bA7w== X-Forwarded-Encrypted: i=1; AJvYcCUY53QgBoTvvOvffUaPEd6P7kUSzM+O4IWLnXSR6AwBahSLLn3tMqQK+Dh8Rv3bvFbjnVXtQDLaYZeVUS0=@vger.kernel.org X-Gm-Message-State: AOJu0YxNop1cA+a5vs/7PC+i8QmjEQTTo/OENbFr8qWdDckNK1zW9K6y 2RuxTdamwPhunPOwXGwW01mo+2NajiAFTSyA5nmIPsOxWjNtHEaS1hmHySjMWHD3hxi1wfRefwY wxfhCCg== X-Google-Smtp-Source: AGHT+IEUPVSq8lBgYTPQFcTqPnjauWVaFibsYrI1AVzY9v9JhHQtrgLP0tfvy5Nuebxp1GkuuHWp20EUvSdz X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:a2bc:ec03:1143:41ab]) (user=irogers job=sendgmr) by 2002:a05:690c:2502:b0:6ef:7372:10f8 with SMTP id 00721157ae682-6f3f822b63emr238087b3.5.1734809218491; Sat, 21 Dec 2024 11:26:58 -0800 (PST) Date: Sat, 21 Dec 2024 11:26:50 -0800 Message-Id: <20241221192654.94344-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Subject: [PATCH v3 0/4] Prefer sysfs/JSON events also when no PMU is provided From: Ian Rogers To: 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 , Dominique Martinet , Jean-Philippe Romain , Junhao He , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Aditya Bodkhe 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. v3: Make no events opening for perf record a failure as suggested by James Clark and Aditya Bodkhe . Also, rebase. v2: Rebase and add tested-by tags from James Clark, Leo Yan and Atish Patra who have tested on RISC-V and ARM CPUs, including the problem case from before. 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 | 34 ++++++++++++--- 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, 156 insertions(+), 74 deletions(-) -- 2.47.1.613.gc27f4b7a9f-goog