From: Ilkka Koskinen <ilkka@os.amperecomputing.com>
To: James Clark <james.clark@arm.com>
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCH v2] perf data convert: Fix segfault when converting to json on arm64
Date: Wed, 17 Jan 2024 13:38:37 -0800 (PST) [thread overview]
Message-ID: <afa5f15-1898-3731-c275-397e41b3c8f3@os.amperecomputing.com> (raw)
In-Reply-To: <19913e91-b055-d767-2cb8-c6bc53671728@arm.com>
On Wed, 17 Jan 2024, James Clark wrote:
>
>
> On 17/01/2024 07:13, Ilkka Koskinen wrote:
>> Arm64 doesn't have Model in /proc/cpuinfo and, thus, cpu_desc doesn't get
>> assigned.
>>
>> Running
>> $ perf data convert --to-json perf.data.json
>>
>> ends up calling output_json_string() with NULL pointer, which causes a
>> segmentation fault.
>>
>> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
>> ---
>> v1:
>> - https://lore.kernel.org/all/20240111232923.8138-1-ilkka@os.amperecomputing.com/
>> v2:
>> - Changed the patch based on James's comments.
>> ---
>> tools/perf/util/data-convert-json.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c
>> index 5bb3c2ba95ca..e8b006c3581f 100644
>> --- a/tools/perf/util/data-convert-json.c
>> +++ b/tools/perf/util/data-convert-json.c
>> @@ -284,7 +284,13 @@ static void output_headers(struct perf_session *session, struct convert_json *c)
>> output_json_key_string(out, true, 2, "os-release", header->env.os_release);
>> output_json_key_string(out, true, 2, "arch", header->env.arch);
>>
>> +#if !defined(__aarch64__)
>
> I think this needs to read from header->env.arch, otherwise it won't
> work if you run data convert on another machine.
>
> I'm assuming that perf data convert is one of the commands that runs on
> a pre-recorded file, rather than a command that creates the perf.data
> file to begin with?
Oh, right. I'll fix it right away.
Cheers, Ilkka
>
>> + /*
>> + * arm64 doesn't have Model section in /proc/cpuinfo and, thus, cpu-desc
>> + * is not set.
>> + */
>> output_json_key_string(out, true, 2, "cpu-desc", header->env.cpu_desc);
>> +#endif
>> output_json_key_string(out, true, 2, "cpuid", header->env.cpuid);
>> output_json_key_format(out, true, 2, "nrcpus-online", "%u", header->env.nr_cpus_online);
>> output_json_key_format(out, true, 2, "nrcpus-avail", "%u", header->env.nr_cpus_avail);
>
prev parent reply other threads:[~2024-01-17 21:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 7:13 Ilkka Koskinen
2024-01-17 15:30 ` James Clark
2024-01-17 21:38 ` Ilkka Koskinen [this message]
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=afa5f15-1898-3731-c275-397e41b3c8f3@os.amperecomputing.com \
--to=ilkka@os.amperecomputing.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®