From: Thomas Richter <tmricht@linux.ibm.com>
To: linux-s390@vger.kernel.org, sumanthk@linux.ibm.com, japo@linux.ibm.com
Cc: agordeev@linux.ibm.com, iii@linux.ibm.com, hca@linux.ibm.com,
Thomas Richter <tmricht@linux.ibm.com>
Subject: [PATCH] perf header: Fix HEADER_CPU_DOMAIN_INFO feature
Date: Fri, 11 Sep 2026 11:41:29 +0200 [thread overview]
Message-ID: <20260911094129.2032815-1-tmricht@linux.ibm.com> (raw)
commit d40c68a49f69 ("perf header: Support CPU DOMAIN relation info")
introduced the HEADER_CPU_DOMAIN_INFO feature and the necessary data
into the perf.data file.
The documentation differs from the data actually written by
write_cpu_domain_info(). The first two values written to the header
section are schedstat_version and max_sched_domains. They are missing
in the documentation. Add them to the documentation.
Also structure cpu_domain_info actually contains an array of
struct domain_info. It is very important for the reader to know
how many array elements have been written to that file section,
especially when the member domain_info::dname is optional and
only present when schedstat_version >= 17.
Add the number of CPUs which have been saved into that file section
so the reader knows in advance how many array elements to read.
This is also in sync with other perf.data file sections which always
have the number of elements before the array data.
Fixes: d40c68a49f69 ("perf header: Support CPU DOMAIN relation info")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
# Cc: Swapnil Sapkal <swapnil.sapkal@amd.com>
---
tools/perf/Documentation/perf.data-file-format.txt | 11 +++++++++--
| 11 ++++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt
index b90cba9168f8..e37f7484487b 100644
--- a/tools/perf/Documentation/perf.data-file-format.txt
+++ b/tools/perf/Documentation/perf.data-file-format.txt
@@ -453,7 +453,7 @@ List of cpu-domain relation info. The format of the data is as below.
struct domain_info {
int domain;
- char dname[];
+ char dname[]; if schedstat_version >= 17
char cpumask[];
char cpulist[];
};
@@ -461,7 +461,14 @@ struct domain_info {
struct cpu_domain_info {
int cpu;
int nr_domains;
- struct domain_info domains[];
++ int schedstat_version;
++ int max_sched_domains;
++ int nr_cpus;
++ struct {
++ int cpu;
++ int nr_domains;
++ struct domain_info domains[nr_domains];
++ } [nr_cpus]
};
HEADER_E_MACHINE = 33,
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 7db7da090a1e..770fd21eb1a5 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1836,7 +1836,7 @@ struct cpu_domain_map **build_cpu_domain_map(u32 *schedstat_version, u32 *max_sc
static int write_cpu_domain_info(struct feat_fd *ff,
struct evlist *evlist __maybe_unused)
{
- u32 max_sched_domains = 0, schedstat_version = 0;
+ u32 max_sched_domains = 0, schedstat_version = 0, nr_cpus = 0;
struct cpu_domain_map **cd_map;
u32 i, j, nr, ret;
@@ -1855,6 +1855,15 @@ static int write_cpu_domain_info(struct feat_fd *ff,
if (ret < 0)
goto out;
+ for (i = 0; i < nr; i++) {
+ if (!cd_map[i])
+ continue;
+ ++nr_cpus;
+ }
+ ret = do_write(ff, &nr_cpus, sizeof(u32));
+ if (ret < 0)
+ goto out;
+
for (i = 0; i < nr; i++) {
if (!cd_map[i])
continue;
--
2.55.0
next reply other threads:[~2026-09-11 9:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 9:41 Thomas Richter [this message]
2026-09-11 9:52 ` [PATCH] perf header: Fix HEADER_CPU_DOMAIN_INFO feature sashiko-bot
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=20260911094129.2032815-1-tmricht@linux.ibm.com \
--to=tmricht@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=japo@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sumanthk@linux.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.