Archive-only list for patches
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Namhyung Kim <namhyung@kernel.org>,
	Rob Herring <robh@kernel.org>, Leo Yan <leo.yan@linaro.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>, James Clark <james.clark@arm.com>,
	Jiri Olsa <jolsa@kernel.org>, Mark Rutland <mark.rutland@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.10 60/73] perf: Skip and warn on unknown format configN attrs
Date: Fri, 28 Oct 2022 14:03:57 +0200	[thread overview]
Message-ID: <20221028120234.990363295@linuxfoundation.org> (raw)
In-Reply-To: <20221028120232.344548477@linuxfoundation.org>

From: Rob Herring <robh@kernel.org>

[ Upstream commit e552b7be12ed62357df84392efa525ecb01910fb ]

If the kernel exposes a new perf_event_attr field in a format attr, perf
will return an error stating the specified PMU can't be found. For
example, a format attr with 'config3:0-63' causes an error as config3 is
unknown to perf. This causes a compatibility issue between a newer
kernel with older perf tool.

Before this change with a kernel adding 'config3' I get:

  $ perf record -e arm_spe// -- true
  event syntax error: 'arm_spe//'
                       \___ Cannot find PMU `arm_spe'. Missing kernel support?
  Run 'perf list' for a list of valid events

   Usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. use 'perf list' to list
  available events

After this change, I get:

  $ perf record -e arm_spe// -- true
  WARNING: 'arm_spe_0' format 'inv_event_filter' requires 'perf_event_attr::config3' which is not supported by this version of perf!
  [ perf record: Woken up 2 times to write data ]
  [ perf record: Captured and wrote 0.091 MB perf.data ]

To support unknown configN formats, rework the YACC implementation to
pass any config[0-9]+ format to perf_pmu__new_format() to handle with a
warning.

Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220914-arm-perf-tool-spe1-2-v2-v4-1-83c098e6212e@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/perf/util/parse-events.c |  3 +++
 tools/perf/util/pmu.c          | 17 +++++++++++++++++
 tools/perf/util/pmu.h          |  2 ++
 tools/perf/util/pmu.l          |  2 --
 tools/perf/util/pmu.y          | 15 ++++-----------
 5 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 36969fc8f1fc..c56a4d9c3be9 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -356,6 +356,9 @@ __add_event(struct list_head *list, int *idx,
 	struct perf_cpu_map *cpus = pmu ? perf_cpu_map__get(pmu->cpus) :
 			       cpu_list ? perf_cpu_map__new(cpu_list) : NULL;
 
+	if (pmu)
+		perf_pmu__warn_invalid_formats(pmu);
+
 	if (pmu && attr->type == PERF_TYPE_RAW)
 		perf_pmu__warn_invalid_config(pmu, attr->config, name);
 
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 349012f7defb..ac45da0302a7 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -862,6 +862,23 @@ static struct perf_pmu *pmu_lookup(const char *name)
 	return pmu;
 }
 
+void perf_pmu__warn_invalid_formats(struct perf_pmu *pmu)
+{
+	struct perf_pmu_format *format;
+
+	/* fake pmu doesn't have format list */
+	if (pmu == &perf_pmu__fake)
+		return;
+
+	list_for_each_entry(format, &pmu->format, list)
+		if (format->value >= PERF_PMU_FORMAT_VALUE_CONFIG_END) {
+			pr_warning("WARNING: '%s' format '%s' requires 'perf_event_attr::config%d'"
+				   "which is not supported by this version of perf!\n",
+				   pmu->name, format->name, format->value);
+			return;
+		}
+}
+
 static struct perf_pmu *pmu_find(const char *name)
 {
 	struct perf_pmu *pmu;
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index d9aa8c958d21..7d208b850769 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -15,6 +15,7 @@ enum {
 	PERF_PMU_FORMAT_VALUE_CONFIG,
 	PERF_PMU_FORMAT_VALUE_CONFIG1,
 	PERF_PMU_FORMAT_VALUE_CONFIG2,
+	PERF_PMU_FORMAT_VALUE_CONFIG_END,
 };
 
 #define PERF_PMU_FORMAT_BITS 64
@@ -122,5 +123,6 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu);
 
 void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
 				   char *name);
+void perf_pmu__warn_invalid_formats(struct perf_pmu *pmu);
 
 #endif /* __PMU_H */
diff --git a/tools/perf/util/pmu.l b/tools/perf/util/pmu.l
index a15d9fbd7c0e..58b4926cfaca 100644
--- a/tools/perf/util/pmu.l
+++ b/tools/perf/util/pmu.l
@@ -27,8 +27,6 @@ num_dec         [0-9]+
 
 {num_dec}	{ return value(10); }
 config		{ return PP_CONFIG; }
-config1		{ return PP_CONFIG1; }
-config2		{ return PP_CONFIG2; }
 -		{ return '-'; }
 :		{ return ':'; }
 ,		{ return ','; }
diff --git a/tools/perf/util/pmu.y b/tools/perf/util/pmu.y
index bfd7e8509869..283efe059819 100644
--- a/tools/perf/util/pmu.y
+++ b/tools/perf/util/pmu.y
@@ -20,7 +20,7 @@ do { \
 
 %}
 
-%token PP_CONFIG PP_CONFIG1 PP_CONFIG2
+%token PP_CONFIG
 %token PP_VALUE PP_ERROR
 %type <num> PP_VALUE
 %type <bits> bit_term
@@ -47,18 +47,11 @@ PP_CONFIG ':' bits
 				      $3));
 }
 |
-PP_CONFIG1 ':' bits
+PP_CONFIG PP_VALUE ':' bits
 {
 	ABORT_ON(perf_pmu__new_format(format, name,
-				      PERF_PMU_FORMAT_VALUE_CONFIG1,
-				      $3));
-}
-|
-PP_CONFIG2 ':' bits
-{
-	ABORT_ON(perf_pmu__new_format(format, name,
-				      PERF_PMU_FORMAT_VALUE_CONFIG2,
-				      $3));
+				      $2,
+				      $4));
 }
 
 bits:
-- 
2.35.1




  parent reply	other threads:[~2022-10-28 12:06 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 12:02 [PATCH 5.10 00/73] 5.10.152-rc1 review Greg Kroah-Hartman
2022-10-28 12:02 ` [PATCH 5.10 01/73] ocfs2: clear dinode links count in case of error Greg Kroah-Hartman
2022-10-28 12:02 ` [PATCH 5.10 02/73] ocfs2: fix BUG when iput after ocfs2_mknod fails Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 03/73] selinux: enable use of both GFP_KERNEL and GFP_ATOMIC in convert_context() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 04/73] cpufreq: qcom: fix writes in read-only memory region Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 05/73] i2c: qcom-cci: Fix ordering of pm_runtime_xx and i2c_add_adapter Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 06/73] x86/microcode/AMD: Apply the patch early on every logical thread Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 07/73] hwmon/coretemp: Handle large core ID value Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 08/73] ata: ahci-imx: Fix MODULE_ALIAS Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 09/73] ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 10/73] cpufreq: qcom: fix memory leak in error path Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 11/73] kvm: Add support for arch compat vm ioctls Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 12/73] KVM: arm64: vgic: Fix exit condition in scan_its_table() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 13/73] media: mceusb: set timeout to at least timeout provided Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 14/73] media: venus: dec: Handle the case where find_format fails Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 15/73] block: wbt: Remove unnecessary invoking of wbt_update_limits in wbt_init Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 16/73] blk-wbt: call rq_qos_add() after wb_normal is initialized Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 17/73] arm64: errata: Remove AES hwcap for COMPAT tasks Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 18/73] r8152: add PID for the Lenovo OneLink+ Dock Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 19/73] btrfs: fix processing of delayed data refs during backref walking Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 20/73] btrfs: fix processing of delayed tree block " Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 21/73] ACPI: extlog: Handle multiple records Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 22/73] tipc: Fix recognition of trial period Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 23/73] tipc: fix an information leak in tipc_topsrv_kern_subscr Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 24/73] i40e: Fix DMA mappings leak Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 25/73] HID: magicmouse: Do not set BTN_MOUSE on double report Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 26/73] sfc: Change VF mac via PF as first preference if available Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 27/73] net/atm: fix proc_mpc_write incorrect return value Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 28/73] net: phy: dp83867: Extend RX strap quirk for SGMII mode Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 29/73] tcp: Add num_closed_socks to struct sock_reuseport Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 30/73] udp: Update reuse->has_conns under reuseport_lock Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 31/73] cifs: Fix xid leak in cifs_copy_file_range() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 32/73] cifs: Fix xid leak in cifs_flock() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 33/73] cifs: Fix xid leak in cifs_ses_add_channel() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 34/73] net: hsr: avoid possible NULL deref in skb_clone() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 35/73] ionic: catch NULL pointer issue on reconfig Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 36/73] nvme-hwmon: rework to avoid devm allocation Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 37/73] nvme-hwmon: Return error code when registration fails Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 38/73] nvme-hwmon: consistently ignore errors from nvme_hwmon_init Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 39/73] nvme-hwmon: kmalloc the NVME SMART log buffer Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 40/73] net: sched: cake: fix null pointer access issue when cake_init() fails Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 41/73] net: sched: delete duplicate cleanup of backlog and qlen Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 42/73] net: sched: sfb: fix null pointer access issue when sfb_init() fails Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 43/73] sfc: include vport_id in filter spec hash and equal() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 44/73] net: hns: fix possible memory leak in hnae_ae_register() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 45/73] net: sched: fix race condition in qdisc_graft() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 46/73] net: phy: dp83822: disable MDI crossover status change interrupt Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 47/73] iommu/vt-d: Allow NVS regions in arch_rmrr_sanity_check() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 48/73] iommu/vt-d: Clean up si_domain in the init_dmars() error path Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 49/73] drm/virtio: Use appropriate atomic state in virtio_gpu_plane_cleanup_fb() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 50/73] dmaengine: mxs-dma: Remove the unused .id_table Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 51/73] dmaengine: mxs: use platform_driver_register Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 52/73] tracing: Simplify conditional compilation code in tracing_set_tracer() Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 53/73] tracing: Do not free snapshot if tracer is on cmdline Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 54/73] xen: assume XENFEAT_gnttab_map_avail_bits being set for pv guests Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 55/73] xen/gntdev: Accommodate VMA splitting Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 56/73] mmc: sdhci-tegra: Use actual clock rate for SW tuning correction Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 57/73] riscv: Add machine name to kernel boot log and stack dump output Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 58/73] riscv: always honor the CONFIG_CMDLINE_FORCE when parsing dtb Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 59/73] perf pmu: Validate raw event with sysfs exported format bits Greg Kroah-Hartman
2022-10-28 12:03 ` Greg Kroah-Hartman [this message]
2022-10-28 12:03 ` [PATCH 5.10 61/73] fcntl: make F_GETOWN(EX) return 0 on dead owner task Greg Kroah-Hartman
2022-10-28 12:03 ` [PATCH 5.10 62/73] fcntl: fix potential deadlocks for &fown_struct.lock Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 63/73] arm64: dts: qcom: sc7180-trogdor: Fixup modem memory region Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 64/73] arm64: topology: move store_cpu_topology() to shared code Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 65/73] riscv: topology: fix default topology reporting Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 66/73] perf/x86/intel/pt: Relax address filter validation Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 67/73] hv_netvsc: Fix race between VF offering and VF association message from host Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 68/73] [PATCH v3] ACPI: video: Force backlight native for more TongFang devices Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 69/73] x86/Kconfig: Drop check for -mabi=ms for CONFIG_EFI_STUB Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 70/73] Makefile.debug: re-enable debug info for .S files Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 71/73] mmc: core: Add SD card quirk for broken discard Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 72/73] blk-wbt: fix that rwb->wc is always set to 1 in wbt_init() Greg Kroah-Hartman
2022-10-28 12:04 ` [PATCH 5.10 73/73] mm: /proc/pid/smaps_rollup: fix no vmas null-deref Greg Kroah-Hartman
2022-10-28 13:55 ` [PATCH 5.10 00/73] 5.10.152-rc1 review Rudi Heitbaum
2022-10-28 17:14 ` Pavel Machek
2022-10-28 19:44 ` Sudip Mukherjee (Codethink)
2022-10-28 20:55 ` Florian Fainelli
2022-10-29  3:35 ` Guenter Roeck
2022-10-29  6:55 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221028120234.990363295@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox