From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 989102C2349 for ; Mon, 18 May 2026 17:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779126147; cv=none; b=t7qiBUotROJuooS9sRtmcGBRro0lPhpWraCUQP8yshN92NxIrOXlYwX+7Rr4aYq36r1Whw1jZQmXpe/YpSICDhWjPiZbiZ+W4/KVUyq2ULDt2VdDJ9cVSm3Q5k+2Crkr5CPq0DShh0Y2eRLxz/uyVXwLNm4fMxl11gBbF10FOY0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779126147; c=relaxed/simple; bh=qXp7CseHYV8iqbeq1vkUrT4f4UESvv3dJP7LpI5MZ5I=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=kLFpwAaCZHOFF6d498uH/edhIo5bpNMg7jSsqV+j9BRKsZfOInWEOxlMQch+wJ4BPb7tqrGXygCySff6ifatVqPj8RuXdVVP/IM1Ozqwa6LzYsaXiC0bv4uTs4Fp0ggGjlfJJSkax2q9+TVdlCNg/FLv0D1+F6hU1v35K54Wgq4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ctshao.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sSh+Dfcj; arc=none smtp.client-ip=74.125.82.74 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--ctshao.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sSh+Dfcj" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-13537722193so10297407c88.0 for ; Mon, 18 May 2026 10:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779126146; x=1779730946; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ArPDPsXqWxv2tWUpgQ+9DRcdJT82uTP9KMMeLvxS2Qk=; b=sSh+DfcjCnn0ap95m4mRnDIZanGWywxVTiSleqX2KOxfrdfPHfSy+qppY5SryL9/lS YbB+vccucjJ3x9kfvB+OLY9LMo++9WW6e+VFdnW0H+kf6dQ3RTUzfJp0mzDeBNdEdEO3 uyqs9JKQRT3TRwnhxbdEoTsRpQvTzyEU66R2BDxKgvKkLiuRhv7zZnkbSTAC/tu0fdpx IBH/lWCWNlWElLufgyK4TxVeLYcAjddX1KQI8Do9wh37EOnHBLUgHmMgqOLGsgWpfgU6 dmG70xkCMAki0+bSJacwWBZOS+nb1C9433MKR7No8mZtiPGvjLSkni8UlpSDN103jNgP 4VqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779126146; x=1779730946; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ArPDPsXqWxv2tWUpgQ+9DRcdJT82uTP9KMMeLvxS2Qk=; b=ZFvQY/h6lx2qaIGl+E7BKj7phxtPzj7P4Exjr/BDXXtGoJj+EboEXF6uPZct2cwR7x aC/spwIOSCqReQd1UoPgkEbcJqNnbMBzu7tBucc1DKLspxVuJ9yixJA/X8pRut9dh4iZ 0qbylBj6USm4+5G5W+uXLyH+hSTQf8d4eGwXQ0gn/MvWGL0rFNdm165UwZS+stbNBywH Zpffr4bIws/yLQizmBE0GwZ4WVMfVEyxGv6EXtwI/1KHH/rNbO6zxrVzd8DenmaJuwOM 7VJSON+O+99Thlhdk5qmyDnS2I/giR5Ope0WVkIpQ9VCgIFixfYvkaPOPGyR9WB9s1gf AeQQ== X-Gm-Message-State: AOJu0YyZh4dORXkzxKZog0JpszuZ4fKagEwXbaKzSEnYhyTsgWRVa0u3 Nzr/YZBUJeEwf/TKRJ6oLzoK9g65vszJJyp6qGxWVb3B4IkfkqaxmA8gdxnJEbcUNrbyM9oM3AC A4qEr9mcQQ8MjuyN6Y/ApDJVyC+PUWm/4lulspqNkPX04D98+amSp8rN+Z5H1sgm4qobjmxtIR5 JuveBID19Cdo9mLGFRkR3q/OMgm1rlgo4NMdP4s5G9TrAe X-Received: from dlaf25.prod.google.com ([2002:a05:701b:2419:b0:134:e337:a5ef]) (user=ctshao job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:922:b0:12a:6902:ddb8 with SMTP id a92af1059eb24-13504313d47mr7218841c88.4.1779126145365; Mon, 18 May 2026 10:42:25 -0700 (PDT) Date: Mon, 18 May 2026 10:41:22 -0700 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.54.0.746.g67dd491aae-goog Message-ID: <20260518174159.1177549-1-ctshao@google.com> Subject: [PATCH v6 1/2] perf: Reveal PMU type in fdinfo From: Chun-Tse Shao To: linux-kernel@vger.kernel.org Cc: Chun-Tse Shao , Ian Rogers , peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, adrian.hunter@intel.com, james.clark@linaro.org, thomas.falcon@intel.com, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" It gives useful info on knowing which PMUs are reserved by this process. Also add config which would be useful. Testing cycles: $ ./perf stat -e cycles & $ cat /proc/`pidof perf`/fdinfo/3 pos: 0 flags: 02000002 mnt_id: 16 ino: 3081 perf_event_attr.type: 0 perf_event_attr.config: 0x0 perf_event_attr.config1: 0x0 perf_event_attr.config2: 0x0 perf_event_attr.config3: 0x0 Testing L1-dcache-load-misses: $ ./perf stat -e L1-dcache-load-misses & $ cat /proc/`pidof perf`/fdinfo/3 pos: 0 flags: 02000002 mnt_id: 16 ino: 1072 perf_event_attr.type: 3 perf_event_attr.config: 0x10000 perf_event_attr.config1: 0x0 perf_event_attr.config2: 0x0 perf_event_attr.config3: 0x0 Reviewed-by: Ian Rogers Signed-off-by: Chun-Tse Shao --- v6: Rebase. v5: lore.kernel.org/20251121230951.3240124-1-ctshao@google.com/ Added config1, config2 and config3 and print output in hex. v4: lore.kernel.org/20250603181634.1362626-1-ctshao@google.com/ Removed the first patch in v3 since it is merged. Retested to make sure the patch still work. v3: lore.kernel.org/20241106003007.2112584-3-ctshao@google.com/ kernel/events/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 6d1f8bad7e1c..d88947e9f774 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -58,6 +58,7 @@ #include #include #include +#include #include "internal.h" @@ -7506,6 +7507,20 @@ static int perf_fasync(int fd, struct file *filp, int on) return 0; } +static void perf_show_fdinfo(struct seq_file *m, struct file *f) +{ + struct perf_event *event = f->private_data; + + seq_printf(m, "perf_event_attr.type:\t%u\n", event->orig_type); + seq_printf(m, "perf_event_attr.config:\t0x%llx\n", (unsigned long long)event->attr.config); + seq_printf(m, "perf_event_attr.config1:\t0x%llx\n", + (unsigned long long)event->attr.config1); + seq_printf(m, "perf_event_attr.config2:\t0x%llx\n", + (unsigned long long)event->attr.config2); + seq_printf(m, "perf_event_attr.config3:\t0x%llx\n", + (unsigned long long)event->attr.config3); +} + static const struct file_operations perf_fops = { .release = perf_release, .read = perf_read, @@ -7514,6 +7529,7 @@ static const struct file_operations perf_fops = { .compat_ioctl = perf_compat_ioctl, .mmap = perf_mmap, .fasync = perf_fasync, + .show_fdinfo = perf_show_fdinfo, }; /* -- 2.54.0.746.g67dd491aae-goog