Sure, I will update this in the next version.
On 16/09/2024 17:47, Ravi Bangoria wrote:
From: Swapnil Sapkal <swapnil.sapkal@xxxxxxx>
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@xxxxxxx>
Co-developed-by: Ravi Bangoria <ravi.bangoria@xxxxxxx>
Signed-off-by: Ravi Bangoria <ravi.bangoria@xxxxxxx>
---
[...]
+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.