[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <95e39d9c-7f0e-447b-9b2d-aab5d36b933a@linaro.org>
Date: Tue, 17 Sep 2024 11:35:08 +0100
From: James Clark <james.clark@...aro.org>
To: Ravi Bangoria <ravi.bangoria@....com>, swapnil.sapkal@....com
Cc: yu.c.chen@...el.com, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org, rostedt@...dmis.org,
vincent.guittot@...aro.org, bristot@...hat.com, adrian.hunter@...el.com,
james.clark@....com, kan.liang@...ux.intel.com, gautham.shenoy@....com,
kprateek.nayak@....com, juri.lelli@...hat.com, yangjihong@...edance.com,
void@...ifault.com, tj@...nel.org, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, santosh.shukla@....com,
ananth.narayan@....com, sandipan.das@....com, peterz@...radead.org,
mingo@...hat.com, acme@...nel.org, namhyung@...nel.org, irogers@...gle.com
Subject: Re: [PATCH 2/5] perf sched stats: Add record and rawdump support
On 16/09/2024 17:47, Ravi Bangoria wrote:
> From: Swapnil Sapkal <swapnil.sapkal@....com>
>
> Define new, perf tool only, sample types and their layouts. Add logic
> to parse /proc/schedstat, convert it to perf sample format and save
> samples to perf.data file with `perf sched stats record` command. Also
> add logic to read perf.data file, interpret schedstat samples and
> print rawdump of samples with `perf script -D`.
>
> Note that, /proc/schedstat file output is standardized with version
> number. The patch supports v15 but older or newer version can be added
> easily.
>
> Signed-off-by: Swapnil Sapkal <swapnil.sapkal@....com>
> Co-developed-by: Ravi Bangoria <ravi.bangoria@....com>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@....com>
> ---
[...]
> +int perf_event__synthesize_schedstat(const struct perf_tool *tool,
> + perf_event__handler_t process,
> + struct perf_cpu_map *user_requested_cpus)
> +{
> + union perf_event *event = NULL;
> + size_t line_len = 0;
> + char *line = NULL;
> + char bf[BUFSIZ];
> + __u64 timestamp;
> + __u16 version;
> + struct io io;
> + int ret = -1;
> + int cpu = -1;
> + char ch;
> +
> + io.fd = open("/proc/schedstat", O_RDONLY, 0);
Other parts of the tool use procfs__mountpoint() for /proc. Although it
can only be in one place so it doesn't actually make a difference for
this one. Probably worth it for consistency though.
> + if (io.fd < 0) {
> + pr_err("Failed to open /proc/schedstat\n");
A hint about CONFIG_SCHEDSTAT would be useful here.
Powered by blists - more mailing lists