Re: pahole + BTF was: Re: [Question] bpf: about a new 'tools/bpf/bpf_dwarf2btf'

2018-07-25 Thread Taeung Song




On 07/26/2018 03:27 AM, Taeung Song wrote:

Hi Arnaldo,

On 07/26/2018 02:52 AM, Arnaldo Carvalho de Melo wrote:

Em Thu, Jul 26, 2018 at 02:23:32AM +0900, Taeung Song escreveu:

Hi,

Building bpf programs with .BTF section,
I thought it'd be better to convert dwarf info to .BTF by
a new tool such as 'tools/bpf/bpf_dwarf2btf' instead of pahole
in the future.
Currently for bpf binary that have .BTF section,
we need to use pahole from https://github.com/iamkafai/pahole/tree/btf
with the command line such as "pahole -J bpf_prog.o".
I think it is great but if implementing new 'bpf_dwarf2btf'
(dwarf parsing + btf encoder code written by Martin KaFai Lau on
the pahole project i.e. btf.h, btf_encoder.c, btf_encoder.h,
libbtf.c, libbtf.h),
BPF developers would more easily use functionalities based on BTF.


What would be easier exactly? Not having to install a package but build
it from the kernel sources?

Many kernel developers already have pahole installed for other uses, so
no need to install anything.



Understood, but I think there are many non-kernel developers
developing BPF programs and they mightn't have or use pahole.

So, if providing the 'dwarf2btf' feature on tools/bpf or tools/bpf/bpftool,
non-kernel developers can also more easily build bpf prog with .BPF, no ?



Or, if tools/lib/bpf/ have the 'dwarf2btf' feature,
I think BPF developers can just use bpf programs that have dwarf info
after compiling with clang '-g' and llc '-mattr=dwarfris', even though 
not using pahole.

Isn't it good way ?


BTW, Daniel, I just pushed to pahole's main repository at:

   git://git.kernel.org/pub/scm/devel/pahole/pahole.git

with the Martin's BTF patch, so no need to pull from the github one,
I'll tag v1.12 and announce the release so that distro package
maintainers can update their packages.

What do you think about this ? Do you think this is needed ?
Or, already implementing something like this ?
If it is needed, I want to try to make 'tools/bpf/bpf_dwarf2btf'
based on the pahole code. I'd appreciate it, if you reply to this


The way Martin took advantage of the work done a long time ago to
support CTF out of the same DWARF reading codebase was really cool, not
that much work to do, just add a new format to pahole's codebase making
it more useful.



I got it !

Thanks,
Taeung


I was just so far overly picky with testing it and kept leaving for
later to have a good documentation about testing it, vacation and perf
maintainership duties kept making this take like forever, grumble :-\

- Arnaldo



--
oh.. :'(


Re: pahole + BTF was: Re: [Question] bpf: about a new 'tools/bpf/bpf_dwarf2btf'

2018-07-25 Thread Taeung Song




On 07/26/2018 03:27 AM, Taeung Song wrote:

Hi Arnaldo,

On 07/26/2018 02:52 AM, Arnaldo Carvalho de Melo wrote:

Em Thu, Jul 26, 2018 at 02:23:32AM +0900, Taeung Song escreveu:

Hi,

Building bpf programs with .BTF section,
I thought it'd be better to convert dwarf info to .BTF by
a new tool such as 'tools/bpf/bpf_dwarf2btf' instead of pahole
in the future.
Currently for bpf binary that have .BTF section,
we need to use pahole from https://github.com/iamkafai/pahole/tree/btf
with the command line such as "pahole -J bpf_prog.o".
I think it is great but if implementing new 'bpf_dwarf2btf'
(dwarf parsing + btf encoder code written by Martin KaFai Lau on
the pahole project i.e. btf.h, btf_encoder.c, btf_encoder.h,
libbtf.c, libbtf.h),
BPF developers would more easily use functionalities based on BTF.


What would be easier exactly? Not having to install a package but build
it from the kernel sources?

Many kernel developers already have pahole installed for other uses, so
no need to install anything.



Understood, but I think there are many non-kernel developers
developing BPF programs and they mightn't have or use pahole.

So, if providing the 'dwarf2btf' feature on tools/bpf or tools/bpf/bpftool,
non-kernel developers can also more easily build bpf prog with .BPF, no ?



Or, if tools/lib/bpf/ have the 'dwarf2btf' feature,
I think BPF developers can just use bpf programs that have dwarf info
after compiling with clang '-g' and llc '-mattr=dwarfris', even though 
not using pahole.

Isn't it good way ?


BTW, Daniel, I just pushed to pahole's main repository at:

   git://git.kernel.org/pub/scm/devel/pahole/pahole.git

with the Martin's BTF patch, so no need to pull from the github one,
I'll tag v1.12 and announce the release so that distro package
maintainers can update their packages.

What do you think about this ? Do you think this is needed ?
Or, already implementing something like this ?
If it is needed, I want to try to make 'tools/bpf/bpf_dwarf2btf'
based on the pahole code. I'd appreciate it, if you reply to this


The way Martin took advantage of the work done a long time ago to
support CTF out of the same DWARF reading codebase was really cool, not
that much work to do, just add a new format to pahole's codebase making
it more useful.



I got it !

Thanks,
Taeung


I was just so far overly picky with testing it and kept leaving for
later to have a good documentation about testing it, vacation and perf
maintainership duties kept making this take like forever, grumble :-\

- Arnaldo



--
oh.. :'(


Re: pahole + BTF was: Re: [Question] bpf: about a new 'tools/bpf/bpf_dwarf2btf'

2018-07-25 Thread Taeung Song

Hi Arnaldo,

On 07/26/2018 02:52 AM, Arnaldo Carvalho de Melo wrote:

Em Thu, Jul 26, 2018 at 02:23:32AM +0900, Taeung Song escreveu:

Hi,

Building bpf programs with .BTF section,
I thought it'd be better to convert dwarf info to .BTF by
a new tool such as 'tools/bpf/bpf_dwarf2btf' instead of pahole
in the future.
  

Currently for bpf binary that have .BTF section,
we need to use pahole from https://github.com/iamkafai/pahole/tree/btf
with the command line such as "pahole -J bpf_prog.o".
  

I think it is great but if implementing new 'bpf_dwarf2btf'
(dwarf parsing + btf encoder code written by Martin KaFai Lau on
the pahole project i.e. btf.h, btf_encoder.c, btf_encoder.h,
libbtf.c, libbtf.h),
BPF developers would more easily use functionalities based on BTF.


What would be easier exactly? Not having to install a package but build
it from the kernel sources?

Many kernel developers already have pahole installed for other uses, so
no need to install anything.



Understood, but I think there are many non-kernel developers
developing BPF programs and they mightn't have or use pahole.

So, if providing the 'dwarf2btf' feature on tools/bpf or tools/bpf/bpftool,
non-kernel developers can also more easily build bpf prog with .BPF, no ?


BTW, Daniel, I just pushed to pahole's main repository at:

   git://git.kernel.org/pub/scm/devel/pahole/pahole.git

with the Martin's BTF patch, so no need to pull from the github one,
I'll tag v1.12 and announce the release so that distro package
maintainers can update their packages.
  

What do you think about this ? Do you think this is needed ?
Or, already implementing something like this ?
  

If it is needed, I want to try to make 'tools/bpf/bpf_dwarf2btf'
based on the pahole code. I'd appreciate it, if you reply to this


The way Martin took advantage of the work done a long time ago to
support CTF out of the same DWARF reading codebase was really cool, not
that much work to do, just add a new format to pahole's codebase making
it more useful.



I got it !

Thanks,
Taeung


I was just so far overly picky with testing it and kept leaving for
later to have a good documentation about testing it, vacation and perf
maintainership duties kept making this take like forever, grumble :-\

- Arnaldo



--
oh.. :'(


Re: pahole + BTF was: Re: [Question] bpf: about a new 'tools/bpf/bpf_dwarf2btf'

2018-07-25 Thread Taeung Song

Hi Arnaldo,

On 07/26/2018 02:52 AM, Arnaldo Carvalho de Melo wrote:

Em Thu, Jul 26, 2018 at 02:23:32AM +0900, Taeung Song escreveu:

Hi,

Building bpf programs with .BTF section,
I thought it'd be better to convert dwarf info to .BTF by
a new tool such as 'tools/bpf/bpf_dwarf2btf' instead of pahole
in the future.
  

Currently for bpf binary that have .BTF section,
we need to use pahole from https://github.com/iamkafai/pahole/tree/btf
with the command line such as "pahole -J bpf_prog.o".
  

I think it is great but if implementing new 'bpf_dwarf2btf'
(dwarf parsing + btf encoder code written by Martin KaFai Lau on
the pahole project i.e. btf.h, btf_encoder.c, btf_encoder.h,
libbtf.c, libbtf.h),
BPF developers would more easily use functionalities based on BTF.


What would be easier exactly? Not having to install a package but build
it from the kernel sources?

Many kernel developers already have pahole installed for other uses, so
no need to install anything.



Understood, but I think there are many non-kernel developers
developing BPF programs and they mightn't have or use pahole.

So, if providing the 'dwarf2btf' feature on tools/bpf or tools/bpf/bpftool,
non-kernel developers can also more easily build bpf prog with .BPF, no ?


BTW, Daniel, I just pushed to pahole's main repository at:

   git://git.kernel.org/pub/scm/devel/pahole/pahole.git

with the Martin's BTF patch, so no need to pull from the github one,
I'll tag v1.12 and announce the release so that distro package
maintainers can update their packages.
  

What do you think about this ? Do you think this is needed ?
Or, already implementing something like this ?
  

If it is needed, I want to try to make 'tools/bpf/bpf_dwarf2btf'
based on the pahole code. I'd appreciate it, if you reply to this


The way Martin took advantage of the work done a long time ago to
support CTF out of the same DWARF reading codebase was really cool, not
that much work to do, just add a new format to pahole's codebase making
it more useful.



I got it !

Thanks,
Taeung


I was just so far overly picky with testing it and kept leaving for
later to have a good documentation about testing it, vacation and perf
maintainership duties kept making this take like forever, grumble :-\

- Arnaldo



--
oh.. :'(


[Question] bpf: about a new 'tools/bpf/bpf_dwarf2btf'

2018-07-25 Thread Taeung Song

Hi,

Building bpf programs with .BTF section,
I thought it'd be better to convert dwarf info to .BTF by
a new tool such as 'tools/bpf/bpf_dwarf2btf' instead of pahole
in the future.

Currently for bpf binary that have .BTF section,
we need to use pahole from https://github.com/iamkafai/pahole/tree/btf
with the command line such as "pahole -J bpf_prog.o".

I think it is great but if implementing new 'bpf_dwarf2btf'
(dwarf parsing + btf encoder code written by Martin KaFai Lau on
the pahole project i.e. btf.h, btf_encoder.c, btf_encoder.h, libbtf.c, 
libbtf.h),

BPF developers would more easily use functionalities based on BTF.

What do you think about this ? Do you think this is needed ?
Or, already implementing something like this ?

If it is needed, I want to try to make 'tools/bpf/bpf_dwarf2btf'
based on the pahole code. I'd appreciate it, if you reply to this

Thanks,
Taeung


[Question] bpf: about a new 'tools/bpf/bpf_dwarf2btf'

2018-07-25 Thread Taeung Song

Hi,

Building bpf programs with .BTF section,
I thought it'd be better to convert dwarf info to .BTF by
a new tool such as 'tools/bpf/bpf_dwarf2btf' instead of pahole
in the future.

Currently for bpf binary that have .BTF section,
we need to use pahole from https://github.com/iamkafai/pahole/tree/btf
with the command line such as "pahole -J bpf_prog.o".

I think it is great but if implementing new 'bpf_dwarf2btf'
(dwarf parsing + btf encoder code written by Martin KaFai Lau on
the pahole project i.e. btf.h, btf_encoder.c, btf_encoder.h, libbtf.c, 
libbtf.h),

BPF developers would more easily use functionalities based on BTF.

What do you think about this ? Do you think this is needed ?
Or, already implementing something like this ?

If it is needed, I want to try to make 'tools/bpf/bpf_dwarf2btf'
based on the pahole code. I'd appreciate it, if you reply to this

Thanks,
Taeung


[PATCH] samples/bpf: Add BTF build flags to Makefile

2018-07-25 Thread Taeung Song
To smoothly test BTF supported binary on samples/bpf,
let samples/bpf/Makefile probe llc, pahole and
llvm-objcopy for BPF support and use them
like tools/testing/selftests/bpf/Makefile
changed from the commit c0fa1b6c3efc ("bpf: btf:
 Add BTF tests")

Cc: Martin KaFai Lau 
Signed-off-by: Taeung Song 
---
 samples/bpf/Makefile | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 1303af10e54d..e079266360a3 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -191,6 +191,8 @@ HOSTLOADLIBES_xdpsock   += -pthread
 #  make samples/bpf/ LLC=~/git/llvm/build/bin/llc 
CLANG=~/git/llvm/build/bin/clang
 LLC ?= llc
 CLANG ?= clang
+LLVM_OBJCOPY ?= llvm-objcopy
+BTF_PAHOLE ?= pahole
 
 # Detect that we're cross compiling and use the cross compiler
 ifdef CROSS_COMPILE
@@ -198,6 +200,20 @@ HOSTCC = $(CROSS_COMPILE)gcc
 CLANG_ARCH_ARGS = -target $(ARCH)
 endif
 
+BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
+BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
+BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 
'usage.*llvm')
+
+ifneq ($(BTF_LLC_PROBE),)
+ifneq ($(BTF_PAHOLE_PROBE),)
+ifneq ($(BTF_OBJCOPY_PROBE),)
+   EXTRA_CFLAGS += -g
+   LLC_FLAGS += -mattr=dwarfris
+   DWARF2BTF = y
+endif
+endif
+endif
+
 # Trick to allow make to be run from this directory
 all:
$(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
@@ -256,4 +272,7 @@ $(obj)/%.o: $(src)/%.c
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-address-of-packed-member -Wno-tautological-compare \
-Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
-   -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
+   -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) 
-filetype=obj -o $@
+ifeq ($(DWARF2BTF),y)
+   $(BTF_PAHOLE) -J $@
+endif
-- 
2.17.1



[PATCH] samples/bpf: Add BTF build flags to Makefile

2018-07-25 Thread Taeung Song
To smoothly test BTF supported binary on samples/bpf,
let samples/bpf/Makefile probe llc, pahole and
llvm-objcopy for BPF support and use them
like tools/testing/selftests/bpf/Makefile
changed from the commit c0fa1b6c3efc ("bpf: btf:
 Add BTF tests")

Cc: Martin KaFai Lau 
Signed-off-by: Taeung Song 
---
 samples/bpf/Makefile | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 1303af10e54d..e079266360a3 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -191,6 +191,8 @@ HOSTLOADLIBES_xdpsock   += -pthread
 #  make samples/bpf/ LLC=~/git/llvm/build/bin/llc 
CLANG=~/git/llvm/build/bin/clang
 LLC ?= llc
 CLANG ?= clang
+LLVM_OBJCOPY ?= llvm-objcopy
+BTF_PAHOLE ?= pahole
 
 # Detect that we're cross compiling and use the cross compiler
 ifdef CROSS_COMPILE
@@ -198,6 +200,20 @@ HOSTCC = $(CROSS_COMPILE)gcc
 CLANG_ARCH_ARGS = -target $(ARCH)
 endif
 
+BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
+BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
+BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 
'usage.*llvm')
+
+ifneq ($(BTF_LLC_PROBE),)
+ifneq ($(BTF_PAHOLE_PROBE),)
+ifneq ($(BTF_OBJCOPY_PROBE),)
+   EXTRA_CFLAGS += -g
+   LLC_FLAGS += -mattr=dwarfris
+   DWARF2BTF = y
+endif
+endif
+endif
+
 # Trick to allow make to be run from this directory
 all:
$(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
@@ -256,4 +272,7 @@ $(obj)/%.o: $(src)/%.c
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-address-of-packed-member -Wno-tautological-compare \
-Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
-   -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
+   -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) 
-filetype=obj -o $@
+ifeq ($(DWARF2BTF),y)
+   $(BTF_PAHOLE) -J $@
+endif
-- 
2.17.1



[PATCH v2 bpf-next] tools/bpftool: ignore build products

2018-07-25 Thread Taeung Song
For untracked things of tools/bpf, add this.

Reviewed-by: Jakub Kicinski 
Signed-off-by: Taeung Song 
---
 tools/bpf/.gitignore | 5 +
 tools/bpf/bpftool/.gitignore | 2 ++
 2 files changed, 7 insertions(+)
 create mode 100644 tools/bpf/.gitignore

diff --git a/tools/bpf/.gitignore b/tools/bpf/.gitignore
new file mode 100644
index ..dfe2bd5a4b95
--- /dev/null
+++ b/tools/bpf/.gitignore
@@ -0,0 +1,5 @@
+FEATURE-DUMP.bpf
+bpf_asm
+bpf_dbg
+bpf_exp.yacc.*
+bpf_jit_disasm
diff --git a/tools/bpf/bpftool/.gitignore b/tools/bpf/bpftool/.gitignore
index d7e678c2d396..67167e44b726 100644
--- a/tools/bpf/bpftool/.gitignore
+++ b/tools/bpf/bpftool/.gitignore
@@ -1,3 +1,5 @@
 *.d
 bpftool
+bpftool*.8
+bpf-helpers.*
 FEATURE-DUMP.bpftool
-- 
2.17.1



[PATCH v2 bpf-next] tools/bpftool: ignore build products

2018-07-25 Thread Taeung Song
For untracked things of tools/bpf, add this.

Reviewed-by: Jakub Kicinski 
Signed-off-by: Taeung Song 
---
 tools/bpf/.gitignore | 5 +
 tools/bpf/bpftool/.gitignore | 2 ++
 2 files changed, 7 insertions(+)
 create mode 100644 tools/bpf/.gitignore

diff --git a/tools/bpf/.gitignore b/tools/bpf/.gitignore
new file mode 100644
index ..dfe2bd5a4b95
--- /dev/null
+++ b/tools/bpf/.gitignore
@@ -0,0 +1,5 @@
+FEATURE-DUMP.bpf
+bpf_asm
+bpf_dbg
+bpf_exp.yacc.*
+bpf_jit_disasm
diff --git a/tools/bpf/bpftool/.gitignore b/tools/bpf/bpftool/.gitignore
index d7e678c2d396..67167e44b726 100644
--- a/tools/bpf/bpftool/.gitignore
+++ b/tools/bpf/bpftool/.gitignore
@@ -1,3 +1,5 @@
 *.d
 bpftool
+bpftool*.8
+bpf-helpers.*
 FEATURE-DUMP.bpftool
-- 
2.17.1



[PATCH bpf-next] tools/bpftool: ignore build products

2018-07-25 Thread Taeung Song
For untracked things of tools/bpf, add this.

Reviewed-by: Quentin Monnet 
Signed-off-by: Taeung Song 
---
 tools/bpf/.gitignore | 5 +
 tools/bpf/bpftool/.gitignore | 2 ++
 2 files changed, 7 insertions(+)
 create mode 100644 tools/bpf/.gitignore

diff --git a/tools/bpf/.gitignore b/tools/bpf/.gitignore
new file mode 100644
index ..dfe2bd5a4b95
--- /dev/null
+++ b/tools/bpf/.gitignore
@@ -0,0 +1,5 @@
+FEATURE-DUMP.bpf
+bpf_asm
+bpf_dbg
+bpf_exp.yacc.*
+bpf_jit_disasm
diff --git a/tools/bpf/bpftool/.gitignore b/tools/bpf/bpftool/.gitignore
index d7e678c2d396..67167e44b726 100644
--- a/tools/bpf/bpftool/.gitignore
+++ b/tools/bpf/bpftool/.gitignore
@@ -1,3 +1,5 @@
 *.d
 bpftool
+bpftool*.8
+bpf-helpers.*
 FEATURE-DUMP.bpftool
-- 
2.17.1



[PATCH bpf-next] tools/bpftool: ignore build products

2018-07-25 Thread Taeung Song
For untracked things of tools/bpf, add this.

Reviewed-by: Quentin Monnet 
Signed-off-by: Taeung Song 
---
 tools/bpf/.gitignore | 5 +
 tools/bpf/bpftool/.gitignore | 2 ++
 2 files changed, 7 insertions(+)
 create mode 100644 tools/bpf/.gitignore

diff --git a/tools/bpf/.gitignore b/tools/bpf/.gitignore
new file mode 100644
index ..dfe2bd5a4b95
--- /dev/null
+++ b/tools/bpf/.gitignore
@@ -0,0 +1,5 @@
+FEATURE-DUMP.bpf
+bpf_asm
+bpf_dbg
+bpf_exp.yacc.*
+bpf_jit_disasm
diff --git a/tools/bpf/bpftool/.gitignore b/tools/bpf/bpftool/.gitignore
index d7e678c2d396..67167e44b726 100644
--- a/tools/bpf/bpftool/.gitignore
+++ b/tools/bpf/bpftool/.gitignore
@@ -1,3 +1,5 @@
 *.d
 bpftool
+bpftool*.8
+bpf-helpers.*
 FEATURE-DUMP.bpftool
-- 
2.17.1



[PATCH v2 2/2] tools/bpftool: Fix segfault case regarding 'pin' arguments

2018-07-18 Thread Taeung Song
Arguments of 'pin' subcommand should be checked
at the very beginning of do_pin_any().
Otherwise segfault errors can occur when using
'map pin' or 'prog pin' commands, so fix it.

  # bpftool prog pin id
  Segmentation fault

Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
Reviewed-by: Jakub Kicinski 
Reported-by: Taehee Yoo 
Signed-off-by: Taeung Song 
---
 tools/bpf/bpftool/common.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 32f9e397a6c0..3f140eff039f 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -217,6 +217,14 @@ int do_pin_any(int argc, char **argv, int 
(*get_fd_by_id)(__u32))
int err;
int fd;
 
+   if (argc < 3) {
+   p_err("too few arguments, id ID and FILE path is required");
+   return -1;
+   } else if (argc > 3) {
+   p_err("too many arguments");
+   return -1;
+   }
+
if (!is_prefix(*argv, "id")) {
p_err("expected 'id' got %s", *argv);
return -1;
@@ -230,9 +238,6 @@ int do_pin_any(int argc, char **argv, int 
(*get_fd_by_id)(__u32))
}
NEXT_ARG();
 
-   if (argc != 1)
-   usage();
-
fd = get_fd_by_id(id);
if (fd < 0) {
p_err("can't get prog by id (%u): %s", id, strerror(errno));
-- 
2.17.1



[PATCH v2 2/2] tools/bpftool: Fix segfault case regarding 'pin' arguments

2018-07-18 Thread Taeung Song
Arguments of 'pin' subcommand should be checked
at the very beginning of do_pin_any().
Otherwise segfault errors can occur when using
'map pin' or 'prog pin' commands, so fix it.

  # bpftool prog pin id
  Segmentation fault

Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
Reviewed-by: Jakub Kicinski 
Reported-by: Taehee Yoo 
Signed-off-by: Taeung Song 
---
 tools/bpf/bpftool/common.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 32f9e397a6c0..3f140eff039f 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -217,6 +217,14 @@ int do_pin_any(int argc, char **argv, int 
(*get_fd_by_id)(__u32))
int err;
int fd;
 
+   if (argc < 3) {
+   p_err("too few arguments, id ID and FILE path is required");
+   return -1;
+   } else if (argc > 3) {
+   p_err("too many arguments");
+   return -1;
+   }
+
if (!is_prefix(*argv, "id")) {
p_err("expected 'id' got %s", *argv);
return -1;
@@ -230,9 +238,6 @@ int do_pin_any(int argc, char **argv, int 
(*get_fd_by_id)(__u32))
}
NEXT_ARG();
 
-   if (argc != 1)
-   usage();
-
fd = get_fd_by_id(id);
if (fd < 0) {
p_err("can't get prog by id (%u): %s", id, strerror(errno));
-- 
2.17.1



[PATCH v2 2/4] samples/bpf: Check the result of system()

2018-07-04 Thread Taeung Song
To avoid the below build warning message,
use new generate_load() checking the return value.

  ignoring return value of ‘system’, declared with attribute warn_unused_result

And it also refactors the duplicate code of both
test_perf_event_all_cpu() and test_perf_event_task()

Cc: Teng Qin 
Signed-off-by: Taeung Song 
---
 samples/bpf/trace_event_user.c | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
index 1fa1becfa641..d08046ab81f0 100644
--- a/samples/bpf/trace_event_user.c
+++ b/samples/bpf/trace_event_user.c
@@ -122,6 +122,16 @@ static void print_stacks(void)
}
 }
 
+static inline int generate_load(void)
+{
+   if (system("dd if=/dev/zero of=/dev/null count=5000k status=none") < 0) 
{
+   printf("failed to generate some load with dd: %s\n", 
strerror(errno));
+   return -1;
+   }
+
+   return 0;
+}
+
 static void test_perf_event_all_cpu(struct perf_event_attr *attr)
 {
int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
@@ -142,7 +152,11 @@ static void test_perf_event_all_cpu(struct perf_event_attr 
*attr)
assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 
0);
assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0);
}
-   system("dd if=/dev/zero of=/dev/null count=5000k status=none");
+
+   if (generate_load() < 0) {
+   error = 1;
+   goto all_cpu_err;
+   }
print_stacks();
 all_cpu_err:
for (i--; i >= 0; i--) {
@@ -156,7 +170,7 @@ static void test_perf_event_all_cpu(struct perf_event_attr 
*attr)
 
 static void test_perf_event_task(struct perf_event_attr *attr)
 {
-   int pmu_fd;
+   int pmu_fd, error = 0;
 
/* per task perf event, enable inherit so the "dd ..." command can be 
traced properly.
 * Enabling inherit will cause bpf_perf_prog_read_time helper failure.
@@ -171,10 +185,17 @@ static void test_perf_event_task(struct perf_event_attr 
*attr)
}
assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0);
-   system("dd if=/dev/zero of=/dev/null count=5000k status=none");
+
+   if (generate_load() < 0) {
+   error = 1;
+   goto err;
+   }
print_stacks();
+err:
ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
close(pmu_fd);
+   if (error)
+   int_exit(0);
 }
 
 static void test_bpf_perf_event(void)
-- 
2.17.1



[PATCH v2 0/4] samples/bpf: simple fixes

2018-07-04 Thread Taeung Song
v2:
- in error cases, do return; instead of break; in loop

Hello,
This patchset fixes trivial things that I found
when testing 'samples/bpf/' sample code.
I'd appreciate it, if you review this.

Thanks,
Taeung

Taeung Song (4):
  samples/bpf: add missing 
  samples/bpf: Check the result of system()
  samples/bpf: Check the error of write() and read()
  samples/bpf: add .gitignore file

 samples/bpf/.gitignore   | 49 
 samples/bpf/parse_varlen.c   |  6 +---
 samples/bpf/test_overhead_user.c | 19 ++---
 samples/bpf/trace_event_user.c   | 27 --
 4 files changed, 89 insertions(+), 12 deletions(-)
 create mode 100644 samples/bpf/.gitignore

-- 
2.17.1



[PATCH v2 1/4] samples/bpf: add missing

2018-07-04 Thread Taeung Song
This fixes build error regarding redefinition:

CLANG-bpf  samples/bpf/parse_varlen.o
  samples/bpf/parse_varlen.c:111:8: error: redefinition of 'vlan_hdr'
  struct vlan_hdr {
 ^
  ./include/linux/if_vlan.h:38:8: note: previous definition is here

So remove duplicate 'struct vlan_hdr' in sample code and include if_vlan.h

Signed-off-by: Taeung Song 
---
 samples/bpf/parse_varlen.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
index 95c16324760c..0b6f22feb2c9 100644
--- a/samples/bpf/parse_varlen.c
+++ b/samples/bpf/parse_varlen.c
@@ -6,6 +6,7 @@
  */
 #define KBUILD_MODNAME "foo"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -108,11 +109,6 @@ static int parse_ipv6(void *data, uint64_t nh_off, void 
*data_end)
return 0;
 }
 
-struct vlan_hdr {
-   uint16_t h_vlan_TCI;
-   uint16_t h_vlan_encapsulated_proto;
-};
-
 SEC("varlen")
 int handle_ingress(struct __sk_buff *skb)
 {
-- 
2.17.1



[PATCH v2 4/4] samples/bpf: add .gitignore file

2018-07-04 Thread Taeung Song
For untracked executables of samples/bpf, add this.

  Untracked files:
(use "git add ..." to include in what will be committed)

samples/bpf/cpustat
samples/bpf/fds_example
samples/bpf/lathist
samples/bpf/load_sock_ops
...

Signed-off-by: Taeung Song 
---
 samples/bpf/.gitignore | 49 ++
 1 file changed, 49 insertions(+)
 create mode 100644 samples/bpf/.gitignore

diff --git a/samples/bpf/.gitignore b/samples/bpf/.gitignore
new file mode 100644
index ..8ae4940025f8
--- /dev/null
+++ b/samples/bpf/.gitignore
@@ -0,0 +1,49 @@
+cpustat
+fds_example
+lathist
+load_sock_ops
+lwt_len_hist
+map_perf_test
+offwaketime
+per_socket_stats_example
+sampleip
+sock_example
+sockex1
+sockex2
+sockex3
+spintest
+syscall_nrs.h
+syscall_tp
+task_fd_query
+tc_l2_redirect
+test_cgrp2_array_pin
+test_cgrp2_attach
+test_cgrp2_attach2
+test_cgrp2_sock
+test_cgrp2_sock2
+test_current_task_under_cgroup
+test_lru_dist
+test_map_in_map
+test_overhead
+test_probe_write_user
+trace_event
+trace_output
+tracex1
+tracex2
+tracex3
+tracex4
+tracex5
+tracex6
+tracex7
+xdp1
+xdp2
+xdp_adjust_tail
+xdp_fwd
+xdp_monitor
+xdp_redirect
+xdp_redirect_cpu
+xdp_redirect_map
+xdp_router_ipv4
+xdp_rxq_info
+xdp_tx_iptunnel
+xdpsock
-- 
2.17.1



[PATCH v2 2/4] samples/bpf: Check the result of system()

2018-07-04 Thread Taeung Song
To avoid the below build warning message,
use new generate_load() checking the return value.

  ignoring return value of ‘system’, declared with attribute warn_unused_result

And it also refactors the duplicate code of both
test_perf_event_all_cpu() and test_perf_event_task()

Cc: Teng Qin 
Signed-off-by: Taeung Song 
---
 samples/bpf/trace_event_user.c | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
index 1fa1becfa641..d08046ab81f0 100644
--- a/samples/bpf/trace_event_user.c
+++ b/samples/bpf/trace_event_user.c
@@ -122,6 +122,16 @@ static void print_stacks(void)
}
 }
 
+static inline int generate_load(void)
+{
+   if (system("dd if=/dev/zero of=/dev/null count=5000k status=none") < 0) 
{
+   printf("failed to generate some load with dd: %s\n", 
strerror(errno));
+   return -1;
+   }
+
+   return 0;
+}
+
 static void test_perf_event_all_cpu(struct perf_event_attr *attr)
 {
int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
@@ -142,7 +152,11 @@ static void test_perf_event_all_cpu(struct perf_event_attr 
*attr)
assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 
0);
assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0);
}
-   system("dd if=/dev/zero of=/dev/null count=5000k status=none");
+
+   if (generate_load() < 0) {
+   error = 1;
+   goto all_cpu_err;
+   }
print_stacks();
 all_cpu_err:
for (i--; i >= 0; i--) {
@@ -156,7 +170,7 @@ static void test_perf_event_all_cpu(struct perf_event_attr 
*attr)
 
 static void test_perf_event_task(struct perf_event_attr *attr)
 {
-   int pmu_fd;
+   int pmu_fd, error = 0;
 
/* per task perf event, enable inherit so the "dd ..." command can be 
traced properly.
 * Enabling inherit will cause bpf_perf_prog_read_time helper failure.
@@ -171,10 +185,17 @@ static void test_perf_event_task(struct perf_event_attr 
*attr)
}
assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0);
-   system("dd if=/dev/zero of=/dev/null count=5000k status=none");
+
+   if (generate_load() < 0) {
+   error = 1;
+   goto err;
+   }
print_stacks();
+err:
ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
close(pmu_fd);
+   if (error)
+   int_exit(0);
 }
 
 static void test_bpf_perf_event(void)
-- 
2.17.1



[PATCH v2 0/4] samples/bpf: simple fixes

2018-07-04 Thread Taeung Song
v2:
- in error cases, do return; instead of break; in loop

Hello,
This patchset fixes trivial things that I found
when testing 'samples/bpf/' sample code.
I'd appreciate it, if you review this.

Thanks,
Taeung

Taeung Song (4):
  samples/bpf: add missing 
  samples/bpf: Check the result of system()
  samples/bpf: Check the error of write() and read()
  samples/bpf: add .gitignore file

 samples/bpf/.gitignore   | 49 
 samples/bpf/parse_varlen.c   |  6 +---
 samples/bpf/test_overhead_user.c | 19 ++---
 samples/bpf/trace_event_user.c   | 27 --
 4 files changed, 89 insertions(+), 12 deletions(-)
 create mode 100644 samples/bpf/.gitignore

-- 
2.17.1



[PATCH v2 1/4] samples/bpf: add missing

2018-07-04 Thread Taeung Song
This fixes build error regarding redefinition:

CLANG-bpf  samples/bpf/parse_varlen.o
  samples/bpf/parse_varlen.c:111:8: error: redefinition of 'vlan_hdr'
  struct vlan_hdr {
 ^
  ./include/linux/if_vlan.h:38:8: note: previous definition is here

So remove duplicate 'struct vlan_hdr' in sample code and include if_vlan.h

Signed-off-by: Taeung Song 
---
 samples/bpf/parse_varlen.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
index 95c16324760c..0b6f22feb2c9 100644
--- a/samples/bpf/parse_varlen.c
+++ b/samples/bpf/parse_varlen.c
@@ -6,6 +6,7 @@
  */
 #define KBUILD_MODNAME "foo"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -108,11 +109,6 @@ static int parse_ipv6(void *data, uint64_t nh_off, void 
*data_end)
return 0;
 }
 
-struct vlan_hdr {
-   uint16_t h_vlan_TCI;
-   uint16_t h_vlan_encapsulated_proto;
-};
-
 SEC("varlen")
 int handle_ingress(struct __sk_buff *skb)
 {
-- 
2.17.1



[PATCH v2 4/4] samples/bpf: add .gitignore file

2018-07-04 Thread Taeung Song
For untracked executables of samples/bpf, add this.

  Untracked files:
(use "git add ..." to include in what will be committed)

samples/bpf/cpustat
samples/bpf/fds_example
samples/bpf/lathist
samples/bpf/load_sock_ops
...

Signed-off-by: Taeung Song 
---
 samples/bpf/.gitignore | 49 ++
 1 file changed, 49 insertions(+)
 create mode 100644 samples/bpf/.gitignore

diff --git a/samples/bpf/.gitignore b/samples/bpf/.gitignore
new file mode 100644
index ..8ae4940025f8
--- /dev/null
+++ b/samples/bpf/.gitignore
@@ -0,0 +1,49 @@
+cpustat
+fds_example
+lathist
+load_sock_ops
+lwt_len_hist
+map_perf_test
+offwaketime
+per_socket_stats_example
+sampleip
+sock_example
+sockex1
+sockex2
+sockex3
+spintest
+syscall_nrs.h
+syscall_tp
+task_fd_query
+tc_l2_redirect
+test_cgrp2_array_pin
+test_cgrp2_attach
+test_cgrp2_attach2
+test_cgrp2_sock
+test_cgrp2_sock2
+test_current_task_under_cgroup
+test_lru_dist
+test_map_in_map
+test_overhead
+test_probe_write_user
+trace_event
+trace_output
+tracex1
+tracex2
+tracex3
+tracex4
+tracex5
+tracex6
+tracex7
+xdp1
+xdp2
+xdp_adjust_tail
+xdp_fwd
+xdp_monitor
+xdp_redirect
+xdp_redirect_cpu
+xdp_redirect_map
+xdp_router_ipv4
+xdp_rxq_info
+xdp_tx_iptunnel
+xdpsock
-- 
2.17.1



[tip:perf/core] tools lib traceevent: Fix missing break in FALSE case of pevent_filter_clear_trivial()

2018-01-17 Thread tip-bot for Taeung Song
Commit-ID:  806efaed3cacab1521895d20bb3b5ed610909299
Gitweb: https://git.kernel.org/tip/806efaed3cacab1521895d20bb3b5ed610909299
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Thu, 11 Jan 2018 19:47:50 -0500
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Wed, 17 Jan 2018 10:22:57 -0300

tools lib traceevent: Fix missing break in FALSE case of 
pevent_filter_clear_trivial()

Currently the FILTER_TRIVIAL_FALSE case has a missing break statement,
if the trivial type is FALSE, it will also run into the TRUE case, and
always be skipped as the TRUE statement will continue the loop on the
inverse condition of the FALSE statement.

Reported-by: Namhyung Kim <namhy...@kernel.org>
Acked-by: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Cc: Andrew Morton <a...@linux-foundation.org>
Link: http://lkml.kernel.org/r/20180112004823.012918...@goodmis.org
Link: 
http://lkml.kernel.org/r/1493218540-12296-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Steven Rostedt <rost...@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/lib/traceevent/parse-filter.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/lib/traceevent/parse-filter.c 
b/tools/lib/traceevent/parse-filter.c
index 2410afd..2b9048f 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1631,6 +1631,7 @@ int pevent_filter_clear_trivial(struct event_filter 
*filter,
case FILTER_TRIVIAL_FALSE:
if (filter_type->filter->boolean.value)
continue;
+   break;
case FILTER_TRIVIAL_TRUE:
if (!filter_type->filter->boolean.value)
continue;


[tip:perf/core] tools lib traceevent: Fix missing break in FALSE case of pevent_filter_clear_trivial()

2018-01-17 Thread tip-bot for Taeung Song
Commit-ID:  806efaed3cacab1521895d20bb3b5ed610909299
Gitweb: https://git.kernel.org/tip/806efaed3cacab1521895d20bb3b5ed610909299
Author: Taeung Song 
AuthorDate: Thu, 11 Jan 2018 19:47:50 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 17 Jan 2018 10:22:57 -0300

tools lib traceevent: Fix missing break in FALSE case of 
pevent_filter_clear_trivial()

Currently the FILTER_TRIVIAL_FALSE case has a missing break statement,
if the trivial type is FALSE, it will also run into the TRUE case, and
always be skipped as the TRUE statement will continue the loop on the
inverse condition of the FALSE statement.

Reported-by: Namhyung Kim 
Acked-by: Namhyung Kim 
Signed-off-by: Taeung Song 
Cc: Andrew Morton 
Link: http://lkml.kernel.org/r/20180112004823.012918...@goodmis.org
Link: 
http://lkml.kernel.org/r/1493218540-12296-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Steven Rostedt 
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/traceevent/parse-filter.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/lib/traceevent/parse-filter.c 
b/tools/lib/traceevent/parse-filter.c
index 2410afd..2b9048f 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1631,6 +1631,7 @@ int pevent_filter_clear_trivial(struct event_filter 
*filter,
case FILTER_TRIVIAL_FALSE:
if (filter_type->filter->boolean.value)
continue;
+   break;
case FILTER_TRIVIAL_TRUE:
if (!filter_type->filter->boolean.value)
continue;


Re: [PATCH 09/10] lib traceeevent: Fix missing break in FALSE case of pevent_filter_clear_trivial()

2018-01-11 Thread Taeung Song

Hi Steven,

I found a trivial typo "eee" on the commit log title
It seems better to change "lib traceeevent" to " lib traceevent",
if you want to do it..

Thanks,
Taeung

On 01/12/2018 09:47 AM, Steven Rostedt wrote:


Re: [PATCH 09/10] lib traceeevent: Fix missing break in FALSE case of pevent_filter_clear_trivial()

2018-01-11 Thread Taeung Song

Hi Steven,

I found a trivial typo "eee" on the commit log title
It seems better to change "lib traceeevent" to " lib traceevent",
if you want to do it..

Thanks,
Taeung

On 01/12/2018 09:47 AM, Steven Rostedt wrote:


Re: [PATCH 1/3] perf help: Document missing options

2017-11-13 Thread Taeung Song

Hi Arnaldo and Namhyung :)

On 11/14/2017 09:15 AM, Namhyung Kim wrote:

Hi Arnaldo,

On Mon, Nov 13, 2017 at 03:29:56PM -0300, Arnaldo Carvalho de Melo wrote:

Em Sun, Nov 12, 2017 at 10:10:45AM +0900, Sihyeon Jang escreveu:

Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Sihyeon Jang <uneedsihy...@gmail.com>
---
  tools/perf/Documentation/perf-help.txt | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-help.txt 
b/tools/perf/Documentation/perf-help.txt
index 5143918..bb605af 100644
--- a/tools/perf/Documentation/perf-help.txt
+++ b/tools/perf/Documentation/perf-help.txt
@@ -7,7 +7,7 @@ perf-help - display help information about perf
  
  SYNOPSIS

  
-'perf help' [-a|--all] [COMMAND]
+'perf help' [--all] [--man|--web|--info] [COMMAND]


Can you try figuring out if this actually works? I tried here and it
doesn't, its an area we took "for free" when we copied the initial
codebase from git.git, but I never looked at this area that much, now
that I try:


Yeah, I'm not sure we need to keep it.




[acme@jouet linux]$ perf help
Config with no key for man viewer: childrenError: wrong config key-value pair 
top.children=true
[acme@jouet linux]$

Unsure if this is something that got broken by the 'perf config'
patches, Taeung?


Looks like a bug in 8e99b6d4533c ("tools include: Adopt strstarts()
from the kernel").

Following patch should fix it:

Thanks,
Namhyung


I also checked this error and test the below patch.
It seems that Namhyung already fixes it !!

Thanks,
Taeung




 From 096b78b437b5758acc025498e88d73d9d471b3c0 Mon Sep 17 00:00:00 2001
From: Namhyung Kim <namhy...@kernel.org>
Date: Tue, 14 Nov 2017 09:10:43 +0900
Subject: [PATCH] perf help: Fix a bug during strstart() conversion

The commit 8e99b6d4533c changed prefixcmp() to strstart() but missed to
change the return value in some place.  It makes perf help print
annoying output even for sane config items like below:

   $ perf help
   '.root': unsupported man viewer sub key.
   ...

Fixes: 8e99b6d4533c ("tools include: Adopt strstarts() from the kernel")
Cc: Taeung Song <treeze.tae...@gmail.com>
Signed-off-by: Namhyung Kim <namhy...@kernel.org>
---
  tools/perf/builtin-help.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index dbe4e4153bcf..ff51e5fc0daf 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -283,7 +283,7 @@ static int perf_help_config(const char *var, const char 
*value, void *cb)
add_man_viewer(value);
return 0;
}
-   if (!strstarts(var, "man."))
+   if (strstarts(var, "man."))
return add_man_viewer_info(var, value);
  
  	return 0;

@@ -313,7 +313,7 @@ static const char *cmd_to_page(const char *perf_cmd)
  
  	if (!perf_cmd)

return "perf";
-   else if (!strstarts(perf_cmd, "perf"))
+   else if (strstarts(perf_cmd, "perf"))
return perf_cmd;
  
  	return asprintf(, "perf-%s", perf_cmd) < 0 ? NULL : s;




Re: [PATCH 1/3] perf help: Document missing options

2017-11-13 Thread Taeung Song

Hi Arnaldo and Namhyung :)

On 11/14/2017 09:15 AM, Namhyung Kim wrote:

Hi Arnaldo,

On Mon, Nov 13, 2017 at 03:29:56PM -0300, Arnaldo Carvalho de Melo wrote:

Em Sun, Nov 12, 2017 at 10:10:45AM +0900, Sihyeon Jang escreveu:

Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Sihyeon Jang 
---
  tools/perf/Documentation/perf-help.txt | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-help.txt 
b/tools/perf/Documentation/perf-help.txt
index 5143918..bb605af 100644
--- a/tools/perf/Documentation/perf-help.txt
+++ b/tools/perf/Documentation/perf-help.txt
@@ -7,7 +7,7 @@ perf-help - display help information about perf
  
  SYNOPSIS

  
-'perf help' [-a|--all] [COMMAND]
+'perf help' [--all] [--man|--web|--info] [COMMAND]


Can you try figuring out if this actually works? I tried here and it
doesn't, its an area we took "for free" when we copied the initial
codebase from git.git, but I never looked at this area that much, now
that I try:


Yeah, I'm not sure we need to keep it.




[acme@jouet linux]$ perf help
Config with no key for man viewer: childrenError: wrong config key-value pair 
top.children=true
[acme@jouet linux]$

Unsure if this is something that got broken by the 'perf config'
patches, Taeung?


Looks like a bug in 8e99b6d4533c ("tools include: Adopt strstarts()
from the kernel").

Following patch should fix it:

Thanks,
Namhyung


I also checked this error and test the below patch.
It seems that Namhyung already fixes it !!

Thanks,
Taeung




 From 096b78b437b5758acc025498e88d73d9d471b3c0 Mon Sep 17 00:00:00 2001
From: Namhyung Kim 
Date: Tue, 14 Nov 2017 09:10:43 +0900
Subject: [PATCH] perf help: Fix a bug during strstart() conversion

The commit 8e99b6d4533c changed prefixcmp() to strstart() but missed to
change the return value in some place.  It makes perf help print
annoying output even for sane config items like below:

   $ perf help
   '.root': unsupported man viewer sub key.
   ...

Fixes: 8e99b6d4533c ("tools include: Adopt strstarts() from the kernel")
Cc: Taeung Song 
Signed-off-by: Namhyung Kim 
---
  tools/perf/builtin-help.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index dbe4e4153bcf..ff51e5fc0daf 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -283,7 +283,7 @@ static int perf_help_config(const char *var, const char 
*value, void *cb)
add_man_viewer(value);
return 0;
}
-   if (!strstarts(var, "man."))
+   if (strstarts(var, "man."))
return add_man_viewer_info(var, value);
  
  	return 0;

@@ -313,7 +313,7 @@ static const char *cmd_to_page(const char *perf_cmd)
  
  	if (!perf_cmd)

return "perf";
-   else if (!strstarts(perf_cmd, "perf"))
+   else if (strstarts(perf_cmd, "perf"))
return perf_cmd;
  
  	return asprintf(, "perf-%s", perf_cmd) < 0 ? NULL : s;




[tip:perf/urgent] perf record: Fix documentation for a inexistent option '-l'

2017-10-20 Thread tip-bot for Taeung Song
Commit-ID:  3f50f614d61f91ad30b1947c429d1f235493a7f9
Gitweb: https://git.kernel.org/tip/3f50f614d61f91ad30b1947c429d1f235493a7f9
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Sat, 14 Oct 2017 00:10:12 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 17 Oct 2017 09:05:36 -0300

perf record: Fix documentation for a inexistent option '-l'

'perf record' had a '-l' option that meant "scale counter values" a very
long time ago, but it currently belongs to 'perf stat' as '-c'.  So
remove it. I found this problem in the below case.

$ perf record -e cycles -l sleep 3
  Error: unknown switch `l

Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Link: 
http://lkml.kernel.org/r/1507907412-19813-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Documentation/perf-record.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index e397453..63526f4 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -8,8 +8,8 @@ perf-record - Run a command and record its profile into 
perf.data
 SYNOPSIS
 
 [verse]
-'perf record' [-e  | --event=EVENT] [-l] [-a] 
-'perf record' [-e  | --event=EVENT] [-l] [-a] --  []
+'perf record' [-e  | --event=EVENT] [-a] 
+'perf record' [-e  | --event=EVENT] [-a] --  []
 
 DESCRIPTION
 ---


[tip:perf/urgent] perf record: Fix documentation for a inexistent option '-l'

2017-10-20 Thread tip-bot for Taeung Song
Commit-ID:  3f50f614d61f91ad30b1947c429d1f235493a7f9
Gitweb: https://git.kernel.org/tip/3f50f614d61f91ad30b1947c429d1f235493a7f9
Author: Taeung Song 
AuthorDate: Sat, 14 Oct 2017 00:10:12 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 17 Oct 2017 09:05:36 -0300

perf record: Fix documentation for a inexistent option '-l'

'perf record' had a '-l' option that meant "scale counter values" a very
long time ago, but it currently belongs to 'perf stat' as '-c'.  So
remove it. I found this problem in the below case.

$ perf record -e cycles -l sleep 3
  Error: unknown switch `l

Signed-off-by: Taeung Song 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1507907412-19813-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-record.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index e397453..63526f4 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -8,8 +8,8 @@ perf-record - Run a command and record its profile into 
perf.data
 SYNOPSIS
 
 [verse]
-'perf record' [-e  | --event=EVENT] [-l] [-a] 
-'perf record' [-e  | --event=EVENT] [-l] [-a] --  []
+'perf record' [-e  | --event=EVENT] [-a] 
+'perf record' [-e  | --event=EVENT] [-a] --  []
 
 DESCRIPTION
 ---


[PATCH RESEND] perf record: Fix documentation for a disused option '-l'

2017-10-13 Thread Taeung Song
perf-record had a '-l' option that mean "scale counter values"
very long time ago, but it currently belong to perf-stat as '-c'.
So remove it. I found this problem in the below case.

$ perf record -e cycles -l sleep 3
  Error: unknown switch `l

Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/Documentation/perf-record.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index 68a1ffb..5a626ef 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -8,8 +8,8 @@ perf-record - Run a command and record its profile into 
perf.data
 SYNOPSIS
 
 [verse]
-'perf record' [-e  | --event=EVENT] [-l] [-a] 
-'perf record' [-e  | --event=EVENT] [-l] [-a] --  []
+'perf record' [-e  | --event=EVENT] [-a] 
+'perf record' [-e  | --event=EVENT] [-a] --  []
 
 DESCRIPTION
 ---
-- 
2.7.4



[PATCH RESEND] perf record: Fix documentation for a disused option '-l'

2017-10-13 Thread Taeung Song
perf-record had a '-l' option that mean "scale counter values"
very long time ago, but it currently belong to perf-stat as '-c'.
So remove it. I found this problem in the below case.

$ perf record -e cycles -l sleep 3
  Error: unknown switch `l

Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-record.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index 68a1ffb..5a626ef 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -8,8 +8,8 @@ perf-record - Run a command and record its profile into 
perf.data
 SYNOPSIS
 
 [verse]
-'perf record' [-e  | --event=EVENT] [-l] [-a] 
-'perf record' [-e  | --event=EVENT] [-l] [-a] --  []
+'perf record' [-e  | --event=EVENT] [-a] 
+'perf record' [-e  | --event=EVENT] [-a] --  []
 
 DESCRIPTION
 ---
-- 
2.7.4



[PATCH] perf record: Remove a disused option '-l'

2017-10-13 Thread Taeung Song
perf-record had a '-l' option that mean "scale counter values"
very long time ago, but it currently belong to perf-stat as '-c'.
So remove it. I found this problem in the below case.

$ perf record -e cycles -l sleep 3
  Error: unknown switch `l

Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/Documentation/perf-record.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index 68a1ffb..5a626ef 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -8,8 +8,8 @@ perf-record - Run a command and record its profile into 
perf.data
 SYNOPSIS
 
 [verse]
-'perf record' [-e  | --event=EVENT] [-l] [-a] 
-'perf record' [-e  | --event=EVENT] [-l] [-a] --  []
+'perf record' [-e  | --event=EVENT] [-a] 
+'perf record' [-e  | --event=EVENT] [-a] --  []
 
 DESCRIPTION
 ---
-- 
2.7.4



[PATCH] perf record: Remove a disused option '-l'

2017-10-13 Thread Taeung Song
perf-record had a '-l' option that mean "scale counter values"
very long time ago, but it currently belong to perf-stat as '-c'.
So remove it. I found this problem in the below case.

$ perf record -e cycles -l sleep 3
  Error: unknown switch `l

Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-record.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index 68a1ffb..5a626ef 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -8,8 +8,8 @@ perf-record - Run a command and record its profile into 
perf.data
 SYNOPSIS
 
 [verse]
-'perf record' [-e  | --event=EVENT] [-l] [-a] 
-'perf record' [-e  | --event=EVENT] [-l] [-a] --  []
+'perf record' [-e  | --event=EVENT] [-a] 
+'perf record' [-e  | --event=EVENT] [-a] --  []
 
 DESCRIPTION
 ---
-- 
2.7.4



[tip:perf/core] perf config: Allow creating empty config set for config file autogeneration

2017-09-22 Thread tip-bot for Taeung Song
Commit-ID:  55421b4fb7054f85274b1b6a321e204dac696133
Gitweb: http://git.kernel.org/tip/55421b4fb7054f85274b1b6a321e204dac696133
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Thu, 7 Sep 2017 12:18:56 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Wed, 13 Sep 2017 09:49:16 -0300

perf config: Allow creating empty config set for config file autogeneration

When there isn't a config file (e.g. ~/.perfconfig) or it has nothing,
the config set wasn't created.

If the config set does not exist, a config file can't be autogenerated.

So allow creating a empty config set in the above case,
then we can support the config file autogeneration.

Before:

  $ rm -f ~/.perfconfig
  $ perf config --user report.children=false

  $ cat ~/.perfconfig
  cat: /root/.perfconfig: No such file or directory

But I think it should work even if there isn't a config file.

After:

  $ rm -f ~/.perfconfig
  $ perf config --user report.children=false

  $ cat ~/.perfconfig
  # this file is auto-generated.
  [report]
  children = false

NOTE:

As a result, if perf_config_set__init() fails, it looks as if the config
set isn't freed. But it isn't a problem.  Because the config set will be
freed by perf_config_set__delete() at the end of cmd_config().

Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Link: 
http://lkml.kernel.org/r/1504754336-9824-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/util/config.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index bc75596..d2b6983 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -700,10 +700,7 @@ struct perf_config_set *perf_config_set__new(void)
 
if (set) {
INIT_LIST_HEAD(>sections);
-   if (perf_config_set__init(set) < 0) {
-   perf_config_set__delete(set);
-   set = NULL;
-   }
+   perf_config_set__init(set);
}
 
return set;


[tip:perf/core] perf config: Allow creating empty config set for config file autogeneration

2017-09-22 Thread tip-bot for Taeung Song
Commit-ID:  55421b4fb7054f85274b1b6a321e204dac696133
Gitweb: http://git.kernel.org/tip/55421b4fb7054f85274b1b6a321e204dac696133
Author: Taeung Song 
AuthorDate: Thu, 7 Sep 2017 12:18:56 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 13 Sep 2017 09:49:16 -0300

perf config: Allow creating empty config set for config file autogeneration

When there isn't a config file (e.g. ~/.perfconfig) or it has nothing,
the config set wasn't created.

If the config set does not exist, a config file can't be autogenerated.

So allow creating a empty config set in the above case,
then we can support the config file autogeneration.

Before:

  $ rm -f ~/.perfconfig
  $ perf config --user report.children=false

  $ cat ~/.perfconfig
  cat: /root/.perfconfig: No such file or directory

But I think it should work even if there isn't a config file.

After:

  $ rm -f ~/.perfconfig
  $ perf config --user report.children=false

  $ cat ~/.perfconfig
  # this file is auto-generated.
  [report]
  children = false

NOTE:

As a result, if perf_config_set__init() fails, it looks as if the config
set isn't freed. But it isn't a problem.  Because the config set will be
freed by perf_config_set__delete() at the end of cmd_config().

Signed-off-by: Taeung Song 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1504754336-9824-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/config.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index bc75596..d2b6983 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -700,10 +700,7 @@ struct perf_config_set *perf_config_set__new(void)
 
if (set) {
INIT_LIST_HEAD(>sections);
-   if (perf_config_set__init(set) < 0) {
-   perf_config_set__delete(set);
-   set = NULL;
-   }
+   perf_config_set__init(set);
}
 
return set;


[tip:perf/core] perf config: Write a config file just once

2017-09-22 Thread tip-bot for Taeung Song
Commit-ID:  5c2615556d4410baebc9b336f14befe0bb32cde4
Gitweb: http://git.kernel.org/tip/5c2615556d4410baebc9b336f14befe0bb32cde4
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Thu, 7 Sep 2017 12:18:51 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Wed, 13 Sep 2017 09:49:15 -0300

perf config: Write a config file just once

Currently set_config() can be repeatedly called for each input config on
the below case:

  $ perf config kmem.default=slab report.children=false ...

But it's a waste, so only once write a config file gathering all given
config key=value pairs.

Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Link: 
http://lkml.kernel.org/r/1504754331-9776-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/builtin-config.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index a1d82e3..b89417d 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -34,8 +34,7 @@ static struct option config_options[] = {
OPT_END()
 };
 
-static int set_config(struct perf_config_set *set, const char *file_name,
- const char *var, const char *value)
+static int set_config(struct perf_config_set *set, const char *file_name)
 {
struct perf_config_section *section = NULL;
struct perf_config_item *item = NULL;
@@ -49,7 +48,6 @@ static int set_config(struct perf_config_set *set, const char 
*file_name,
if (!fp)
return -1;
 
-   perf_config_set__collect(set, file_name, var, value);
fprintf(fp, "%s\n", first_line);
 
/* overwrite configvariables */
@@ -161,6 +159,7 @@ int cmd_config(int argc, const char **argv)
struct perf_config_set *set;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
const char *config_filename;
+   bool changed = false;
 
argc = parse_options(argc, argv, config_options, config_usage,
 PARSE_OPT_STOP_AT_NON_OPTION);
@@ -231,15 +230,26 @@ int cmd_config(int argc, const char **argv)
goto out_err;
}
} else {
-   if (set_config(set, config_filename, var, 
value) < 0) {
-   pr_err("Failed to set '%s=%s' on %s\n",
-  var, value, config_filename);
+   if (perf_config_set__collect(set, 
config_filename,
+var, value) < 0) {
+   pr_err("Failed to add '%s=%s'\n",
+  var, value);
free(arg);
goto out_err;
}
+   changed = true;
}
free(arg);
}
+
+   if (!changed)
+   break;
+
+   if (set_config(set, config_filename) < 0) {
+   pr_err("Failed to set the configs on %s\n",
+  config_filename);
+   goto out_err;
+   }
}
 
ret = 0;


[tip:perf/core] perf config: Write a config file just once

2017-09-22 Thread tip-bot for Taeung Song
Commit-ID:  5c2615556d4410baebc9b336f14befe0bb32cde4
Gitweb: http://git.kernel.org/tip/5c2615556d4410baebc9b336f14befe0bb32cde4
Author: Taeung Song 
AuthorDate: Thu, 7 Sep 2017 12:18:51 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 13 Sep 2017 09:49:15 -0300

perf config: Write a config file just once

Currently set_config() can be repeatedly called for each input config on
the below case:

  $ perf config kmem.default=slab report.children=false ...

But it's a waste, so only once write a config file gathering all given
config key=value pairs.

Signed-off-by: Taeung Song 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1504754331-9776-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-config.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index a1d82e3..b89417d 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -34,8 +34,7 @@ static struct option config_options[] = {
OPT_END()
 };
 
-static int set_config(struct perf_config_set *set, const char *file_name,
- const char *var, const char *value)
+static int set_config(struct perf_config_set *set, const char *file_name)
 {
struct perf_config_section *section = NULL;
struct perf_config_item *item = NULL;
@@ -49,7 +48,6 @@ static int set_config(struct perf_config_set *set, const char 
*file_name,
if (!fp)
return -1;
 
-   perf_config_set__collect(set, file_name, var, value);
fprintf(fp, "%s\n", first_line);
 
/* overwrite configvariables */
@@ -161,6 +159,7 @@ int cmd_config(int argc, const char **argv)
struct perf_config_set *set;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
const char *config_filename;
+   bool changed = false;
 
argc = parse_options(argc, argv, config_options, config_usage,
 PARSE_OPT_STOP_AT_NON_OPTION);
@@ -231,15 +230,26 @@ int cmd_config(int argc, const char **argv)
goto out_err;
}
} else {
-   if (set_config(set, config_filename, var, 
value) < 0) {
-   pr_err("Failed to set '%s=%s' on %s\n",
-  var, value, config_filename);
+   if (perf_config_set__collect(set, 
config_filename,
+var, value) < 0) {
+   pr_err("Failed to add '%s=%s'\n",
+  var, value);
free(arg);
goto out_err;
}
+   changed = true;
}
free(arg);
}
+
+   if (!changed)
+   break;
+
+   if (set_config(set, config_filename) < 0) {
+   pr_err("Failed to set the configs on %s\n",
+  config_filename);
+   goto out_err;
+   }
}
 
ret = 0;


[tip:perf/urgent] perf config: Check not only section->from_system_config but also item's

2017-09-13 Thread tip-bot for Taeung Song
Commit-ID:  cba225d6eeaf00bd8181a851fbaa7b8716337e0b
Gitweb: http://git.kernel.org/tip/cba225d6eeaf00bd8181a851fbaa7b8716337e0b
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Thu, 7 Sep 2017 12:18:45 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 12 Sep 2017 12:35:11 -0300

perf config: Check not only section->from_system_config but also item's

Currently section->from_system_config is being checked multiple times.
item->from_system_config should be checked instead, when iterating thru
the items in a section. Fix it.

Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Link: 
http://lkml.kernel.org/r/1504754325-9724-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/builtin-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 3ddcc6e..a1d82e3 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -59,7 +59,7 @@ static int set_config(struct perf_config_set *set, const char 
*file_name,
fprintf(fp, "[%s]\n", section->name);
 
perf_config_items__for_each_entry(>items, item) {
-   if (!use_system_config && section->from_system_config)
+   if (!use_system_config && item->from_system_config)
continue;
if (item->value)
fprintf(fp, "\t%s = %s\n",


[tip:perf/urgent] perf config: Check not only section->from_system_config but also item's

2017-09-13 Thread tip-bot for Taeung Song
Commit-ID:  cba225d6eeaf00bd8181a851fbaa7b8716337e0b
Gitweb: http://git.kernel.org/tip/cba225d6eeaf00bd8181a851fbaa7b8716337e0b
Author: Taeung Song 
AuthorDate: Thu, 7 Sep 2017 12:18:45 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 12 Sep 2017 12:35:11 -0300

perf config: Check not only section->from_system_config but also item's

Currently section->from_system_config is being checked multiple times.
item->from_system_config should be checked instead, when iterating thru
the items in a section. Fix it.

Signed-off-by: Taeung Song 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1504754325-9724-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 3ddcc6e..a1d82e3 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -59,7 +59,7 @@ static int set_config(struct perf_config_set *set, const char 
*file_name,
fprintf(fp, "[%s]\n", section->name);
 
perf_config_items__for_each_entry(>items, item) {
-   if (!use_system_config && section->from_system_config)
+   if (!use_system_config && item->from_system_config)
continue;
if (item->value)
fprintf(fp, "\t%s = %s\n",


Re: [PATCH v5 3/3] perf config: Allow creating empty config set for config file autogeneration

2017-09-08 Thread Taeung Song

Thank you !! :)

  - Taeung

On 09/08/2017 11:36 PM, Arnaldo Carvalho de Melo wrote:

Em Thu, Sep 07, 2017 at 12:18:56PM +0900, Taeung Song escreveu:

When there isn't a config file (e.g. ~/.perfconfig)
or it has nothing, the config set wasn't created.
If the config set not exists, a config file can't be autogenerated.

So allow creating a empty config set in the above case,
then we can support the config file autogeneration.


Applied, and rephased a bit the cset log message.

- Arnaldo
  

Before:

   $ rm -f ~/.perfconfig
   $ perf config --user report.children=false

   $ cat ~/.perfconfig
   cat: /root/.perfconfig: No such file or directory

But I think it should work even if there isn't a config file.

After:

   $ rm -f ~/.perfconfig
   $ perf config --user report.children=false

   $ cat ~/.perfconfig
   # this file is auto-generated.
   [report]
   children = false

NOTE:
As a result, if perf_config_set__init() is failed,
it seems that the config set isn't freed. But it isn't a problem.
Because the config set  will be freed by perf_config_set__delete()
at the end of cmd_config().

Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
  tools/perf/util/config.c | 5 +
  1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index bc75596..d2b6983 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -700,10 +700,7 @@ struct perf_config_set *perf_config_set__new(void)
  
  	if (set) {

INIT_LIST_HEAD(>sections);
-   if (perf_config_set__init(set) < 0) {
-   perf_config_set__delete(set);
-   set = NULL;
-   }
+   perf_config_set__init(set);
}
  
  	return set;

--
2.7.4


Re: [PATCH v5 3/3] perf config: Allow creating empty config set for config file autogeneration

2017-09-08 Thread Taeung Song

Thank you !! :)

  - Taeung

On 09/08/2017 11:36 PM, Arnaldo Carvalho de Melo wrote:

Em Thu, Sep 07, 2017 at 12:18:56PM +0900, Taeung Song escreveu:

When there isn't a config file (e.g. ~/.perfconfig)
or it has nothing, the config set wasn't created.
If the config set not exists, a config file can't be autogenerated.

So allow creating a empty config set in the above case,
then we can support the config file autogeneration.


Applied, and rephased a bit the cset log message.

- Arnaldo
  

Before:

   $ rm -f ~/.perfconfig
   $ perf config --user report.children=false

   $ cat ~/.perfconfig
   cat: /root/.perfconfig: No such file or directory

But I think it should work even if there isn't a config file.

After:

   $ rm -f ~/.perfconfig
   $ perf config --user report.children=false

   $ cat ~/.perfconfig
   # this file is auto-generated.
   [report]
   children = false

NOTE:
As a result, if perf_config_set__init() is failed,
it seems that the config set isn't freed. But it isn't a problem.
Because the config set  will be freed by perf_config_set__delete()
at the end of cmd_config().

Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Taeung Song 
---
  tools/perf/util/config.c | 5 +
  1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index bc75596..d2b6983 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -700,10 +700,7 @@ struct perf_config_set *perf_config_set__new(void)
  
  	if (set) {

INIT_LIST_HEAD(>sections);
-   if (perf_config_set__init(set) < 0) {
-   perf_config_set__delete(set);
-   set = NULL;
-   }
+   perf_config_set__init(set);
}
  
  	return set;

--
2.7.4


[PATCH v5 3/3] perf config: Allow creating empty config set for config file autogeneration

2017-09-06 Thread Taeung Song
When there isn't a config file (e.g. ~/.perfconfig)
or it has nothing, the config set wasn't created.
If the config set not exists, a config file can't be autogenerated.

So allow creating a empty config set in the above case,
then we can support the config file autogeneration.

Before:

  $ rm -f ~/.perfconfig
  $ perf config --user report.children=false

  $ cat ~/.perfconfig
  cat: /root/.perfconfig: No such file or directory

But I think it should work even if there isn't a config file.

After:

  $ rm -f ~/.perfconfig
  $ perf config --user report.children=false

  $ cat ~/.perfconfig
  # this file is auto-generated.
  [report]
  children = false

NOTE:
As a result, if perf_config_set__init() is failed,
it seems that the config set isn't freed. But it isn't a problem.
Because the config set  will be freed by perf_config_set__delete()
at the end of cmd_config().

Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/util/config.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index bc75596..d2b6983 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -700,10 +700,7 @@ struct perf_config_set *perf_config_set__new(void)
 
if (set) {
INIT_LIST_HEAD(>sections);
-   if (perf_config_set__init(set) < 0) {
-   perf_config_set__delete(set);
-   set = NULL;
-   }
+   perf_config_set__init(set);
}
 
return set;
-- 
2.7.4



[PATCH v5 1/3] perf config: Check not only section->from_system_config but also item's

2017-09-06 Thread Taeung Song
Currently only section->from_system_config is being checked multiple times.
items->from_system_config should be also checked, so fix it.

Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/builtin-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 3ddcc6e..a1d82e3 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -59,7 +59,7 @@ static int set_config(struct perf_config_set *set, const char 
*file_name,
fprintf(fp, "[%s]\n", section->name);
 
perf_config_items__for_each_entry(>items, item) {
-   if (!use_system_config && section->from_system_config)
+   if (!use_system_config && item->from_system_config)
continue;
if (item->value)
fprintf(fp, "\t%s = %s\n",
-- 
2.7.4



[PATCH v5 3/3] perf config: Allow creating empty config set for config file autogeneration

2017-09-06 Thread Taeung Song
When there isn't a config file (e.g. ~/.perfconfig)
or it has nothing, the config set wasn't created.
If the config set not exists, a config file can't be autogenerated.

So allow creating a empty config set in the above case,
then we can support the config file autogeneration.

Before:

  $ rm -f ~/.perfconfig
  $ perf config --user report.children=false

  $ cat ~/.perfconfig
  cat: /root/.perfconfig: No such file or directory

But I think it should work even if there isn't a config file.

After:

  $ rm -f ~/.perfconfig
  $ perf config --user report.children=false

  $ cat ~/.perfconfig
  # this file is auto-generated.
  [report]
  children = false

NOTE:
As a result, if perf_config_set__init() is failed,
it seems that the config set isn't freed. But it isn't a problem.
Because the config set  will be freed by perf_config_set__delete()
at the end of cmd_config().

Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Taeung Song 
---
 tools/perf/util/config.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index bc75596..d2b6983 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -700,10 +700,7 @@ struct perf_config_set *perf_config_set__new(void)
 
if (set) {
INIT_LIST_HEAD(>sections);
-   if (perf_config_set__init(set) < 0) {
-   perf_config_set__delete(set);
-   set = NULL;
-   }
+   perf_config_set__init(set);
}
 
return set;
-- 
2.7.4



[PATCH v5 1/3] perf config: Check not only section->from_system_config but also item's

2017-09-06 Thread Taeung Song
Currently only section->from_system_config is being checked multiple times.
items->from_system_config should be also checked, so fix it.

Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 3ddcc6e..a1d82e3 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -59,7 +59,7 @@ static int set_config(struct perf_config_set *set, const char 
*file_name,
fprintf(fp, "[%s]\n", section->name);
 
perf_config_items__for_each_entry(>items, item) {
-   if (!use_system_config && section->from_system_config)
+   if (!use_system_config && item->from_system_config)
continue;
if (item->value)
fprintf(fp, "\t%s = %s\n",
-- 
2.7.4



[PATCH v5 0/3] perf config: Simple bugfixes & refactoring

2017-09-06 Thread Taeung Song
Hi all,

This is simple patchset for perf-config
to fix small bugs and refactor code.

I'd appreciate some feedback on this patchset.

The code is also available at 'config/refactoring-v5' branch on

  git://github.com/taeung/linux-perf.git


Thanks,
Taeung

v5:
- rebase on current acme/perf/core
- adjust commit log messages to be more proper

v4:
- rebase on current acme/perf/core
- simplify commit log messages
- remove needless two patches

v3:
- fix a bug of no checked 'ret' in the loop in cmd_config() (Arnaldo)
- modify commit log messages to be more clear (Aranaldo)
- return -1 if show_spec_config() cannot show the config
- initialize 'ret' with -1 instead of 0 for more compact code in cmd_config()
- Add a error message when perf_config_set__new() failed in cmd_config()

v2:
- there is no need to consider empty config file (Arnaldo)

Taeung Song (3):
  perf config: Check not only section->from_system_config but also
item's
  perf config: Once write a config file in the end, not a repeat
  perf config: Allow creating empty config set for config file
autogeneration

 tools/perf/builtin-config.c | 24 +---
 tools/perf/util/config.c|  5 +
 2 files changed, 18 insertions(+), 11 deletions(-)

-- 
2.7.4



[PATCH v5 2/3] perf config: Once write a config file in the end, not a repeat

2017-09-06 Thread Taeung Song
Currently set_config() can be repeatedly called for each
input config on the below case:

  $ perf config kmem.default=slab report.children=false ...

But it's a waste, so only once write a config file
gathering all given config key=value pairs

Cc: Jiri Olsa <jo...@kernel.org>
Cc: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/builtin-config.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index a1d82e3..b89417d 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -34,8 +34,7 @@ static struct option config_options[] = {
OPT_END()
 };
 
-static int set_config(struct perf_config_set *set, const char *file_name,
- const char *var, const char *value)
+static int set_config(struct perf_config_set *set, const char *file_name)
 {
struct perf_config_section *section = NULL;
struct perf_config_item *item = NULL;
@@ -49,7 +48,6 @@ static int set_config(struct perf_config_set *set, const char 
*file_name,
if (!fp)
return -1;
 
-   perf_config_set__collect(set, file_name, var, value);
fprintf(fp, "%s\n", first_line);
 
/* overwrite configvariables */
@@ -161,6 +159,7 @@ int cmd_config(int argc, const char **argv)
struct perf_config_set *set;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
const char *config_filename;
+   bool changed = false;
 
argc = parse_options(argc, argv, config_options, config_usage,
 PARSE_OPT_STOP_AT_NON_OPTION);
@@ -231,15 +230,26 @@ int cmd_config(int argc, const char **argv)
goto out_err;
}
} else {
-   if (set_config(set, config_filename, var, 
value) < 0) {
-   pr_err("Failed to set '%s=%s' on %s\n",
-  var, value, config_filename);
+   if (perf_config_set__collect(set, 
config_filename,
+var, value) < 0) {
+   pr_err("Failed to add '%s=%s'\n",
+  var, value);
free(arg);
goto out_err;
}
+   changed = true;
}
free(arg);
}
+
+   if (!changed)
+   break;
+
+   if (set_config(set, config_filename) < 0) {
+   pr_err("Failed to set the configs on %s\n",
+  config_filename);
+   goto out_err;
+   }
}
 
ret = 0;
-- 
2.7.4



[PATCH v5 2/3] perf config: Once write a config file in the end, not a repeat

2017-09-06 Thread Taeung Song
Currently set_config() can be repeatedly called for each
input config on the below case:

  $ perf config kmem.default=slab report.children=false ...

But it's a waste, so only once write a config file
gathering all given config key=value pairs

Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-config.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index a1d82e3..b89417d 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -34,8 +34,7 @@ static struct option config_options[] = {
OPT_END()
 };
 
-static int set_config(struct perf_config_set *set, const char *file_name,
- const char *var, const char *value)
+static int set_config(struct perf_config_set *set, const char *file_name)
 {
struct perf_config_section *section = NULL;
struct perf_config_item *item = NULL;
@@ -49,7 +48,6 @@ static int set_config(struct perf_config_set *set, const char 
*file_name,
if (!fp)
return -1;
 
-   perf_config_set__collect(set, file_name, var, value);
fprintf(fp, "%s\n", first_line);
 
/* overwrite configvariables */
@@ -161,6 +159,7 @@ int cmd_config(int argc, const char **argv)
struct perf_config_set *set;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
const char *config_filename;
+   bool changed = false;
 
argc = parse_options(argc, argv, config_options, config_usage,
 PARSE_OPT_STOP_AT_NON_OPTION);
@@ -231,15 +230,26 @@ int cmd_config(int argc, const char **argv)
goto out_err;
}
} else {
-   if (set_config(set, config_filename, var, 
value) < 0) {
-   pr_err("Failed to set '%s=%s' on %s\n",
-  var, value, config_filename);
+   if (perf_config_set__collect(set, 
config_filename,
+var, value) < 0) {
+   pr_err("Failed to add '%s=%s'\n",
+  var, value);
free(arg);
goto out_err;
}
+   changed = true;
}
free(arg);
}
+
+   if (!changed)
+   break;
+
+   if (set_config(set, config_filename) < 0) {
+   pr_err("Failed to set the configs on %s\n",
+  config_filename);
+   goto out_err;
+   }
}
 
ret = 0;
-- 
2.7.4



[PATCH v5 0/3] perf config: Simple bugfixes & refactoring

2017-09-06 Thread Taeung Song
Hi all,

This is simple patchset for perf-config
to fix small bugs and refactor code.

I'd appreciate some feedback on this patchset.

The code is also available at 'config/refactoring-v5' branch on

  git://github.com/taeung/linux-perf.git


Thanks,
Taeung

v5:
- rebase on current acme/perf/core
- adjust commit log messages to be more proper

v4:
- rebase on current acme/perf/core
- simplify commit log messages
- remove needless two patches

v3:
- fix a bug of no checked 'ret' in the loop in cmd_config() (Arnaldo)
- modify commit log messages to be more clear (Aranaldo)
- return -1 if show_spec_config() cannot show the config
- initialize 'ret' with -1 instead of 0 for more compact code in cmd_config()
- Add a error message when perf_config_set__new() failed in cmd_config()

v2:
- there is no need to consider empty config file (Arnaldo)

Taeung Song (3):
  perf config: Check not only section->from_system_config but also
item's
  perf config: Once write a config file in the end, not a repeat
  perf config: Allow creating empty config set for config file
autogeneration

 tools/perf/builtin-config.c | 24 +---
 tools/perf/util/config.c|  5 +
 2 files changed, 18 insertions(+), 11 deletions(-)

-- 
2.7.4



[tip:perf/core] perf annotate browser: Circulate percent, total-period and nr-samples view

2017-08-22 Thread tip-bot for Taeung Song
Commit-ID:  3a555c7799de69d73826eccc9a21948a5775d4d3
Gitweb: http://git.kernel.org/tip/3a555c7799de69d73826eccc9a21948a5775d4d3
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Fri, 18 Aug 2017 17:47:08 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Fri, 18 Aug 2017 11:23:20 -0300

perf annotate browser: Circulate percent, total-period and nr-samples view

Using the existing 't' hotkey, support the three views: percent, total
period and number of samples on the annotate TUI browser, circulating
them like below:

  Percent -> Total Period -> Nr Samples -> Percent ...

Committer notes:

Removed new 'e' hotkey, should be resubmitted as a separate patch, with
proper justification for its inclusion.

Suggested-by: Namhyung Kim <namhy...@kernel.org>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Milian Wolff <milian.wo...@kdab.com>
Link: 
http://lkml.kernel.org/r/1503046028-5691-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/ui/browsers/annotate.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index faca1b9..ba0aee5 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
-   "t Toggle total period view\n"
+   "t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
@@ -912,8 +912,13 @@ show_sup_ins:
}
continue;
case 't':
-   annotate_browser__opts.show_total_period =
- !annotate_browser__opts.show_total_period;
+   if (annotate_browser__opts.show_total_period) {
+   annotate_browser__opts.show_total_period = 
false;
+   annotate_browser__opts.show_nr_samples = true;
+   } else if (annotate_browser__opts.show_nr_samples)
+   annotate_browser__opts.show_nr_samples = false;
+   else
+   annotate_browser__opts.show_total_period = true;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:


[tip:perf/core] perf annotate browser: Circulate percent, total-period and nr-samples view

2017-08-22 Thread tip-bot for Taeung Song
Commit-ID:  3a555c7799de69d73826eccc9a21948a5775d4d3
Gitweb: http://git.kernel.org/tip/3a555c7799de69d73826eccc9a21948a5775d4d3
Author: Taeung Song 
AuthorDate: Fri, 18 Aug 2017 17:47:08 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 18 Aug 2017 11:23:20 -0300

perf annotate browser: Circulate percent, total-period and nr-samples view

Using the existing 't' hotkey, support the three views: percent, total
period and number of samples on the annotate TUI browser, circulating
them like below:

  Percent -> Total Period -> Nr Samples -> Percent ...

Committer notes:

Removed new 'e' hotkey, should be resubmitted as a separate patch, with
proper justification for its inclusion.

Suggested-by: Namhyung Kim 
Signed-off-by: Taeung Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Milian Wolff 
Link: 
http://lkml.kernel.org/r/1503046028-5691-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/annotate.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index faca1b9..ba0aee5 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
-   "t Toggle total period view\n"
+   "t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
@@ -912,8 +912,13 @@ show_sup_ins:
}
continue;
case 't':
-   annotate_browser__opts.show_total_period =
- !annotate_browser__opts.show_total_period;
+   if (annotate_browser__opts.show_total_period) {
+   annotate_browser__opts.show_total_period = 
false;
+   annotate_browser__opts.show_nr_samples = true;
+   } else if (annotate_browser__opts.show_nr_samples)
+   annotate_browser__opts.show_nr_samples = false;
+   else
+   annotate_browser__opts.show_total_period = true;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:


[tip:perf/core] perf annotate stdio: Support --show-nr-samples option

2017-08-22 Thread tip-bot for Taeung Song
Commit-ID:  1ac39372e06f5009982aaaf890fc5bbd044bb047
Gitweb: http://git.kernel.org/tip/1ac39372e06f5009982aaaf890fc5bbd044bb047
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Fri, 18 Aug 2017 17:46:48 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Fri, 18 Aug 2017 10:31:53 -0300

perf annotate stdio: Support --show-nr-samples option

Add --show-nr-samples option to "perf annotate" so that it matches "perf
report".

Committer note:

Note that it can't be used together with --show-total-period, which
seems like a silly limitation, that can be lifted at some point.

Made it bail out if not on --stdio.

Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Link: 
http://lkml.kernel.org/r/1503046008-5511-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Documentation/perf-annotate.txt |  4 
 tools/perf/builtin-annotate.c  | 16 ++--
 tools/perf/util/annotate.c |  6 +-
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index a89273d..2a5975c 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -43,6 +43,10 @@ OPTIONS
 --quiet::
Do not show any message.  (Suppress -v)
 
+-n::
+--show-nr-samples::
+   Show the number of samples for each symbol
+
 -D::
 --dump-raw-trace::
 Dump raw trace in ASCII.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..89fc038 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
struct perf_data_file file = {
.mode  = PERF_DATA_MODE_READ,
};
-   const struct option options[] = {
+   struct option options[] = {
OPT_STRING('i', "input", _name, "file",
"input file name"),
OPT_STRING('d', "dsos", _conf.dso_list_str, "dso[,dso...]",
@@ -445,13 +445,20 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",
 stdio__config_color, "always"),
OPT_END()
};
-   int ret = hists__init();
+   int ret;
+
+   set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
+   set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
+
 
+   ret = hists__init();
if (ret < 0)
return ret;
 
@@ -467,6 +474,11 @@ int cmd_annotate(int argc, const char **argv)
annotate.sym_hist_filter = argv[0];
}
 
+   if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
+   pr_err("--show-nr-samples is only available in --stdio mode at 
this time\n");
+   return ret;
+   }
+
if (quiet)
perf_quiet_option();
 
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
 
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s 
for %s (%" PRIu64 " samples)\n",
- 

[tip:perf/core] perf annotate: Document --show-total-period option

2017-08-22 Thread tip-bot for Taeung Song
Commit-ID:  01c85629f5e99958606da816f1df058c0722a570
Gitweb: http://git.kernel.org/tip/01c85629f5e99958606da816f1df058c0722a570
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Fri, 18 Aug 2017 17:46:53 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Fri, 18 Aug 2017 10:34:08 -0300

perf annotate: Document --show-total-period option

When the --show-total-period option was introduced we forgot to add an
entry in the man page, fix it.

Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Martin Liška <mli...@suse.cz>
Fixes: 0c4a5bcea460 ("perf annotate: Display total number of samples with 
--show-total-period")
Link: 
http://lkml.kernel.org/r/1503046013--1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Documentation/perf-annotate.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index 2a5975c..c635eab 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -92,6 +92,8 @@ OPTIONS
 --asm-raw::
Show raw instruction encoding of assembly instructions.
 
+--show-total-period:: Show a column with the sum of periods.
+
 --source::
Interleave source code with assembly code. Enabled by default,
disable with --no-source.


[tip:perf/core] perf annotate stdio: Support --show-nr-samples option

2017-08-22 Thread tip-bot for Taeung Song
Commit-ID:  1ac39372e06f5009982aaaf890fc5bbd044bb047
Gitweb: http://git.kernel.org/tip/1ac39372e06f5009982aaaf890fc5bbd044bb047
Author: Taeung Song 
AuthorDate: Fri, 18 Aug 2017 17:46:48 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 18 Aug 2017 10:31:53 -0300

perf annotate stdio: Support --show-nr-samples option

Add --show-nr-samples option to "perf annotate" so that it matches "perf
report".

Committer note:

Note that it can't be used together with --show-total-period, which
seems like a silly limitation, that can be lifted at some point.

Made it bail out if not on --stdio.

Signed-off-by: Taeung Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1503046008-5511-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-annotate.txt |  4 
 tools/perf/builtin-annotate.c  | 16 ++--
 tools/perf/util/annotate.c |  6 +-
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index a89273d..2a5975c 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -43,6 +43,10 @@ OPTIONS
 --quiet::
Do not show any message.  (Suppress -v)
 
+-n::
+--show-nr-samples::
+   Show the number of samples for each symbol
+
 -D::
 --dump-raw-trace::
 Dump raw trace in ASCII.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..89fc038 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
struct perf_data_file file = {
.mode  = PERF_DATA_MODE_READ,
};
-   const struct option options[] = {
+   struct option options[] = {
OPT_STRING('i', "input", _name, "file",
"input file name"),
OPT_STRING('d', "dsos", _conf.dso_list_str, "dso[,dso...]",
@@ -445,13 +445,20 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",
 stdio__config_color, "always"),
OPT_END()
};
-   int ret = hists__init();
+   int ret;
+
+   set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
+   set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
+
 
+   ret = hists__init();
if (ret < 0)
return ret;
 
@@ -467,6 +474,11 @@ int cmd_annotate(int argc, const char **argv)
annotate.sym_hist_filter = argv[0];
}
 
+   if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
+   pr_err("--show-nr-samples is only available in --stdio mode at 
this time\n");
+   return ret;
+   }
+
if (quiet)
perf_quiet_option();
 
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
 
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s 
for %s (%" PRIu64 " samples)\n",
- width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
 
printf("%-*.*s\n",


[tip:perf/core] perf annotate: Document --show-total-period option

2017-08-22 Thread tip-bot for Taeung Song
Commit-ID:  01c85629f5e99958606da816f1df058c0722a570
Gitweb: http://git.kernel.org/tip/01c85629f5e99958606da816f1df058c0722a570
Author: Taeung Song 
AuthorDate: Fri, 18 Aug 2017 17:46:53 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 18 Aug 2017 10:34:08 -0300

perf annotate: Document --show-total-period option

When the --show-total-period option was introduced we forgot to add an
entry in the man page, fix it.

Signed-off-by: Taeung Song 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Martin Liška 
Fixes: 0c4a5bcea460 ("perf annotate: Display total number of samples with 
--show-total-period")
Link: 
http://lkml.kernel.org/r/1503046013--1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-annotate.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index 2a5975c..c635eab 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -92,6 +92,8 @@ OPTIONS
 --asm-raw::
Show raw instruction encoding of assembly instructions.
 
+--show-total-period:: Show a column with the sum of periods.
+
 --source::
Interleave source code with assembly code. Enabled by default,
disable with --no-source.


[tip:perf/core] perf annotate browser: Support --show-nr-samples option

2017-08-22 Thread tip-bot for Taeung Song
Commit-ID:  9cef4b0b5b7f64016f043609313aaa821d682d2e
Gitweb: http://git.kernel.org/tip/9cef4b0b5b7f64016f043609313aaa821d682d2e
Author: Taeung Song <treeze.tae...@gmail.com>
AuthorDate: Fri, 18 Aug 2017 17:47:03 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Fri, 18 Aug 2017 11:15:09 -0300

perf annotate browser: Support --show-nr-samples option

Support the --show-nr-samples in the TUI browser.

Committer notes:

Lift the restriction about --tui but leave it for --gtk:

  $ export LD_LIBRARY_PATH=~/lib64
  $ perf annotate --gtk --show-nr-samples --show-nr-samples is not available in 
--gtk mode at this time
  $

Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Link: 
http://lkml.kernel.org/r/1503046023-5646-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/builtin-annotate.c |  4 ++--
 tools/perf/ui/browsers/annotate.c | 14 +++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 89fc038..c383731 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -474,8 +474,8 @@ int cmd_annotate(int argc, const char **argv)
annotate.sym_hist_filter = argv[0];
}
 
-   if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
-   pr_err("--show-nr-samples is only available in --stdio mode at 
this time\n");
+   if (symbol_conf.show_nr_samples && annotate.use_gtk) {
+   pr_err("--show-nr-samples is not available in --gtk mode at 
this time\n");
return ret;
}
 
diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..faca1b9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 jump_arrows,
 show_linenr,
 show_nr_jumps,
+show_nr_samples,
 show_total_period;
 } annotate_browser__opts = {
.use_offset = true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
+   } else if (annotate_browser__opts.show_nr_samples) {
+   ui_browser__printf(browser, "%6" PRIu64 " ",
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
-  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+  
annotate_browser__opts.show_total_period ? "Period" :
+  
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
@@ -931,9 +936,11 @@ out:
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   /* Set default value for show_total_period.  */
+   /* Set default value for show_total_period and show_nr_samples  */
annotate_browser__opts.show_total_period =
- symbol_conf.show_total_period;
+   symbol_conf.show_total_period;
+   annotate_browser__opts.show_nr_samples =
+   symbol_conf.show_nr_samples;
 
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
+   ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
 };


[tip:perf/core] perf annotate browser: Support --show-nr-samples option

2017-08-22 Thread tip-bot for Taeung Song
Commit-ID:  9cef4b0b5b7f64016f043609313aaa821d682d2e
Gitweb: http://git.kernel.org/tip/9cef4b0b5b7f64016f043609313aaa821d682d2e
Author: Taeung Song 
AuthorDate: Fri, 18 Aug 2017 17:47:03 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 18 Aug 2017 11:15:09 -0300

perf annotate browser: Support --show-nr-samples option

Support the --show-nr-samples in the TUI browser.

Committer notes:

Lift the restriction about --tui but leave it for --gtk:

  $ export LD_LIBRARY_PATH=~/lib64
  $ perf annotate --gtk --show-nr-samples --show-nr-samples is not available in 
--gtk mode at this time
  $

Signed-off-by: Taeung Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1503046023-5646-1-git-send-email-treeze.tae...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-annotate.c |  4 ++--
 tools/perf/ui/browsers/annotate.c | 14 +++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 89fc038..c383731 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -474,8 +474,8 @@ int cmd_annotate(int argc, const char **argv)
annotate.sym_hist_filter = argv[0];
}
 
-   if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
-   pr_err("--show-nr-samples is only available in --stdio mode at 
this time\n");
+   if (symbol_conf.show_nr_samples && annotate.use_gtk) {
+   pr_err("--show-nr-samples is not available in --gtk mode at 
this time\n");
return ret;
}
 
diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..faca1b9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 jump_arrows,
 show_linenr,
 show_nr_jumps,
+show_nr_samples,
 show_total_period;
 } annotate_browser__opts = {
.use_offset = true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
+   } else if (annotate_browser__opts.show_nr_samples) {
+   ui_browser__printf(browser, "%6" PRIu64 " ",
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
-  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+  
annotate_browser__opts.show_total_period ? "Period" :
+  
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
@@ -931,9 +936,11 @@ out:
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   /* Set default value for show_total_period.  */
+   /* Set default value for show_total_period and show_nr_samples  */
annotate_browser__opts.show_total_period =
- symbol_conf.show_total_period;
+   symbol_conf.show_total_period;
+   annotate_browser__opts.show_nr_samples =
+   symbol_conf.show_nr_samples;
 
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
+   ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
 };


Re: [PATCH v3 5/5] perf annotate browser: Circulate percent, total period and samples view

2017-08-20 Thread Taeung Song



On 08/18/2017 11:23 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Aug 18, 2017 at 05:47:08PM +0900, Taeung Song escreveu:

With a existing 't' hotkey, support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

   Percent -> Period -> Samples -> Percent ...

Suggested-by: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---


Ok, here I removed this part, that is not documented in the patch nor in
the 'h' help screen, if you think it should be considered, please
resubmit it with a proper explanation:


I'm really sorry. The case 'e' code is a residue..
I missed removing the code.
Thank you for indicating my mistakes.

Do I resend this patchkit based on your changes ?
Or, will you modify it by yourself ?

Thanks,
Taeung



diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index e82e6c5df83b..ba0aee576a2b 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -921,12 +921,6 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
annotate_browser__opts.show_total_period = true;
annotate_browser__update_addr_width(browser);
continue;
-   case 'e':
-   annotate_browser__opts.show_total_period = false;
-   annotate_browser__opts.show_nr_samples =
-   !annotate_browser__opts.show_nr_samples;
-   annotate_browser__update_addr_width(browser);
-   continue;
case K_LEFT:
case K_ESC:
case 'q':



Re: [PATCH v3 5/5] perf annotate browser: Circulate percent, total period and samples view

2017-08-20 Thread Taeung Song



On 08/18/2017 11:23 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Aug 18, 2017 at 05:47:08PM +0900, Taeung Song escreveu:

With a existing 't' hotkey, support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

   Percent -> Period -> Samples -> Percent ...

Suggested-by: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---


Ok, here I removed this part, that is not documented in the patch nor in
the 'h' help screen, if you think it should be considered, please
resubmit it with a proper explanation:


I'm really sorry. The case 'e' code is a residue..
I missed removing the code.
Thank you for indicating my mistakes.

Do I resend this patchkit based on your changes ?
Or, will you modify it by yourself ?

Thanks,
Taeung



diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index e82e6c5df83b..ba0aee576a2b 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -921,12 +921,6 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
annotate_browser__opts.show_total_period = true;
annotate_browser__update_addr_width(browser);
continue;
-   case 'e':
-   annotate_browser__opts.show_total_period = false;
-   annotate_browser__opts.show_nr_samples =
-   !annotate_browser__opts.show_nr_samples;
-   annotate_browser__update_addr_width(browser);
-   continue;
case K_LEFT:
case K_ESC:
case 'q':



Re: [PATCH v3 4/5] perf annotate browser: Support --show-nr-samples option

2017-08-20 Thread Taeung Song



On 08/18/2017 11:17 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Aug 18, 2017 at 05:47:03PM +0900, Taeung Song escreveu:

Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>


Ok, now that check for !--stdio is lifted and replaced with:

-   if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
-   pr_err("--show-nr-samples is only available in --stdio mode at this 
time\n");
+   if (symbol_conf.show_nr_samples && annotate.use_gtk) {
+   pr_err("--show-nr-samples is not available in --gtk mode at this 
time\n");
 return ret;
 }

- Arnaldo



I got it :)

Thanks,
Taeung


Re: [PATCH v3 4/5] perf annotate browser: Support --show-nr-samples option

2017-08-20 Thread Taeung Song



On 08/18/2017 11:17 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Aug 18, 2017 at 05:47:03PM +0900, Taeung Song escreveu:

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 


Ok, now that check for !--stdio is lifted and replaced with:

-   if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
-   pr_err("--show-nr-samples is only available in --stdio mode at this 
time\n");
+   if (symbol_conf.show_nr_samples && annotate.use_gtk) {
+   pr_err("--show-nr-samples is not available in --gtk mode at this 
time\n");
 return ret;
 }

- Arnaldo



I got it :)

Thanks,
Taeung


Re: [PATCH v3 1/5] perf annotate stdio: Support --show-nr-samples option

2017-08-20 Thread Taeung Song



On 08/18/2017 10:33 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Aug 18, 2017 at 05:46:48PM +0900, Taeung Song escreveu:

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.


So, at this point I tried to test it and forgot this was just about
--stdio, which confused me, so I added the following patch, that I'll
lift when adding the browser support, which may not happen at this time
if there are problems there.

@@ -473,6 +474,11 @@ int cmd_annotate(int argc, const char **argv)
 annotate.sym_hist_filter = argv[0];
 }
  
+   if (symbol_conf.show_nr_samples && !annotate.use_stdio) {

+   pr_err("--show-nr-samples is only available in --stdio mode at this 
time\n");
+   return ret;
+   }
+

- Arnaldo



Ok, got it.

Thanks,
Taeung


Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
  tools/perf/Documentation/perf-annotate.txt | 4 
  tools/perf/builtin-annotate.c  | 2 ++
  tools/perf/util/annotate.c | 6 +-
  3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index a89273d..2a5975c 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -43,6 +43,10 @@ OPTIONS
  --quiet::
Do not show any message.  (Suppress -v)
  
+-n::

+--show-nr-samples::
+   Show the number of samples for each symbol
+
  -D::
  --dump-raw-trace::
  Dump raw trace in ASCII.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only applicable 
to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
  
  	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",

- width, width, symbol_conf.show_total_period ? "Event 
count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
  
  	printf("%-*.*s\n",

--
2.7.4


Re: [PATCH v3 1/5] perf annotate stdio: Support --show-nr-samples option

2017-08-20 Thread Taeung Song



On 08/18/2017 10:33 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Aug 18, 2017 at 05:46:48PM +0900, Taeung Song escreveu:

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.


So, at this point I tried to test it and forgot this was just about
--stdio, which confused me, so I added the following patch, that I'll
lift when adding the browser support, which may not happen at this time
if there are problems there.

@@ -473,6 +474,11 @@ int cmd_annotate(int argc, const char **argv)
 annotate.sym_hist_filter = argv[0];
 }
  
+   if (symbol_conf.show_nr_samples && !annotate.use_stdio) {

+   pr_err("--show-nr-samples is only available in --stdio mode at this 
time\n");
+   return ret;
+   }
+

- Arnaldo



Ok, got it.

Thanks,
Taeung


Cc: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
  tools/perf/Documentation/perf-annotate.txt | 4 
  tools/perf/builtin-annotate.c  | 2 ++
  tools/perf/util/annotate.c | 6 +-
  3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index a89273d..2a5975c 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -43,6 +43,10 @@ OPTIONS
  --quiet::
Do not show any message.  (Suppress -v)
  
+-n::

+--show-nr-samples::
+   Show the number of samples for each symbol
+
  -D::
  --dump-raw-trace::
  Dump raw trace in ASCII.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only applicable 
to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
  
  	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",

- width, width, symbol_conf.show_total_period ? "Event 
count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
  
  	printf("%-*.*s\n",

--
2.7.4


[PATCH v3 2/5] perf annotate: Add a missing period option in documentation

2017-08-18 Thread Taeung Song
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/Documentation/perf-annotate.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index 2a5975c..c635eab 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -92,6 +92,8 @@ OPTIONS
 --asm-raw::
Show raw instruction encoding of assembly instructions.
 
+--show-total-period:: Show a column with the sum of periods.
+
 --source::
Interleave source code with assembly code. Enabled by default,
disable with --no-source.
-- 
2.7.4



[PATCH v3 2/5] perf annotate: Add a missing period option in documentation

2017-08-18 Thread Taeung Song
Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-annotate.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index 2a5975c..c635eab 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -92,6 +92,8 @@ OPTIONS
 --asm-raw::
Show raw instruction encoding of assembly instructions.
 
+--show-total-period:: Show a column with the sum of periods.
+
 --source::
Interleave source code with assembly code. Enabled by default,
disable with --no-source.
-- 
2.7.4



[PATCH v3 4/5] perf annotate browser: Support --show-nr-samples option

2017-08-18 Thread Taeung Song
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/ui/browsers/annotate.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..faca1b9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 jump_arrows,
 show_linenr,
 show_nr_jumps,
+show_nr_samples,
 show_total_period;
 } annotate_browser__opts = {
.use_offset = true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
+   } else if (annotate_browser__opts.show_nr_samples) {
+   ui_browser__printf(browser, "%6" PRIu64 " ",
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
-  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+  
annotate_browser__opts.show_total_period ? "Period" :
+  
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
@@ -931,9 +936,11 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   /* Set default value for show_total_period.  */
+   /* Set default value for show_total_period and show_nr_samples  */
annotate_browser__opts.show_total_period =
- symbol_conf.show_total_period;
+   symbol_conf.show_total_period;
+   annotate_browser__opts.show_nr_samples =
+   symbol_conf.show_nr_samples;
 
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
+   ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
 };
-- 
2.7.4



[PATCH v3 4/5] perf annotate browser: Support --show-nr-samples option

2017-08-18 Thread Taeung Song
Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/ui/browsers/annotate.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..faca1b9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 jump_arrows,
 show_linenr,
 show_nr_jumps,
+show_nr_samples,
 show_total_period;
 } annotate_browser__opts = {
.use_offset = true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
+   } else if (annotate_browser__opts.show_nr_samples) {
+   ui_browser__printf(browser, "%6" PRIu64 " ",
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
-  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+  
annotate_browser__opts.show_total_period ? "Period" :
+  
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
@@ -931,9 +936,11 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   /* Set default value for show_total_period.  */
+   /* Set default value for show_total_period and show_nr_samples  */
annotate_browser__opts.show_total_period =
- symbol_conf.show_total_period;
+   symbol_conf.show_total_period;
+   annotate_browser__opts.show_nr_samples =
+   symbol_conf.show_nr_samples;
 
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
+   ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
 };
-- 
2.7.4



[PATCH v3 1/5] perf annotate stdio: Support --show-nr-samples option

2017-08-18 Thread Taeung Song
Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/Documentation/perf-annotate.txt | 4 
 tools/perf/builtin-annotate.c  | 2 ++
 tools/perf/util/annotate.c | 6 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index a89273d..2a5975c 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -43,6 +43,10 @@ OPTIONS
 --quiet::
Do not show any message.  (Suppress -v)
 
+-n::
+--show-nr-samples::
+   Show the number of samples for each symbol
+
 -D::
 --dump-raw-trace::
 Dump raw trace in ASCII.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
 
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s 
for %s (%" PRIu64 " samples)\n",
- width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
 
printf("%-*.*s\n",
-- 
2.7.4



[PATCH v3 3/5] perf annotate: Period and samples view can't be used at the same time

2017-08-18 Thread Taeung Song
If users give two options --show-total-period
and --show-nr-samples, show their proper usage because
the two options can not be used at the same time.

Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/builtin-annotate.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index acde4cc..9d25c27 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
struct perf_data_file file = {
.mode  = PERF_DATA_MODE_READ,
};
-   const struct option options[] = {
+   struct option options[] = {
OPT_STRING('i', "input", _name, "file",
"input file name"),
OPT_STRING('d', "dsos", _conf.dso_list_str, "dso[,dso...]",
@@ -452,8 +452,12 @@ int cmd_annotate(int argc, const char **argv)
 stdio__config_color, "always"),
OPT_END()
};
-   int ret = hists__init();
+   int ret;
+
+   set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
+   set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
 
+   ret = hists__init();
if (ret < 0)
return ret;
 
-- 
2.7.4



[PATCH v3 5/5] perf annotate browser: Circulate percent, total period and samples view

2017-08-18 Thread Taeung Song
With a existing 't' hotkey, support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

Suggested-by: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/ui/browsers/annotate.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index faca1b9..e82e6c5 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
-   "t Toggle total period view\n"
+   "t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
@@ -912,8 +912,19 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
}
continue;
case 't':
-   annotate_browser__opts.show_total_period =
- !annotate_browser__opts.show_total_period;
+   if (annotate_browser__opts.show_total_period) {
+   annotate_browser__opts.show_total_period = 
false;
+   annotate_browser__opts.show_nr_samples = true;
+   } else if (annotate_browser__opts.show_nr_samples)
+   annotate_browser__opts.show_nr_samples = false;
+   else
+   annotate_browser__opts.show_total_period = true;
+   annotate_browser__update_addr_width(browser);
+   continue;
+   case 'e':
+   annotate_browser__opts.show_total_period = false;
+   annotate_browser__opts.show_nr_samples =
+   !annotate_browser__opts.show_nr_samples;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:
-- 
2.7.4



[PATCH v3 1/5] perf annotate stdio: Support --show-nr-samples option

2017-08-18 Thread Taeung Song
Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

Cc: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-annotate.txt | 4 
 tools/perf/builtin-annotate.c  | 2 ++
 tools/perf/util/annotate.c | 6 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt 
b/tools/perf/Documentation/perf-annotate.txt
index a89273d..2a5975c 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -43,6 +43,10 @@ OPTIONS
 --quiet::
Do not show any message.  (Suppress -v)
 
+-n::
+--show-nr-samples::
+   Show the number of samples for each symbol
+
 -D::
 --dump-raw-trace::
 Dump raw trace in ASCII.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
 
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s 
for %s (%" PRIu64 " samples)\n",
- width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
 
printf("%-*.*s\n",
-- 
2.7.4



[PATCH v3 3/5] perf annotate: Period and samples view can't be used at the same time

2017-08-18 Thread Taeung Song
If users give two options --show-total-period
and --show-nr-samples, show their proper usage because
the two options can not be used at the same time.

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-annotate.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index acde4cc..9d25c27 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
struct perf_data_file file = {
.mode  = PERF_DATA_MODE_READ,
};
-   const struct option options[] = {
+   struct option options[] = {
OPT_STRING('i', "input", _name, "file",
"input file name"),
OPT_STRING('d', "dsos", _conf.dso_list_str, "dso[,dso...]",
@@ -452,8 +452,12 @@ int cmd_annotate(int argc, const char **argv)
 stdio__config_color, "always"),
OPT_END()
};
-   int ret = hists__init();
+   int ret;
+
+   set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
+   set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
 
+   ret = hists__init();
if (ret < 0)
return ret;
 
-- 
2.7.4



[PATCH v3 5/5] perf annotate browser: Circulate percent, total period and samples view

2017-08-18 Thread Taeung Song
With a existing 't' hotkey, support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

Suggested-by: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/ui/browsers/annotate.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index faca1b9..e82e6c5 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
-   "t Toggle total period view\n"
+   "t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
@@ -912,8 +912,19 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
}
continue;
case 't':
-   annotate_browser__opts.show_total_period =
- !annotate_browser__opts.show_total_period;
+   if (annotate_browser__opts.show_total_period) {
+   annotate_browser__opts.show_total_period = 
false;
+   annotate_browser__opts.show_nr_samples = true;
+   } else if (annotate_browser__opts.show_nr_samples)
+   annotate_browser__opts.show_nr_samples = false;
+   else
+   annotate_browser__opts.show_total_period = true;
+   annotate_browser__update_addr_width(browser);
+   continue;
+   case 'e':
+   annotate_browser__opts.show_total_period = false;
+   annotate_browser__opts.show_nr_samples =
+   !annotate_browser__opts.show_nr_samples;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:
-- 
2.7.4



[PATCH v3 0/5] perf annotate: Support --show-nr-samples and circulating view

2017-08-18 Thread Taeung Song
Hello,

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

And support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

I'd appreciate some feedback on my patchkit. :)
The code is available on 'perf/ann-nr-samples-v3' branch at

  git://github.com/taeung/linux-perf.git

Thanks,
Taeung

v3:
- Add --show-nr-samples option in documentation (Arnaldo)
- Add a missing --show-total-period in documentation

v2:
- period and nr-samples view can't be used at the same time (Arnaldo)

Taeung Song (5):
  perf annotate stdio: Support --show-nr-samples option
  perf annotate: Add a missing period option in documentation
  perf annotate: Period and samples view can't be used at the same time
  perf annotate browser: Support --show-nr-samples option
  perf annotate browser: Circulate percent, total period and samples
view

 tools/perf/Documentation/perf-annotate.txt |  6 ++
 tools/perf/builtin-annotate.c  | 10 --
 tools/perf/ui/browsers/annotate.c  | 31 --
 tools/perf/util/annotate.c |  6 +-
 4 files changed, 44 insertions(+), 9 deletions(-)

-- 
2.7.4



[PATCH v3 0/5] perf annotate: Support --show-nr-samples and circulating view

2017-08-18 Thread Taeung Song
Hello,

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

And support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

I'd appreciate some feedback on my patchkit. :)
The code is available on 'perf/ann-nr-samples-v3' branch at

  git://github.com/taeung/linux-perf.git

Thanks,
Taeung

v3:
- Add --show-nr-samples option in documentation (Arnaldo)
- Add a missing --show-total-period in documentation

v2:
- period and nr-samples view can't be used at the same time (Arnaldo)

Taeung Song (5):
  perf annotate stdio: Support --show-nr-samples option
  perf annotate: Add a missing period option in documentation
  perf annotate: Period and samples view can't be used at the same time
  perf annotate browser: Support --show-nr-samples option
  perf annotate browser: Circulate percent, total period and samples
view

 tools/perf/Documentation/perf-annotate.txt |  6 ++
 tools/perf/builtin-annotate.c  | 10 --
 tools/perf/ui/browsers/annotate.c  | 31 --
 tools/perf/util/annotate.c |  6 +-
 4 files changed, 44 insertions(+), 9 deletions(-)

-- 
2.7.4



Re: [PATCH v2 1/4] perf annotate stdio: Support --show-nr-samples option

2017-08-18 Thread Taeung Song

Hi Arnaldo,

On 08/18/2017 12:16 AM, Arnaldo Carvalho de Melo wrote:

Em Tue, Aug 15, 2017 at 05:06:31PM -0300, Arnaldo Carvalho de Melo escreveu:

Em Wed, Aug 16, 2017 at 12:13:09AM +0900, Taeung Song escreveu:

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.


I'll fold the second patch (2/4) with this one, thanks.


So, I was going to do that, please do it since there is another thing
missing here, document the new option in
tools/perf/Documentation/perf-annotate.txt.

- Arnaldo
  


Yep, got it, will add the new option --show-nr-samples
into Documentation/perf-annotate.txt

Thanks,
Taeung


- Arnaldo
  

Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
  tools/perf/builtin-annotate.c | 2 ++
  tools/perf/util/annotate.c| 6 +-
  2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only applicable 
to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
  
  	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",

- width, width, symbol_conf.show_total_period ? "Event 
count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
  
  	printf("%-*.*s\n",

--
2.7.4


Re: [PATCH v2 1/4] perf annotate stdio: Support --show-nr-samples option

2017-08-18 Thread Taeung Song

Hi Arnaldo,

On 08/18/2017 12:16 AM, Arnaldo Carvalho de Melo wrote:

Em Tue, Aug 15, 2017 at 05:06:31PM -0300, Arnaldo Carvalho de Melo escreveu:

Em Wed, Aug 16, 2017 at 12:13:09AM +0900, Taeung Song escreveu:

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.


I'll fold the second patch (2/4) with this one, thanks.


So, I was going to do that, please do it since there is another thing
missing here, document the new option in
tools/perf/Documentation/perf-annotate.txt.

- Arnaldo
  


Yep, got it, will add the new option --show-nr-samples
into Documentation/perf-annotate.txt

Thanks,
Taeung


- Arnaldo
  

Cc: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
  tools/perf/builtin-annotate.c | 2 ++
  tools/perf/util/annotate.c| 6 +-
  2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only applicable 
to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
  
  	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",

- width, width, symbol_conf.show_total_period ? "Event 
count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
  
  	printf("%-*.*s\n",

--
2.7.4


[PATCH v2 4/4] perf annotate browser: Circulate percent, total period and samples view

2017-08-15 Thread Taeung Song
With a existing 't' hotkey, support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

Suggested-by: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/ui/browsers/annotate.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index faca1b9..e82e6c5 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
-   "t Toggle total period view\n"
+   "t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
@@ -912,8 +912,19 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
}
continue;
case 't':
-   annotate_browser__opts.show_total_period =
- !annotate_browser__opts.show_total_period;
+   if (annotate_browser__opts.show_total_period) {
+   annotate_browser__opts.show_total_period = 
false;
+   annotate_browser__opts.show_nr_samples = true;
+   } else if (annotate_browser__opts.show_nr_samples)
+   annotate_browser__opts.show_nr_samples = false;
+   else
+   annotate_browser__opts.show_total_period = true;
+   annotate_browser__update_addr_width(browser);
+   continue;
+   case 'e':
+   annotate_browser__opts.show_total_period = false;
+   annotate_browser__opts.show_nr_samples =
+   !annotate_browser__opts.show_nr_samples;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:
-- 
2.7.4



[PATCH v2 4/4] perf annotate browser: Circulate percent, total period and samples view

2017-08-15 Thread Taeung Song
With a existing 't' hotkey, support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

Suggested-by: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/ui/browsers/annotate.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index faca1b9..e82e6c5 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
-   "t Toggle total period view\n"
+   "t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
@@ -912,8 +912,19 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
}
continue;
case 't':
-   annotate_browser__opts.show_total_period =
- !annotate_browser__opts.show_total_period;
+   if (annotate_browser__opts.show_total_period) {
+   annotate_browser__opts.show_total_period = 
false;
+   annotate_browser__opts.show_nr_samples = true;
+   } else if (annotate_browser__opts.show_nr_samples)
+   annotate_browser__opts.show_nr_samples = false;
+   else
+   annotate_browser__opts.show_total_period = true;
+   annotate_browser__update_addr_width(browser);
+   continue;
+   case 'e':
+   annotate_browser__opts.show_total_period = false;
+   annotate_browser__opts.show_nr_samples =
+   !annotate_browser__opts.show_nr_samples;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:
-- 
2.7.4



[PATCH v2 2/4] perf annotate: Period and samples view can't be used at the same time

2017-08-15 Thread Taeung Song
If users give two options --show-total-period
and --show-nr-samples, show their proper usage because
the two options can not be used at the same time.

Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/builtin-annotate.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index acde4cc..9d25c27 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
struct perf_data_file file = {
.mode  = PERF_DATA_MODE_READ,
};
-   const struct option options[] = {
+   struct option options[] = {
OPT_STRING('i', "input", _name, "file",
"input file name"),
OPT_STRING('d', "dsos", _conf.dso_list_str, "dso[,dso...]",
@@ -452,8 +452,12 @@ int cmd_annotate(int argc, const char **argv)
 stdio__config_color, "always"),
OPT_END()
};
-   int ret = hists__init();
+   int ret;
+
+   set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
+   set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
 
+   ret = hists__init();
if (ret < 0)
return ret;
 
-- 
2.7.4



[PATCH v2 3/4] perf annotate browser: Support --show-nr-samples option

2017-08-15 Thread Taeung Song
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/ui/browsers/annotate.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..faca1b9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 jump_arrows,
 show_linenr,
 show_nr_jumps,
+show_nr_samples,
 show_total_period;
 } annotate_browser__opts = {
.use_offset = true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
+   } else if (annotate_browser__opts.show_nr_samples) {
+   ui_browser__printf(browser, "%6" PRIu64 " ",
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
-  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+  
annotate_browser__opts.show_total_period ? "Period" :
+  
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
@@ -931,9 +936,11 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   /* Set default value for show_total_period.  */
+   /* Set default value for show_total_period and show_nr_samples  */
annotate_browser__opts.show_total_period =
- symbol_conf.show_total_period;
+   symbol_conf.show_total_period;
+   annotate_browser__opts.show_nr_samples =
+   symbol_conf.show_nr_samples;
 
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
+   ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
 };
-- 
2.7.4



[PATCH v2 0/4] perf annotate: Support --show-nr-samples and circulating view

2017-08-15 Thread Taeung Song
Hello,

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

And support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

I'd appreciate some feedback on my patchkit. :)
The code is available on 'perf/ann-nr-samples' branch at

  git://github.com/taeung/linux-perf.git

Thanks,
Taeung

v2:
- period and nr-samples view can't be used at the same time (Arnaldo)

Taeung Song (4):
  perf annotate stdio: Support --show-nr-samples option
  perf annotate: Period and samples view can't be used at the same time
  perf annotate browser: Support --show-nr-samples option
  perf annotate browser: Circulate percent, total period and samples
view

 tools/perf/builtin-annotate.c | 10 --
 tools/perf/ui/browsers/annotate.c | 31 +--
 tools/perf/util/annotate.c|  6 +-
 3 files changed, 38 insertions(+), 9 deletions(-)

-- 
2.7.4



[PATCH v2 1/4] perf annotate stdio: Support --show-nr-samples option

2017-08-15 Thread Taeung Song
Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/builtin-annotate.c | 2 ++
 tools/perf/util/annotate.c| 6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
 
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s 
for %s (%" PRIu64 " samples)\n",
- width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
 
printf("%-*.*s\n",
-- 
2.7.4



[PATCH v2 2/4] perf annotate: Period and samples view can't be used at the same time

2017-08-15 Thread Taeung Song
If users give two options --show-total-period
and --show-nr-samples, show their proper usage because
the two options can not be used at the same time.

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-annotate.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index acde4cc..9d25c27 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
struct perf_data_file file = {
.mode  = PERF_DATA_MODE_READ,
};
-   const struct option options[] = {
+   struct option options[] = {
OPT_STRING('i', "input", _name, "file",
"input file name"),
OPT_STRING('d', "dsos", _conf.dso_list_str, "dso[,dso...]",
@@ -452,8 +452,12 @@ int cmd_annotate(int argc, const char **argv)
 stdio__config_color, "always"),
OPT_END()
};
-   int ret = hists__init();
+   int ret;
+
+   set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
+   set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
 
+   ret = hists__init();
if (ret < 0)
return ret;
 
-- 
2.7.4



[PATCH v2 3/4] perf annotate browser: Support --show-nr-samples option

2017-08-15 Thread Taeung Song
Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/ui/browsers/annotate.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..faca1b9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 jump_arrows,
 show_linenr,
 show_nr_jumps,
+show_nr_samples,
 show_total_period;
 } annotate_browser__opts = {
.use_offset = true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
+   } else if (annotate_browser__opts.show_nr_samples) {
+   ui_browser__printf(browser, "%6" PRIu64 " ",
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
-  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+  
annotate_browser__opts.show_total_period ? "Period" :
+  
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
@@ -931,9 +936,11 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   /* Set default value for show_total_period.  */
+   /* Set default value for show_total_period and show_nr_samples  */
annotate_browser__opts.show_total_period =
- symbol_conf.show_total_period;
+   symbol_conf.show_total_period;
+   annotate_browser__opts.show_nr_samples =
+   symbol_conf.show_nr_samples;
 
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
+   ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
 };
-- 
2.7.4



[PATCH v2 0/4] perf annotate: Support --show-nr-samples and circulating view

2017-08-15 Thread Taeung Song
Hello,

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

And support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

I'd appreciate some feedback on my patchkit. :)
The code is available on 'perf/ann-nr-samples' branch at

  git://github.com/taeung/linux-perf.git

Thanks,
Taeung

v2:
- period and nr-samples view can't be used at the same time (Arnaldo)

Taeung Song (4):
  perf annotate stdio: Support --show-nr-samples option
  perf annotate: Period and samples view can't be used at the same time
  perf annotate browser: Support --show-nr-samples option
  perf annotate browser: Circulate percent, total period and samples
view

 tools/perf/builtin-annotate.c | 10 --
 tools/perf/ui/browsers/annotate.c | 31 +--
 tools/perf/util/annotate.c|  6 +-
 3 files changed, 38 insertions(+), 9 deletions(-)

-- 
2.7.4



[PATCH v2 1/4] perf annotate stdio: Support --show-nr-samples option

2017-08-15 Thread Taeung Song
Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

Cc: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-annotate.c | 2 ++
 tools/perf/util/annotate.c| 6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
 
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s 
for %s (%" PRIu64 " samples)\n",
- width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
 
printf("%-*.*s\n",
-- 
2.7.4



Re: [PATCH v4 5/9] perf annotate stdio: Support --show-nr-samples option

2017-08-14 Thread Taeung Song



On 08/15/2017 01:31 AM, Arnaldo Carvalho de Melo wrote:

Em Mon, Aug 14, 2017 at 07:42:07PM +0900, Taeung Song escreveu:

On 08/01/2017 03:24 PM, Taeung Song wrote:

On 07/29/2017 01:26 AM, Arnaldo Carvalho de Melo wrote:

Em Fri, Jul 28, 2017 at 01:16:16AM +0900, Taeung Song escreveu:

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.


So this is not that intuitive, i.e. if one ask for:

perf annotate --show-total-period --show-nr-samples

then both should appear, no?



I thought the users can use both --show-total-period and --show-nr-samples,
but perf-annotate can preferentially show the total period view IMHO.


That is inapropriate, if the user asks for both --show-total-period and
--show-nr-samples, then it either should show both or bail out telling
that that is not possible.

- Arnaldo



ok, got it, I'll send changed this patch based on your comment !

Thanks,
Taeung


What do you think about it ?
we need to prevent users from using both ?

Thanks,
Taeung



ping !




Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
   tools/perf/builtin-annotate.c | 2 ++
   tools/perf/util/annotate.c| 6 +-
   2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c
b/tools/perf/builtin-annotate.c
index 6db782d..a8e6db2 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -447,6 +447,8 @@ int cmd_annotate(int argc, const char **argv)
   "Show event group information together"),
   OPT_BOOLEAN(0, "show-total-period",
_conf.show_total_period,
   "Show a column with the sum of periods"),
+OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+"Show a column with the number of samples"),
   OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
"'always' (default), 'never' or 'auto' only
applicable to --stdio mode",
stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5125c2b..7032bdc 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1144,6 +1144,9 @@ static int disasm_line__print(struct
disasm_line *dl, struct symbol *sym, u64 st
   if (symbol_conf.show_total_period)
   color_fprintf(stdout, color, " %11" PRIu64,
 sample.period);
+else if (symbol_conf.show_nr_samples)
+color_fprintf(stdout, color, " %7" PRIu64,
+  sample.nr_samples);
   else
   color_fprintf(stdout, color, " %7.2f", percent);
   }
@@ -1824,7 +1827,8 @@ int symbol__annotate_printf(struct symbol
*sym, struct map *map,
   width *= evsel->nr_members;
   graph_dotted_len = printf(" %-*.*s|Source code &
Disassembly of %s for %s (%" PRIu64 " samples)\n",
-  width, width, symbol_conf.show_total_period ?
"Event count" : "Percent",
+  width, width, symbol_conf.show_total_period ?
"Event count" :
+  symbol_conf.show_nr_samples ? "Samples" : "Percent",
 d_filename, evsel_name, h->nr_samples);
   printf("%-*.*s\n",
--
2.7.4


Re: [PATCH v4 5/9] perf annotate stdio: Support --show-nr-samples option

2017-08-14 Thread Taeung Song



On 08/15/2017 01:31 AM, Arnaldo Carvalho de Melo wrote:

Em Mon, Aug 14, 2017 at 07:42:07PM +0900, Taeung Song escreveu:

On 08/01/2017 03:24 PM, Taeung Song wrote:

On 07/29/2017 01:26 AM, Arnaldo Carvalho de Melo wrote:

Em Fri, Jul 28, 2017 at 01:16:16AM +0900, Taeung Song escreveu:

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.


So this is not that intuitive, i.e. if one ask for:

perf annotate --show-total-period --show-nr-samples

then both should appear, no?



I thought the users can use both --show-total-period and --show-nr-samples,
but perf-annotate can preferentially show the total period view IMHO.


That is inapropriate, if the user asks for both --show-total-period and
--show-nr-samples, then it either should show both or bail out telling
that that is not possible.

- Arnaldo



ok, got it, I'll send changed this patch based on your comment !

Thanks,
Taeung


What do you think about it ?
we need to prevent users from using both ?

Thanks,
Taeung



ping !




Cc: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
   tools/perf/builtin-annotate.c | 2 ++
   tools/perf/util/annotate.c| 6 +-
   2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c
b/tools/perf/builtin-annotate.c
index 6db782d..a8e6db2 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -447,6 +447,8 @@ int cmd_annotate(int argc, const char **argv)
   "Show event group information together"),
   OPT_BOOLEAN(0, "show-total-period",
_conf.show_total_period,
   "Show a column with the sum of periods"),
+OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+"Show a column with the number of samples"),
   OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
"'always' (default), 'never' or 'auto' only
applicable to --stdio mode",
stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5125c2b..7032bdc 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1144,6 +1144,9 @@ static int disasm_line__print(struct
disasm_line *dl, struct symbol *sym, u64 st
   if (symbol_conf.show_total_period)
   color_fprintf(stdout, color, " %11" PRIu64,
 sample.period);
+else if (symbol_conf.show_nr_samples)
+color_fprintf(stdout, color, " %7" PRIu64,
+  sample.nr_samples);
   else
   color_fprintf(stdout, color, " %7.2f", percent);
   }
@@ -1824,7 +1827,8 @@ int symbol__annotate_printf(struct symbol
*sym, struct map *map,
   width *= evsel->nr_members;
   graph_dotted_len = printf(" %-*.*s|Source code &
Disassembly of %s for %s (%" PRIu64 " samples)\n",
-  width, width, symbol_conf.show_total_period ?
"Event count" : "Percent",
+  width, width, symbol_conf.show_total_period ?
"Event count" :
+  symbol_conf.show_nr_samples ? "Samples" : "Percent",
 d_filename, evsel_name, h->nr_samples);
   printf("%-*.*s\n",
--
2.7.4


Re: [PATCH v4 5/9] perf annotate stdio: Support --show-nr-samples option

2017-08-14 Thread Taeung Song

Hi Arnaldo,

On 08/01/2017 03:24 PM, Taeung Song wrote:



On 07/29/2017 01:26 AM, Arnaldo Carvalho de Melo wrote:

Em Fri, Jul 28, 2017 at 01:16:16AM +0900, Taeung Song escreveu:

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.


So this is not that intuitive, i.e. if one ask for:

   perf annotate --show-total-period --show-nr-samples

then both should appear, no?

- Arnaldo


I thought the users can use both --show-total-period and --show-nr-samples,
but perf-annotate can preferentially show the total period view IMHO.

What do you think about it ?
we need to prevent users from using both ?

Thanks,
Taeung



ping !




Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
  tools/perf/builtin-annotate.c | 2 ++
  tools/perf/util/annotate.c| 6 +-
  2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c 
b/tools/perf/builtin-annotate.c

index 6db782d..a8e6db2 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -447,6 +447,8 @@ int cmd_annotate(int argc, const char **argv)
  "Show event group information together"),
  OPT_BOOLEAN(0, "show-total-period", 
_conf.show_total_period,

  "Show a column with the sum of periods"),
+OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+"Show a column with the number of samples"),
  OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
   "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",

   stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5125c2b..7032bdc 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1144,6 +1144,9 @@ static int disasm_line__print(struct 
disasm_line *dl, struct symbol *sym, u64 st

  if (symbol_conf.show_total_period)
  color_fprintf(stdout, color, " %11" PRIu64,
sample.period);
+else if (symbol_conf.show_nr_samples)
+color_fprintf(stdout, color, " %7" PRIu64,
+  sample.nr_samples);
  else
  color_fprintf(stdout, color, " %7.2f", percent);
  }
@@ -1824,7 +1827,8 @@ int symbol__annotate_printf(struct symbol *sym, 
struct map *map,

  width *= evsel->nr_members;
  graph_dotted_len = printf(" %-*.*s|Source code & 
Disassembly of %s for %s (%" PRIu64 " samples)\n",
-  width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+  width, width, symbol_conf.show_total_period ? 
"Event count" :

+  symbol_conf.show_nr_samples ? "Samples" : "Percent",
d_filename, evsel_name, h->nr_samples);
  printf("%-*.*s\n",
--
2.7.4


Re: [PATCH v4 5/9] perf annotate stdio: Support --show-nr-samples option

2017-08-14 Thread Taeung Song

Hi Arnaldo,

On 08/01/2017 03:24 PM, Taeung Song wrote:



On 07/29/2017 01:26 AM, Arnaldo Carvalho de Melo wrote:

Em Fri, Jul 28, 2017 at 01:16:16AM +0900, Taeung Song escreveu:

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.


So this is not that intuitive, i.e. if one ask for:

   perf annotate --show-total-period --show-nr-samples

then both should appear, no?

- Arnaldo


I thought the users can use both --show-total-period and --show-nr-samples,
but perf-annotate can preferentially show the total period view IMHO.

What do you think about it ?
we need to prevent users from using both ?

Thanks,
Taeung



ping !




Cc: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
  tools/perf/builtin-annotate.c | 2 ++
  tools/perf/util/annotate.c| 6 +-
  2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c 
b/tools/perf/builtin-annotate.c

index 6db782d..a8e6db2 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -447,6 +447,8 @@ int cmd_annotate(int argc, const char **argv)
  "Show event group information together"),
  OPT_BOOLEAN(0, "show-total-period", 
_conf.show_total_period,

  "Show a column with the sum of periods"),
+OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+"Show a column with the number of samples"),
  OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
   "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",

   stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5125c2b..7032bdc 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1144,6 +1144,9 @@ static int disasm_line__print(struct 
disasm_line *dl, struct symbol *sym, u64 st

  if (symbol_conf.show_total_period)
  color_fprintf(stdout, color, " %11" PRIu64,
sample.period);
+else if (symbol_conf.show_nr_samples)
+color_fprintf(stdout, color, " %7" PRIu64,
+  sample.nr_samples);
  else
  color_fprintf(stdout, color, " %7.2f", percent);
  }
@@ -1824,7 +1827,8 @@ int symbol__annotate_printf(struct symbol *sym, 
struct map *map,

  width *= evsel->nr_members;
  graph_dotted_len = printf(" %-*.*s|Source code & 
Disassembly of %s for %s (%" PRIu64 " samples)\n",
-  width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+  width, width, symbol_conf.show_total_period ? 
"Event count" :

+  symbol_conf.show_nr_samples ? "Samples" : "Percent",
d_filename, evsel_name, h->nr_samples);
  printf("%-*.*s\n",
--
2.7.4


[PATCH 0/3] perf annotate: Support --show-nr-samples and circulating view

2017-08-01 Thread Taeung Song
Hello,

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

And support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

I'd appreciate some feedback on my patchkit. :)
The code is available on 'perf/ann-nr-samples' branch at

  git://github.com/taeung/linux-perf.git

Thanks,
Taeung

Taeung Song (3):
  perf annotate stdio: Support --show-nr-samples option
  perf annotate browser: Support --show-nr-samples option
  perf annotate browser: Circulate percent, total period and samples
view

 tools/perf/builtin-annotate.c |  2 ++
 tools/perf/ui/browsers/annotate.c | 31 +--
 tools/perf/util/annotate.c|  6 +-
 3 files changed, 32 insertions(+), 7 deletions(-)

-- 
2.7.4



[PATCH 0/3] perf annotate: Support --show-nr-samples and circulating view

2017-08-01 Thread Taeung Song
Hello,

Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

And support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

I'd appreciate some feedback on my patchkit. :)
The code is available on 'perf/ann-nr-samples' branch at

  git://github.com/taeung/linux-perf.git

Thanks,
Taeung

Taeung Song (3):
  perf annotate stdio: Support --show-nr-samples option
  perf annotate browser: Support --show-nr-samples option
  perf annotate browser: Circulate percent, total period and samples
view

 tools/perf/builtin-annotate.c |  2 ++
 tools/perf/ui/browsers/annotate.c | 31 +--
 tools/perf/util/annotate.c|  6 +-
 3 files changed, 32 insertions(+), 7 deletions(-)

-- 
2.7.4



[PATCH 1/3] perf annotate stdio: Support --show-nr-samples option

2017-08-01 Thread Taeung Song
Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/builtin-annotate.c | 2 ++
 tools/perf/util/annotate.c| 6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
 
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s 
for %s (%" PRIu64 " samples)\n",
- width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
 
printf("%-*.*s\n",
-- 
2.7.4



[PATCH 1/3] perf annotate stdio: Support --show-nr-samples option

2017-08-01 Thread Taeung Song
Add --show-nr-samples option to perf-annotate
so that it corresponds with perf-report.

Cc: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-annotate.c | 2 ++
 tools/perf/util/annotate.c| 6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..acde4cc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -445,6 +445,8 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
+   OPT_BOOLEAN('n', "show-nr-samples", _conf.show_nr_samples,
+   "Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
 "'always' (default), 'never' or 'auto' only 
applicable to --stdio mode",
 stdio__config_color, "always"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 2dab0e5..4397a8b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
+   else if (symbol_conf.show_nr_samples)
+   color_fprintf(stdout, color, " %7" PRIu64,
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
width *= evsel->nr_members;
 
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s 
for %s (%" PRIu64 " samples)\n",
- width, width, symbol_conf.show_total_period ? 
"Event count" : "Percent",
+ width, width, symbol_conf.show_total_period ? 
"Period" :
+ symbol_conf.show_nr_samples ? "Samples" : 
"Percent",
  d_filename, evsel_name, h->nr_samples);
 
printf("%-*.*s\n",
-- 
2.7.4



[PATCH 3/3] perf annotate browser: Circulate percent, total period and samples view

2017-08-01 Thread Taeung Song
With a existing 't' hotkey, support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

Suggested-by: Namhyung Kim <namhy...@kernel.org>
Cc: Milian Wolff <milian.wo...@kdab.com>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/ui/browsers/annotate.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index faca1b9..e82e6c5 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
-   "t Toggle total period view\n"
+   "t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
@@ -912,8 +912,19 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
}
continue;
case 't':
-   annotate_browser__opts.show_total_period =
- !annotate_browser__opts.show_total_period;
+   if (annotate_browser__opts.show_total_period) {
+   annotate_browser__opts.show_total_period = 
false;
+   annotate_browser__opts.show_nr_samples = true;
+   } else if (annotate_browser__opts.show_nr_samples)
+   annotate_browser__opts.show_nr_samples = false;
+   else
+   annotate_browser__opts.show_total_period = true;
+   annotate_browser__update_addr_width(browser);
+   continue;
+   case 'e':
+   annotate_browser__opts.show_total_period = false;
+   annotate_browser__opts.show_nr_samples =
+   !annotate_browser__opts.show_nr_samples;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:
-- 
2.7.4



[PATCH 3/3] perf annotate browser: Circulate percent, total period and samples view

2017-08-01 Thread Taeung Song
With a existing 't' hotkey, support the three view based on percent,
total period and number of samples on the annotate TUI browser,
circulating them like below:

  Percent -> Period -> Samples -> Percent ...

Suggested-by: Namhyung Kim 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/ui/browsers/annotate.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index faca1b9..e82e6c5 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
-   "t Toggle total period view\n"
+   "t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
@@ -912,8 +912,19 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
}
continue;
case 't':
-   annotate_browser__opts.show_total_period =
- !annotate_browser__opts.show_total_period;
+   if (annotate_browser__opts.show_total_period) {
+   annotate_browser__opts.show_total_period = 
false;
+   annotate_browser__opts.show_nr_samples = true;
+   } else if (annotate_browser__opts.show_nr_samples)
+   annotate_browser__opts.show_nr_samples = false;
+   else
+   annotate_browser__opts.show_total_period = true;
+   annotate_browser__update_addr_width(browser);
+   continue;
+   case 'e':
+   annotate_browser__opts.show_total_period = false;
+   annotate_browser__opts.show_nr_samples =
+   !annotate_browser__opts.show_nr_samples;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:
-- 
2.7.4



[PATCH 2/3] perf annotate browser: Support --show-nr-samples option

2017-08-01 Thread Taeung Song
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Signed-off-by: Taeung Song <treeze.tae...@gmail.com>
---
 tools/perf/ui/browsers/annotate.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..faca1b9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 jump_arrows,
 show_linenr,
 show_nr_jumps,
+show_nr_samples,
 show_total_period;
 } annotate_browser__opts = {
.use_offset = true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
+   } else if (annotate_browser__opts.show_nr_samples) {
+   ui_browser__printf(browser, "%6" PRIu64 " ",
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
-  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+  
annotate_browser__opts.show_total_period ? "Period" :
+  
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
@@ -931,9 +936,11 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   /* Set default value for show_total_period.  */
+   /* Set default value for show_total_period and show_nr_samples  */
annotate_browser__opts.show_total_period =
- symbol_conf.show_total_period;
+   symbol_conf.show_total_period;
+   annotate_browser__opts.show_nr_samples =
+   symbol_conf.show_nr_samples;
 
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
+   ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
 };
-- 
2.7.4



[PATCH 2/3] perf annotate browser: Support --show-nr-samples option

2017-08-01 Thread Taeung Song
Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/ui/browsers/annotate.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..faca1b9 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -42,6 +42,7 @@ static struct annotate_browser_opt {
 jump_arrows,
 show_linenr,
 show_nr_jumps,
+show_nr_samples,
 show_total_period;
 } annotate_browser__opts = {
.use_offset = true,
@@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
+   } else if (annotate_browser__opts.show_nr_samples) {
+   ui_browser__printf(browser, "%6" PRIu64 " ",
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
-  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+  
annotate_browser__opts.show_total_period ? "Period" :
+  
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
@@ -931,9 +936,11 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   /* Set default value for show_total_period.  */
+   /* Set default value for show_total_period and show_nr_samples  */
annotate_browser__opts.show_total_period =
- symbol_conf.show_total_period;
+   symbol_conf.show_total_period;
+   annotate_browser__opts.show_nr_samples =
+   symbol_conf.show_nr_samples;
 
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
 }
@@ -1184,6 +1191,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
+   ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
 };
-- 
2.7.4



  1   2   3   4   5   6   7   8   9   10   >