* [PATCH] perf mem: Fix -C option behavior for perf mem record
@ 2022-10-04 20:02 Namhyung Kim
2022-10-06 6:01 ` Leo Yan
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2022-10-04 20:02 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jiri Olsa
Cc: Ingo Molnar, Peter Zijlstra, LKML, Ian Rogers, Adrian Hunter,
linux-perf-users, Kan Liang, Leo Yan, Ravi Bangoria
The -C/--cpu option was maily for report but it also affected record as
it ate the option. So users needed to use "--" after perf mem record to
pass the info to the perf record properly.
Check if this option is set for record, and pass it to the actual perf
record.
Before)
$ sudo perf --debug perf-event-open mem record -C 0 2>&1 | grep -a sys_perf_event_open
...
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 4
sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 = 5
sys_perf_event_open: pid -1 cpu 2 group_fd -1 flags 0x8 = 6
sys_perf_event_open: pid -1 cpu 3 group_fd -1 flags 0x8 = 7
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 8
sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 = 9
sys_perf_event_open: pid -1 cpu 2 group_fd -1 flags 0x8 = 10
sys_perf_event_open: pid -1 cpu 3 group_fd -1 flags 0x8 = 11
...
After)
$ sudo perf --debug perf-event-open mem record -C 0 2>&1 | grep -a sys_perf_event_open
...
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 4
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 5
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 6
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 7
Cc: Leo Yan <leo.yan@linaro.org>
Reported-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-mem.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 9e435fd23503..02e7a5dbeb00 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -97,6 +97,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
else
rec_argc = argc + 9 * perf_pmu__hybrid_pmu_num();
+ if (mem->cpu_list)
+ rec_argc += 2;
+
rec_argv = calloc(rec_argc + 1, sizeof(char *));
if (!rec_argv)
return -1;
@@ -158,6 +161,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
if (all_kernel)
rec_argv[i++] = "--all-kernel";
+ if (mem->cpu_list) {
+ rec_argv[i++] = "-C";
+ rec_argv[i++] = mem->cpu_list;
+ }
+
for (j = 0; j < argc; j++, i++)
rec_argv[i] = argv[j];
--
2.38.0.rc1.362.ged0d419d3c-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf mem: Fix -C option behavior for perf mem record
2022-10-04 20:02 [PATCH] perf mem: Fix -C option behavior for perf mem record Namhyung Kim
@ 2022-10-06 6:01 ` Leo Yan
2022-10-14 15:20 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Leo Yan @ 2022-10-06 6:01 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
LKML, Ian Rogers, Adrian Hunter, linux-perf-users, Kan Liang,
Ravi Bangoria
On Tue, Oct 04, 2022 at 01:02:11PM -0700, Namhyung Kim wrote:
> The -C/--cpu option was maily for report but it also affected record as
> it ate the option. So users needed to use "--" after perf mem record to
> pass the info to the perf record properly.
>
> Check if this option is set for record, and pass it to the actual perf
> record.
>
> Before)
> $ sudo perf --debug perf-event-open mem record -C 0 2>&1 | grep -a sys_perf_event_open
> ...
> sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 4
> sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 = 5
> sys_perf_event_open: pid -1 cpu 2 group_fd -1 flags 0x8 = 6
> sys_perf_event_open: pid -1 cpu 3 group_fd -1 flags 0x8 = 7
> sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 8
> sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 = 9
> sys_perf_event_open: pid -1 cpu 2 group_fd -1 flags 0x8 = 10
> sys_perf_event_open: pid -1 cpu 3 group_fd -1 flags 0x8 = 11
> ...
>
> After)
> $ sudo perf --debug perf-event-open mem record -C 0 2>&1 | grep -a sys_perf_event_open
> ...
> sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 4
> sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 5
> sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 6
> sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 7
>
> Cc: Leo Yan <leo.yan@linaro.org>
> Reported-by: Ravi Bangoria <ravi.bangoria@amd.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
The change LGTM:
Reviewed-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf mem: Fix -C option behavior for perf mem record
2022-10-06 6:01 ` Leo Yan
@ 2022-10-14 15:20 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-10-14 15:20 UTC (permalink / raw)
To: Leo Yan
Cc: Namhyung Kim, Jiri Olsa, Ingo Molnar, Peter Zijlstra, LKML,
Ian Rogers, Adrian Hunter, linux-perf-users, Kan Liang,
Ravi Bangoria
Em Thu, Oct 06, 2022 at 02:01:54PM +0800, Leo Yan escreveu:
> On Tue, Oct 04, 2022 at 01:02:11PM -0700, Namhyung Kim wrote:
> > The -C/--cpu option was maily for report but it also affected record as
> > it ate the option. So users needed to use "--" after perf mem record to
> > pass the info to the perf record properly.
> >
> > Check if this option is set for record, and pass it to the actual perf
> > record.
> >
> > Before)
> > $ sudo perf --debug perf-event-open mem record -C 0 2>&1 | grep -a sys_perf_event_open
> > ...
> > sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 4
> > sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 = 5
> > sys_perf_event_open: pid -1 cpu 2 group_fd -1 flags 0x8 = 6
> > sys_perf_event_open: pid -1 cpu 3 group_fd -1 flags 0x8 = 7
> > sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 8
> > sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 = 9
> > sys_perf_event_open: pid -1 cpu 2 group_fd -1 flags 0x8 = 10
> > sys_perf_event_open: pid -1 cpu 3 group_fd -1 flags 0x8 = 11
> > ...
> >
> > After)
> > $ sudo perf --debug perf-event-open mem record -C 0 2>&1 | grep -a sys_perf_event_open
> > ...
> > sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 4
> > sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 5
> > sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 6
> > sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 7
> >
> > Cc: Leo Yan <leo.yan@linaro.org>
> > Reported-by: Ravi Bangoria <ravi.bangoria@amd.com>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>
> The change LGTM:
>
> Reviewed-by: Leo Yan <leo.yan@linaro.org>
> Tested-by: Leo Yan <leo.yan@linaro.org>
Thanks, applied.
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-14 15:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-04 20:02 [PATCH] perf mem: Fix -C option behavior for perf mem record Namhyung Kim
2022-10-06 6:01 ` Leo Yan
2022-10-14 15:20 ` Arnaldo Carvalho de Melo
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.