perf tools: fix: Force backward ring buffer mapped readonly
PATCH 1/1 perf tools: fix: Force backward ring buffer mapped readonly
perf record's --overwrite option doesn't work as we expect. For example:
$ ~/linux/tools/perf$ sudo rm ./perf.data*
rm: cannot remove './perf.data*': No such file or directory
: ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g --overwrite \
--switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump perf.data.2017101221460002 ]
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump perf.data.2017101221460102 ]
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump perf.data.2017101221460202 ]
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump perf.data.2017101221460302 ]
^C[ perf record: Woken up 1 times to write data ]
2066346+0 records in
2066346+0 records out
1057969152 bytes (1.1 GB, 1009 MiB) copied, 4.25983 s, 248 MB/s
[ perf record: Dump perf.data.2017101221460332 ]
[ perf record: Captured and wrote 0.034 MB perf.data.<timestamp> ] $ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221460002 | head -n 1
dd 3918 [006] 182589.668954: raw_syscalls:sys_exit: NR 59 = 0
$ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221460102 | head -n 1
dd 3918 [006] 182589.668954: raw_syscalls:sys_exit: NR 59 = 0
$ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221460202 | head -n 1
dd 3918 [006] 182589.668954: raw_syscalls:sys_exit: NR 59 = 0
$ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221460302 | head -n 1
dd 3918 [006] 182589.668954: raw_syscalls:sys_exit: NR 59 = 0In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable. It is safe because we assume backward ring buffer always overwritable in other part of code.
After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g --overwrite \
--switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump perf.data.2017101221540350 ]
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump perf.data.2017101221540451 ]
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump perf.data.2017101221540551 ]
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump perf.data.2017101221540651 ]
^C[ perf record: Woken up 1 times to write data ]
1604606+0 records in
1604605+0 records out
821557760 bytes (822 MB, 783 MiB) copied, 4.42736 s, 186 MB/s
[ perf record: Dump perf.data.2017101221540700 ]
[ perf record: Captured and wrote 0.034 MB perf.data.<timestamp> ] $ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221540350 | head -n 1
dd 5126 [003] 183074.104581: raw_syscalls:sys_exit: NR 0 = 512
$ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221540451 | head -n 1
dd 5126 [003] 183075.106496: raw_syscalls:sys_exit: NR 1 = 512
$ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221540551 | head -n 1
dd 5126 [003] 183076.108093: raw_syscalls:sys_enter: NR 1 (1, af8000, 200, 871, 0, af8060)
$ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221540651 | head -n 1
dd 5126 [003] 183077.109676: raw_syscalls:sys_exit: NR 1 = 512--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/evlist.c +6 -1
@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, }static int perf_evlist__mmap_per_evsel (struct perf_evlist *evlist,int idx, -struct mmap_params *mp,int cpu_idx, +struct mmap_params *_mp,int cpu_idx,int thread,int *_output,int *_output_backward) {struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;evlist__for_each_entry (evlist, evsel) {struct perf_mmap *maps = evlist->mmap;
@@ -815,6 +817,9 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,if (evsel->attr.write_backward) { output = _output_backward; maps = evlist->backward_mmap; + backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;if (!maps) { maps =perf_evlist__alloc_mmap (evlist);
Signature · 1 line
2.9.3
Quoted 128 lines
perf record's --overwrite option doesn't work as we expect. For example:
$ ~/linux/tools/perf$ sudo rm ./perf.data* rm: cannot remove './perf.data*': No such file or directory : ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null [ perf record: dump data: Woken up 1 times ] [ perf record: Dump perf.data.2017101221460002 ] [ perf record: dump data: Woken up 1 times ] [ perf record: Dump perf.data.2017101221460102 ] [ perf record: dump data: Woken up 1 times ] [ perf record: Dump perf.data.2017101221460202 ] [ perf record: dump data: Woken up 1 times ] [ perf record: Dump perf.data.2017101221460302 ] ^C[ perf record: Woken up 1 times to write data ] 2066346+0 records in 2066346+0 records out 1057969152 bytes (1.1 GB, 1009 MiB) copied, 4.25983 s, 248 MB/s [ perf record: Dump perf.data.2017101221460332 ] [ perf record: Captured and wrote 0.034 MB perf.data.<timestamp> ]$ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221460002 | head -n 1 dd 3918 [006] 182589.668954: raw_syscalls:sys_exit: NR 59 = 0 $ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221460102 | head -n 1 dd 3918 [006] 182589.668954: raw_syscalls:sys_exit: NR 59 = 0 $ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221460202 | head -n 1 dd 3918 [006] 182589.668954: raw_syscalls:sys_exit: NR 59 = 0 $ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221460302 | head -n 1 dd 3918 [006] 182589.668954: raw_syscalls:sys_exit: NR 59 = 0In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable. It is safe because we assume backward ring buffer always overwritable in other part of code.
After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null [ perf record: dump data: Woken up 1 times ] [ perf record: Dump perf.data.2017101221540350 ] [ perf record: dump data: Woken up 1 times ] [ perf record: Dump perf.data.2017101221540451 ] [ perf record: dump data: Woken up 1 times ] [ perf record: Dump perf.data.2017101221540551 ] [ perf record: dump data: Woken up 1 times ] [ perf record: Dump perf.data.2017101221540651 ] ^C[ perf record: Woken up 1 times to write data ] 1604606+0 records in 1604605+0 records out 821557760 bytes (822 MB, 783 MiB) copied, 4.42736 s, 186 MB/s [ perf record: Dump perf.data.2017101221540700 ] [ perf record: Captured and wrote 0.034 MB perf.data.<timestamp> ]$ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221540350 | head -n 1 dd 5126 [003] 183074.104581: raw_syscalls:sys_exit: NR 0 = 512 $ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221540451 | head -n 1 dd 5126 [003] 183075.106496: raw_syscalls:sys_exit: NR 1 = 512 $ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221540551 | head -n 1 dd 5126 [003] 183076.108093: raw_syscalls:sys_enter: NR 1 (1, af8000, 200, 871, 0, af8060) $ ~/linux/tools/perf$ sudo ./perf script -i ./perf.data.2017101221540651 | head -n 1 dd 5126 [003] 183077.109676: raw_syscalls:sys_exit: NR 1 = 512Signed-off-by Wang Nan <[email protected]>Cc Liang Kan <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Adrian Hunter <[email protected]>Cc Andi Kleen <[email protected]>Cc Li Zefan <[email protected]>--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/perf/util/evlist.c +3
-1@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, }static int perf_evlist__mmap_per_evsel (struct perf_evlist *evlist,int idx, -struct mmap_params *mp,int cpu_idx, +struct mmap_params *_mp,int cpu_idx,int thread,int *_output,int *_output_backward) {struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;tools/perf/util/evlist.c +3
-0evlist__for_each_entry (evlist, evsel) {struct perf_mmap *maps = evlist->mmap;@@ -815,6 +817,9 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, if (evsel->attr.write_backward) { output = _output_backward; maps = evlist->backward_mmap; + backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;if (!maps) {
Quoted 1 line
maps =
perf_evlist__alloc_mmap(evlist);
So it's trying to support per-event overwrite.
How about the global --overwrite option?
I think we should use opts->overwrite to replace the hard code 'false' for perf_evlist__mmap_ex as well.
Thanks,
Kan
Quoted 2 lines · Kan
Quoted 2 lines
perf record's --overwrite option doesn't work as we expect. For example:
[SNIP]
Quoted 14 lines
Quoted 14 lines
In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable. It is safe because we assume backward ring buffer always overwritable in other part of code.
After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null
[SNIP]
Quoted 48 lines
Quoted 48 lines
Signed-off-by Wang Nan <[email protected]>Cc Liang Kan <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Adrian Hunter <[email protected]>Cc Andi Kleen <[email protected]>Cc Li Zefan <[email protected]>--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/perf/util/evlist.c +3
-1@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, }static int perf_evlist__mmap_per_evsel (struct perf_evlist *evlist,int idx, -struct mmap_params *mp,int cpu_idx, +struct mmap_params *_mp,int cpu_idx,int thread,int *_output,int *_output_backward) {struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;evlist__for_each_entry(evlist, evsel) { struct perf_mmap *maps = evlist->mmap;tools/perf/util/evlist.c +3
-0@@ -815,6 +817,9 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, if (evsel->attr.write_backward) { output = _output_backward; maps = evlist->backward_mmap; + backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;
Quoted 4 lines
Quoted 2 lines
tools/perf/util/evlist.c +0
-0if (!maps) {maps = perf_evlist__alloc_mmap(evlist);So it's trying to support per-event overwrite.
How about the global --overwrite option?
Not only the per-event overwrite. See the example above. The overall --overwrite option is also respected. In perf_evsel__config, per-event evsel 'backward' setting is set based on overall '--overwrite' and per-event '/overwrite/' setting.
Quoted 5 lines
I think we should use
opts->overwriteto replace the hard code 'false' forperf_evlist__mmap_exas well.Thanks,
Kan
Quoted 78 lines · Kan
Quoted 2 lines
Quoted 2 lines
perf record's --overwrite option doesn't work as we expect. For example:
[SNIP]
Quoted 14 lines
Quoted 14 lines
In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable. It is safe because we assume backward ring buffer always overwritable in other part of code.
After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null[SNIP]
Quoted 37 lines
Quoted 37 lines
Signed-off-by Wang Nan <[email protected]>Cc Liang Kan <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Adrian Hunter <[email protected]>Cc Andi Kleen <[email protected]>Cc Li Zefan <[email protected]>--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/perf/util/evlist.c +3
-1@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, }static int perf_evlist__mmap_per_evsel (struct perf_evlist *evlist,int idx, -struct mmap_params *mp,int cpu_idx, +struct mmap_params *_mp,int cpu_idx,int thread,int *_output,int *_output_backward) {struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;Quoted 2 lines
Quoted 2 lines
evlist__for_each_entry(evlist, evsel) { struct perf_mmap *maps = evlist->mmap; @@ -815,6 +817,9@@ static
Quoted 9 lines
Quoted 9 lines
int perf_evlist__mmap_per_evsel(struct
perf_evlist*evlist, int idx,
if (evsel->attr.write_backward) {
output =_output_backward; maps =evlist->backward_mmap;tools/perf/util/evlist.c +3
-0+ backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;Quoted 4 lines
Quoted 2 lines
if (!maps) { maps = perf_evlist__alloc_mmap(evlist);So it's trying to support per-event overwrite.
How about the global --overwrite option?
Quoted 4 lines
Not only the per-event overwrite. See the example above. The overall -- overwrite option is also respected. In
perf_evsel__config, per-event evsel 'backward' setting is set based on overall '--overwrite' and per-event '/overwrite/' setting.
But how about evlist->overwrite? I think it still keeps the wrong setting. The overwrite is implicitly applied. Some settings are inconsistent.
Is there any drawback if you use opts->overwrite for perf_evlist__mmap_ex?
Thanks,
Kan
Quoted 7 lines
Quoted 6 lines
I think we should use
opts->overwriteto replace the hard code 'false' forperf_evlist__mmap_exas well.Thanks,
Kan
Quoted 72 lines · Kan
Quoted 72 lines · Kan
Quoted 2 lines
Quoted 2 lines
perf record's --overwrite option doesn't work as we expect. For example:
[SNIP]
Quoted 13 lines
Quoted 13 lines
In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable. It is safe because we assume backward ring buffer always overwritable in other part of code.
After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null[SNIP]
Quoted 36 lines
Quoted 36 lines
Signed-off-by Wang Nan <[email protected]>Cc Liang Kan <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Adrian Hunter <[email protected]>Cc Andi Kleen <[email protected]>Cc Li Zefan <[email protected]>--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/perf/util/evlist.c +3
-1@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, }static int perf_evlist__mmap_per_evsel (struct perf_evlist *evlist,int idx, -struct mmap_params *mp,int cpu_idx, +struct mmap_params *_mp,int cpu_idx,int thread,int *_output,int *_output_backward) {struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;Quoted 2 lines
Quoted 2 lines
evlist__for_each_entry(evlist, evsel) { struct perf_mmap *maps = evlist->mmap; @@ -815,6 +817,9@@ static
Quoted 13 lines
tools/perf/util/evlist.c static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, · line 825
Quoted 11 lines
int perf_evlist__mmap_per_evsel(struct
perf_evlist*evlist, int idx,if (evsel->attr.write_backward) { output = _output_backward; maps = evlist->backward_mmap;tools/perf/util/evlist.c +3
-0+ backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;if (!maps) { maps =perf_evlist__alloc_mmap (evlist);So it's trying to support per-event overwrite.
How about the global --overwrite option?
Quoted 8 lines
Quoted 4 lines
Not only the per-event overwrite. See the example above. The overall -- overwrite option is also respected. In
perf_evsel__config, per-event evsel 'backward' setting is set based on overall '--overwrite' and per-event '/overwrite/' setting.But how about
evlist->overwrite? I think it still keeps the wrong setting. The overwrite is implicitly applied. Some settings are inconsistent.Is there any drawback if you use
opts->overwriteforperf_evlist__mmap_ex?
We will always face such inconsistency, because we have an /no-overwrite/ option which can be set per-evsel. Setting evlist->overwrite won't make things more consistent, because in a evlist, different evsel can have different overwrite setting. A simple solution is making evlist non-overwrite by default, and watch all overwrite evsels a special cases. Then we have only 2 cases to consider:
1. overwrite evsel in a non-overwrite evlist.
2. non-overwrite evsel in a non-overwrite evlist.
If we reset evlist->overwrite according to --overwrite, we will have 4 cases to consider:
1. overwrite evsel in a overwrite evlist.
2. non-overwrite evsel in a overwrite evlist.
3. overwrite evsel in a non-overwrite evlist.
4. non-overwrite evsel in a non-overwrite evlist.
The real problem is: there's 'overwrite' and 'backward' concepts in our code, but these two concepts are neither independent nor identical.
Thank you.
Quoted 7 lines
Thanks,
KanQuoted 5 lines
Quoted 5 lines
I think we should use
opts->overwriteto replace the hard code 'false' forperf_evlist__mmap_exas well.Thanks,
Kan
Quoted 93 lines · Kan
Quoted 44 lines
Quoted 44 lines · Kan
Quoted 2 lines
Quoted 2 lines
perf record's --overwrite option doesn't work as we expect. For example:
[SNIP]
Quoted 13 lines
Quoted 13 lines
In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable. It is safe because we assume backward ring buffer always overwritable in other part of code.
After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null[SNIP]
Quoted 24 lines
Quoted 24 lines
Signed-off-by Wang Nan <[email protected]>Cc Liang Kan <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Adrian Hunter <[email protected]>Cc Andi Kleen <[email protected]>Cc Li Zefan <[email protected]>--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/perf/util/evlist.c +0
-0@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, }Quoted 1 line
Quoted 1 line
Quoted 1 line
tools/perf/util/evlist.c perf_evlist__should_poll(struct perf_evlist · line 802
Quoted 1 line
tools/perf/util/evlist.c +0
-0static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, intidx,
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 11 lines
tools/perf/util/evlist.c +3
-1- struct mmap_params *mp, int cpu_idx, + struct mmap_params *_mp, int cpu_idx, int thread, int *_output, int *_output_backward) { struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;Quoted 2 lines
Quoted 2 lines
evlist__for_each_entry(evlist, evsel) { struct perf_mmap *maps = evlist->mmap; @@ -815,6 +817,9@@ static
Quoted 13 lines
tools/perf/util/evlist.c static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, · line 825
Quoted 11 lines
int perf_evlist__mmap_per_evsel(struct
perf_evlist*evlist, int idx,if (evsel->attr.write_backward) { output = _output_backward; maps = evlist->backward_mmap;tools/perf/util/evlist.c +3
-0+ backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;if (!maps) { maps =perf_evlist__alloc_mmap (evlist);So it's trying to support per-event overwrite.
How about the global --overwrite option?Quoted 8 lines
Quoted 4 lines
Not only the per-event overwrite. See the example above. The overall -- overwrite option is also respected. In
perf_evsel__config, per-event evsel 'backward' setting is set based on overall '--overwrite' and per-event '/overwrite/' setting.But how about
evlist->overwrite? I think it still keeps the wrong setting. The overwrite is implicitly applied. Some settings are inconsistent.Is there any drawback if you use
opts->overwritefor
perf_evlist__mmap_ex?We will always face such inconsistency, because we have an /no-overwrite/ option which can be set per-evsel. Setting
evlist->overwritewon't make things more consistent, because in a evlist, different evsel can have different overwrite setting. A simple solution is making evlist non-overwrite by default, and watch all overwrite evsels a special cases. Then we have only 2 cases to consider:
Quoted 3 lines
1. overwrite evsel in a non-overwrite evlist.
2. non-overwrite evsel in a non-overwrite evlist.
If evlist->overwrite is always non-overwrite, why not remove it?
Quoted 23 lines
If we reset
evlist->overwriteaccording to --overwrite, we will have 4 cases to consider:1. overwrite evsel in a overwrite evlist.
2. non-overwrite evsel in a overwrite evlist.
3. overwrite evsel in a non-overwrite evlist.
4. non-overwrite evsel in a non-overwrite evlist.The real problem is: there's 'overwrite' and 'backward' concepts in our code, but these two concepts are neither independent nor identical.
Thank you.
Quoted 7 lines
Thanks,
KanQuoted 5 lines
Quoted 5 lines
I think we should use
opts->overwriteto replace the hard code 'false' forperf_evlist__mmap_exas well.Thanks,
Kan
Quoted 91 lines · Kan
Quoted 91 lines · Kan
Quoted 43 lines
Quoted 43 lines · Kan
Quoted 2 lines
Quoted 2 lines
perf record's --overwrite option doesn't work as we expect. For example:
[SNIP]
Quoted 13 lines
Quoted 13 lines
In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable. It is safe because we assume backward ring buffer always overwritable in other part of code.
After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null[SNIP]
Quoted 23 lines
Quoted 23 lines
Signed-off-by Wang Nan <[email protected]>Cc Liang Kan <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Adrian Hunter <[email protected]>Cc Andi Kleen <[email protected]>Cc Li Zefan <[email protected]>--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/perf/util/evlist.c +0
-0@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, }Quoted 1 line
Quoted 1 line
Quoted 1 line
tools/perf/util/evlist.c perf_evlist__should_poll(struct perf_evlist · line 802
Quoted 1 line
tools/perf/util/evlist.c +0
-0static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, intidx,
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 11 lines
tools/perf/util/evlist.c +3
-1- struct mmap_params *mp, int cpu_idx, + struct mmap_params *_mp, int cpu_idx, int thread, int *_output, int *_output_backward) { struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;Quoted 2 lines
Quoted 2 lines
evlist__for_each_entry(evlist, evsel) { struct perf_mmap *maps = evlist->mmap; @@ -815,6 +817,9@@ static
Quoted 13 lines
tools/perf/util/evlist.c static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, · line 825
Quoted 11 lines
int perf_evlist__mmap_per_evsel(struct
perf_evlist*evlist, int idx,if (evsel->attr.write_backward) { output = _output_backward; maps = evlist->backward_mmap;tools/perf/util/evlist.c +3
-0+ backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;if (!maps) { maps =perf_evlist__alloc_mmap (evlist);So it's trying to support per-event overwrite.
How about the global --overwrite option?Quoted 8 lines
Quoted 4 lines
Not only the per-event overwrite. See the example above. The overall -- overwrite option is also respected. In
perf_evsel__config, per-event evsel 'backward' setting is set based on overall '--overwrite' and per-event '/overwrite/' setting.But how about
evlist->overwrite? I think it still keeps the wrong setting. The overwrite is implicitly applied. Some settings are inconsistent.Is there any drawback if you use
opts->overwritefor
perf_evlist__mmap_ex?We will always face such inconsistency, because we have an /no-overwrite/ option which can be set per-evsel. Setting
evlist->overwritewon't make things more consistent, because in a evlist, different evsel can have different overwrite setting. A simple solution is making evlist non-overwrite by default, and watch all overwrite evsels a special cases. Then we have only 2 cases to consider:
Quoted 5 lines
Quoted 3 lines
1. overwrite evsel in a non-overwrite evlist.
2. non-overwrite evsel in a non-overwrite evlist.If
evlist->overwriteis always non-overwrite, why not remove it?
Some testcases require it.
Thank you.
Quoted 96 lines · Wangnan (F)
Quoted 93 lines · Kan
Quoted 93 lines · Kan
Quoted 44 lines
Quoted 44 lines · Kan
Quoted 2 lines
Quoted 2 lines
perf record's --overwrite option doesn't work as we expect. For example:
[SNIP]
Quoted 14 lines
Quoted 14 lines
In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable. It is safe because we assume backward ring buffer always overwritable in other part of code.
After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null[SNIP]
Quoted 23 lines
Quoted 23 lines
Signed-off-by Wang Nan <[email protected]>Cc Liang Kan <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Adrian Hunter <[email protected]>Cc Andi Kleen <[email protected]>Cc Li Zefan <[email protected]>--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/perf/util/evlist.c +0
-0@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, }Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
tools/perf/util/evlist.c perf_evlist__should_poll(struct perf_evlist · line 803
Quoted 2 lines
tools/perf/util/evlist.c +0
-0static int perf_evlist__mmap_per_evsel (struct perf_evlist *evlist, intidx,
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 11 lines
tools/perf/util/evlist.c +3
-1- struct mmap_params *mp, int cpu_idx, + struct mmap_params *_mp, int cpu_idx, int thread, int *_output, int *_output_backward) { struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;Quoted 2 lines
Quoted 2 lines
evlist__for_each_entry(evlist, evsel) { struct perf_mmap *maps = evlist->mmap; @@ -815,6 +817,9@@ static
Quoted 13 lines
tools/perf/util/evlist.c
Quoted 11 lines
int perf_evlist__mmap_per_evsel(struct
perf_evlist*evlist, int idx,if (evsel->attr.write_backward) { output = _output_backward; maps = evlist->backward_mmap;tools/perf/util/evlist.c +3
-0+ backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;if (!maps) { maps =perf_evlist__alloc_mmap (evlist);So it's trying to support per-event overwrite.
How about the global --overwrite option?Quoted 8 lines
Quoted 4 lines
Not only the per-event overwrite. See the example above. The overall -- overwrite option is also respected. In
perf_evsel__config, per-event evsel 'backward' setting is set based on overall '--overwrite' and per-event '/overwrite/' setting.But how about
evlist->overwrite? I think it still keeps the wrong setting. The overwrite is implicitly applied. Some settings are inconsistent.Is there any drawback if you use
opts->overwritefor
perf_evlist__mmap_ex?We will always face such inconsistency, because we have an /no-overwrite/ option which can be set per-evsel. Setting
evlist->overwritewon't make things more consistent, because in a evlist, different evsel can have different overwrite setting. A simple solution is making evlist non-overwrite by default, and watch all overwrite evsels a special cases. Then we have only 2 cases to consider:
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
1. overwrite evsel in a non-overwrite evlist.
2. non-overwrite evsel in a non-overwrite evlist.If
evlist->overwriteis always non-overwrite, why not remove it?Some testcases require it.
Sorry. I think removing it is reasonable now, but we need to solve
the relationship between overwrite and backward first. I suggest remove the whole 'backward' concept, and makes evsels backward if it is overwrite. Is there any usecases that:
1. overwrite but not backward ring buffer: it will be unparsable after ring buffer full.
2. backward but not overwrite ring buffer: I don't see any advantage.
Thank you.
Quoted 1 line
Thank you.
Quoted 109 lines
Quoted 40 lines · Kan
Quoted 39 lines
Quoted 39 lines · Kan
Quoted 38 lines
Quoted 38 lines · Kan
Quoted 2 lines
Quoted 2 lines
perf record's --overwrite option doesn't work as we expect. For example:
[SNIP]
Quoted 16 lines
Quoted 16 lines
In the above example we get same records from the backward ring buffer all the time. Overwriting is not triggered.
This commit maps backward ring buffers readonly, make it overwritable.
It is safe because we assume backward ring buffer always overwritable
in other part of code.After applying this patch:
$ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:* -g -- overwrite \ --switch-output=1s --tail-synthesize dd if=/dev/zero of=/dev/null[SNIP]
Quoted 15 lines
Quoted 15 lines
Signed-off-by Wang Nan <[email protected]>Cc Liang Kan <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Adrian Hunter <[email protected]>Cc Andi Kleen <[email protected]>Cc Li Zefan <[email protected]>--- tools/perf/util/evlist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
tools/perf/util/evlist.c perf_evlist__should_poll(struct
Quoted 5 lines
tools/perf/util/evlist.c +0
-0@@ -799,12 +799,14 @@ perf_evlist__should_poll(struct
perf_evlistQuoted 55 lines
Quoted 55 lines
Quoted 55 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
tools/perf/util/evlist.c perf_evlist__should_poll(struct · line 803
Quoted 5 lines
tools/perf/util/evlist.c +0
-0*evlist __maybe_unused, }static int perf_evlist__mmap_per_evsel (struct perf_evlist *evlist, intidx,
Quoted 34 lines
Quoted 27 lines
Quoted 11 lines
Quoted 11 lines
tools/perf/util/evlist.c +3
-1- struct mmap_params *mp, int cpu_idx, + struct mmap_params *_mp, int cpu_idx, int thread, int *_output, int *_output_backward) { struct perf_evsel *evsel;int revent;int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +struct mmap_params *mp = _mp; +struct mmap_params backward_mp;Quoted 2 lines
Quoted 2 lines
evlist__for_each_entry(evlist, evsel) { struct perf_mmap *maps = evlist->mmap; @@ -815,6 +817,9@@ static
Quoted 9 lines
Quoted 9 lines
int perf_evlist__mmap_per_evsel(struct
perf_evlist*evlist, int idx,if (evsel->attr.write_backward) { output = _output_backward; maps = evlist->backward_mmap;tools/perf/util/evlist.c +3
-0+ backward_mp = *mp; + backward_mp.prot &= ~PROT_WRITE ; + mp = &backward_mp;Quoted 4 lines
Quoted 2 lines
if (!maps) { maps = perf_evlist__alloc_mmap(evlist);So it's trying to support per-event overwrite.
How about the global --overwrite option?Quoted 7 lines
Not only the per-event overwrite. See the example above. The overall --
overwrite option is also respected. Inperf_evsel__config, per-event evsel
'backward' setting is set based on overall '--overwrite' and per-event
'/overwrite/' setting.Quoted 5 lines
But how about
evlist->overwrite? I think it still keeps the wrong setting.
The overwrite is implicitly applied. Some settings are inconsistent.Is there any drawback if you use
opts->overwritefor
perf_evlist__mmap_ex?We will always face such inconsistency, because we have an /no-overwrite/ option which can be set per-evsel. Setting
evlist->overwritewon't make things more consistent, because in a evlist, different evsel can have different overwrite setting. A simple solution is making evlist non-overwrite by default, and watch all overwrite evsels a special cases. Then we have only 2 cases to consider:Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
1. overwrite evsel in a non-overwrite evlist.
2. non-overwrite evsel in a non-overwrite evlist.If
evlist->overwriteis always non-overwrite, why not remove it?Some testcases require it.
Quoted 8 lines
Sorry. I think removing it is reasonable now, but we need to solve the relationship between overwrite and backward first. I suggest remove the whole 'backward' concept, and makes evsels backward if it is overwrite. Is there any usecases that:
1. overwrite but not backward ring buffer: it will be unparsable after ring buffer full.
2. backward but not overwrite ring buffer: I don't see any advantage.
I agree.
I think we care more about the overwrite or non-overwrite. It doesn't matter it is backward or forward unless it brings issues.
Thanks,
Kan
Quoted 4 lines
Thank you.
Quoted 1 line
Thank you.