Skip to contentSkip to conversation

perf annotate: Display multiple events for --stdio

PATCH In review Jin Yao 3 participants 6 messages May 9, 2018 – May 15, 2018 perf events

lore
Share & tools
lore

Jin Yao

author
#0 lore raw

PATCH 1/1 perf annotate: Display multiple events for --stdio

When we perform following command lines:

perf record -e "{cycles,branches}" ./div
perf annotate main --stdio

Only shows one event "cycles" and the displaying format is not correct.

Percent | Source code & Disassembly of div for cycles (44550 samples)
-----------------------------------------------------------------------------------

                 :
                 :
                 :
                 :            Disassembly of section .text:
                 :
                 :            00000000004004b0 <main>:
                 :            main():
                 :
                 :                    return i;
                 :            }
                 :
                 :            int main(void)
                 :            {
    0.00 :   4004b0:       push   %rbx
                 :                    int i;
                 :                    int flag;
                 :                    volatile double x = 1212121212, y = 121212;
                 :
                 :                    s_randseed = time(0);
    0.00 :   4004b1:       xor    %edi,%edi
                 :                    srand(s_randseed);
    0.00 :   4004b3:       mov    $0x77359400,%ebx
                 :
                 :                    return i;
                 :            }
                 :

The issue is the value of nr_percent is hardcoded to 1. This patch fixes it.

With this patch, the output is:

Percent | Source code & Disassembly of div for cycles (44550 samples)
-----------------------------------------------------------------------------------

                 :
                 :
                 :
                 :            Disassembly of section .text:
                 :
                 :            00000000004004b0 <main>:
                 :            main():
                 :
                 :                    return i;
                 :            }
                 :
                 :            int main(void)
                 :            {
    0.00    0.00 :   4004b0:       push   %rbx
                 :                    int i;
                 :                    int flag;
                 :                    volatile double x = 1212121212, y = 121212;
                 :
                 :                    s_randseed = time(0);
    0.00    0.00 :   4004b1:       xor    %edi,%edi
                 :                    srand(s_randseed);
    0.00    0.00 :   4004b3:       mov    $0x77359400,%ebx
                 :
                 :                    return i;
                 :            }
---
 tools/perf/util/annotate.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/util/annotate.c +3 -0
index 536ee14..5d74a30 100644
@@ -1263,6 +1263,9 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
 				max_percent = sample->percent;
 		}
 
+		if (al->samples_nr > nr_percent)
+			nr_percent = al->samples_nr;
+
 		if (max_percent < min_pcnt)
 			return -1;
 
Signature · 1 line
2.7.4
#1 lore raw

Em Wed, May 09, 2018 at 11:57:15PM +0800, Jin Yao escreveu:

Quoted 9 lines

When we perform following command lines:

perf record -e "{cycles,branches}" ./div
perf annotate main --stdio

Only shows one event "cycles" and the displaying format is not correct.

Percent | Source code & Disassembly of div for cycles (44550 samples)
-----------------------------------------------------------------------------------

Please indent command output (two spaces before all lines) to avoid scripts breaking due to mistaking lines starting with --- as the end of the patch.

Applying.

- Arnaldo

Quoted 81 lines
                 :
                 :
                 :
                 :            Disassembly of section .text:
                 :
                 :            00000000004004b0 <main>:
                 :            main():
                 :
                 :                    return i;
                 :            }
                 :
                 :            int main(void)
                 :            {
    0.00 :   4004b0:       push   %rbx
                 :                    int i;
                 :                    int flag;
                 :                    volatile double x = 1212121212, y = 121212;
                 :
                 :                    s_randseed = time(0);
    0.00 :   4004b1:       xor    %edi,%edi
                 :                    srand(s_randseed);
    0.00 :   4004b3:       mov    $0x77359400,%ebx
                 :
                 :                    return i;
                 :            }
                 :

The issue is the value of nr_percent is hardcoded to 1. This patch fixes it.

With this patch, the output is:

Percent | Source code & Disassembly of div for cycles (44550 samples)
-----------------------------------------------------------------------------------

                 :
                 :
                 :
                 :            Disassembly of section .text:
                 :
                 :            00000000004004b0 <main>:
                 :            main():
                 :
                 :                    return i;
                 :            }
                 :
                 :            int main(void)
                 :            {
    0.00    0.00 :   4004b0:       push   %rbx
                 :                    int i;
                 :                    int flag;
                 :                    volatile double x = 1212121212, y = 121212;
                 :
                 :                    s_randseed = time(0);
    0.00    0.00 :   4004b1:       xor    %edi,%edi
                 :                    srand(s_randseed);
    0.00    0.00 :   4004b3:       mov    $0x77359400,%ebx
                 :
                 :                    return i;
                 :            }
---
 tools/perf/util/annotate.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/util/annotate.c +3 -0
index 536ee14..5d74a30 100644
@@ -1263,6 +1263,9 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
 				max_percent = sample->percent;
 		}
 
+		if (al->samples_nr > nr_percent)
+			nr_percent = al->samples_nr;
+
 		if (max_percent < min_pcnt)
 			return -1;
 
Signature · 1 line
2.7.4
#2 lore raw

Em Wed, May 09, 2018 at 01:42:51PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 8 lines

Em Wed, May 09, 2018 at 11:57:15PM +0800, Jin Yao escreveu:

Quoted 7 lines

When we perform following command lines:

perf record -e "{cycles,branches}" ./div
perf annotate main --stdio

Only shows one event "cycles" and the displaying format is not correct.

Quoted 8 lines
Quoted 2 lines

Percent | Source code & Disassembly of div for cycles (44550 samples)
-----------------------------------------------------------------------------------

Please indent command output (two spaces before all lines) to avoid scripts breaking due to mistaking lines starting with --- as the end of the patch.

Applying.

Also you forgot to add this:

Cc Jiri Olsa <[email protected]>
Fixes f681d593d1ce ("perf annotate: Remove disasm__calc_percent() from disasm_line__print()")

Which I've just added, to help with stable@ processing.

- Arnaldo

author
#3 lore raw
Quoted 18 lines · Arnaldo Carvalho de Melo

Em Wed, May 09, 2018 at 01:42:51PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 8 lines

Em Wed, May 09, 2018 at 11:57:15PM +0800, Jin Yao escreveu:

Quoted 7 lines

When we perform following command lines:

perf record -e "{cycles,branches}" ./div
perf annotate main --stdio

Only shows one event "cycles" and the displaying format is not correct.

Quoted 8 lines
Quoted 2 lines

Percent | Source code & Disassembly of div for cycles (44550 samples)
-----------------------------------------------------------------------------------

Please indent command output (two spaces before all lines) to avoid scripts breaking due to mistaking lines starting with --- as the end of the patch.

Applying.

Quoted 9 lines

Also you forgot to add this:

Cc Jiri Olsa <[email protected]>
Fixes f681d593d1ce ("perf annotate: Remove disasm__calc_percent() from disasm_line__print()")

Which I've just added, to help with stable@ processing.

- Arnaldo

Actually I notice this issue during fixing another issue. :)

Another issue is, without using group, the multiple events can't be supported well in perf annotate.

perf record -e cycles,branches ./div
perf annotate main --stdio

It should show both cycles and branches on the left side but actually it only show cycles.

I will post patches for fixing this (working on the patch now).

Thanks
Jin Yao

author
#4 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 11 lines · Arnaldo Carvalho de Melo

Em Wed, May 09, 2018 at 11:57:15PM +0800, Jin Yao escreveu:

Quoted 9 lines

When we perform following command lines:

perf record -e "{cycles,branches}" ./div
perf annotate main --stdio

Only shows one event "cycles" and the displaying format is not correct.

Percent | Source code & Disassembly of div for cycles (44550 samples)
-----------------------------------------------------------------------------------

Quoted 8 lines

Please indent command output (two spaces before all lines) to avoid scripts breaking due to mistaking lines starting with --- as the end of the patch.

Applying.

- Arnaldo

Breaking the scripts? Oh, very sorry about that, I will be careful next time.

Thanks
Jin Yao

Quoted 81 lines
Quoted 81 lines
                  :
                  :
                  :
                  :            Disassembly of section .text:
                  :
                  :            00000000004004b0 <main>:
                  :            main():
                  :
                  :                    return i;
                  :            }
                  :
                  :            int main(void)
                  :            {
     0.00 :   4004b0:       push   %rbx
                  :                    int i;
                  :                    int flag;
                  :                    volatile double x = 1212121212, y = 121212;
                  :
                  :                    s_randseed = time(0);
     0.00 :   4004b1:       xor    %edi,%edi
                  :                    srand(s_randseed);
     0.00 :   4004b3:       mov    $0x77359400,%ebx
                  :
                  :                    return i;
                  :            }
                  :

The issue is the value of nr_percent is hardcoded to 1. This patch fixes it.

With this patch, the output is:

Percent | Source code & Disassembly of div for cycles (44550 samples)
-----------------------------------------------------------------------------------

                  :
                  :
                  :
                  :            Disassembly of section .text:
                  :
                  :            00000000004004b0 <main>:
                  :            main():
                  :
                  :                    return i;
                  :            }
                  :
                  :            int main(void)
                  :            {
     0.00    0.00 :   4004b0:       push   %rbx
                  :                    int i;
                  :                    int flag;
                  :                    volatile double x = 1212121212, y = 121212;
                  :
                  :                    s_randseed = time(0);
     0.00    0.00 :   4004b1:       xor    %edi,%edi
                  :                    srand(s_randseed);
     0.00    0.00 :   4004b3:       mov    $0x77359400,%ebx
                  :
                  :                    return i;
                  :            }
---
  tools/perf/util/annotate.c | 3 +++
  1 file changed, 3 insertions(+)
tools/perf/util/annotate.c +3 -0
index 536ee14..5d74a30 100644
@@ -1263,6 +1263,9 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
  				max_percent = sample->percent;
  		}
 
+		if (al->samples_nr > nr_percent)
+			nr_percent = al->samples_nr;
+
  		if (max_percent < min_pcnt)
  			return -1;
 
Signature · 1 line
2.7.4
#5 lore raw

[tip:perf/urgent] perf annotate: Display all available events on --stdio

In reply to Jin Yao
perf annotate: Display all available events on --stdio
Commit-ID:  04d2600ab669b2d44dd7920cc8a1b95c8144084c
Gitweb:     https://git.kernel.org/tip/04d2600ab669b2d44dd7920cc8a1b95c8144084c
Author:     Jin Yao <[email protected]>
AuthorDate: Wed, 9 May 2018 23:57:15 +0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 10 May 2018 15:19:30 -0300

perf annotate: Display all available events on --stdio

When we perform the following command lines:

  $ perf record -e "{cycles,branches}" ./div
  $ perf annotate main --stdio

The output shows only the first event, "cycles" and the displaying format is not correct.

   Percent         |      Source code & Disassembly of div for cycles (44550 samples)
  -----------------------------------------------------------------------------------
                   :
                   :
                   :
                   :            Disassembly of section .text:
                   :
                   :            00000000004004b0 <main>:
                   :            main():
                   :
                   :                    return i;
                   :            }
                   :
                   :            int main(void)
                   :            {
      0.00 :   4004b0:       push   %rbx
                   :                    int i;
                   :                    int flag;
                   :                    volatile double x = 1212121212, y = 121212;
                   :
                   :                    s_randseed = time(0);
      0.00 :   4004b1:       xor    %edi,%edi
                   :                    srand(s_randseed);
      0.00 :   4004b3:       mov    $0x77359400,%ebx
                   :
                   :                    return i;
                   :            }

The issue is that the value of the 'nr_percent' variable is hardcoded to
1. This patch fixes it.

With this patch, the output is:

   Percent         |      Source code & Disassembly of div for cycles (44550 samples)
  -----------------------------------------------------------------------------------
                   :
                   :
                   :
                   :            Disassembly of section .text:
                   :
                   :            00000000004004b0 <main>:
                   :            main():
                   :
                   :                    return i;
                   :            }
                   :
                   :            int main(void)
                   :            {
      0.00    0.00 :   4004b0:       push   %rbx
                   :                    int i;
                   :                    int flag;
                   :                    volatile double x = 1212121212, y = 121212;
                   :
                   :                    s_randseed = time(0);
      0.00    0.00 :   4004b1:       xor    %edi,%edi
                   :                    srand(s_randseed);
      0.00    0.00 :   4004b3:       mov    $0x77359400,%ebx
                   :
                   :                    return i;
                   :            }
Cc Alexander Shishkin <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Peter Zijlstra <[email protected]>
Fixes f681d593d1ce ("perf annotate: Remove disasm__calc_percent() from disasm_line__print()")
---
 tools/perf/util/annotate.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/util/annotate.c +3 -0
index 536ee148bff8..5d74a30fe00f 100644
@@ -1263,6 +1263,9 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
 				max_percent = sample->percent;
 		}
 
+		if (al->samples_nr > nr_percent)
+			nr_percent = al->samples_nr;
+
 		if (max_percent < min_pcnt)
 			return -1;