perf script: Add missing closedir() calls
PATCH 1/8 perf script: Add missing closedir() calls
The get_script_path() calls opendir() but misses corresponding closedir()'s. Add them.
--- tools/perf/builtin-script.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
tools/perf/builtin-script.c +4 -0
@@ -1018,13 +1018,17 @@ static char *get_script_path(const char *script_root, const char *suffix) __script_root =get_script_root (&script_dirent, suffix);if (__script_root && !strcmp (script_root, __script_root)) {free (__script_root); +closedir (lang_dir); +closedir (scripts_dir);snprintf (script_path,MAXPATHLEN ,"%s/%s" , lang_path, script_dirent.d_name);return strdup (script_path); }free (__script_root); } +closedir (lang_dir); } +closedir (scripts_dir);return NULL ; }
Signature · 1 line
1.7.6
PATCH 2/8 perf test: Change type of '-v' option to INCR
The '-v' option is usually defined via OPT_INCR not _INTEGER. Follow the trend :).
--- tools/perf/builtin-test.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/builtin-test.c +1 -1
@@ -1396,7 +1396,7 @@ int cmd_test(int argc, const char **argv, const char *prefix __used) NULL, };const struct option test_options[] = { -OPT_INTEGER ('v' ,"verbose" , &verbose, +OPT_INCR ('v' ,"verbose" , &verbose,"be more verbose (show symbol address, etc)" ),OPT_END () };
Signature · 1 line
1.7.6
PATCH 3/8 perf top: Add error message for EMFILE
In reply to Namhyung KimWhen a user tries to open so many events, perf_event_open syscall may fail with EMFILE. Provide advise for that case.
--- tools/perf/builtin-top.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
tools/perf/builtin-top.c +4 -0
@@ -889,6 +889,10 @@ try_again:ui__warning ("The %s event is not supported.\n" ,event_name (counter)); goto out_err; + }else if (err ==EMFILE ) { +ui__warning ("Too many events are opened.\n" +"Try again after reducing the number of events\n" ); + goto out_err; } ui__warning("The sys_perf_event_open() syscall "
Signature · 1 line
1.7.6
PATCH 5/8 perf kmem: Fix a memory leak
In reply to Namhyung KimThe 'str' should be freed when sort_dimension__add() failed too.
--- tools/perf/builtin-kmem.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
tools/perf/builtin-kmem.c +1 -0
@@ -647,6 +647,7 @@ static int setup_sorting(struct list_head *sort_list, const char *arg)break ;if (sort_dimension__add (tok, sort_list) <0 ) {error ("Unknown --sort key: '%s'" , tok); +free (str);return -1 ; } }
Signature · 1 line
1.7.6
PATCH 8/8 perf report: Fix --stdio output alignment when --showcpuutilization used
In reply to Namhyung KimCurrent perf report output is broken if --showcpuutilization is used. Combination with -n and/or --show-total-period make things worse. This patch fixes it as follows:
before:
# Events: 13 cycles
#
# Overhead sys us Command Shared Object Symbol
# ........ ....... ................. .....................
#
48.25% 48.25% 0.00% sleep [kernel.kallsyms] [k] trace_hardirqs_off
34.99% 34.99% 0.00% sleep [kernel.kallsyms] [k] __find_get_block_slow
15.99% 15.99% 0.00% sleep [kernel.kallsyms] [k] lock_release_holdtime
0.77% 0.77% 0.00% sleep [kernel.kallsyms] [k] native_write_msr_safeafter:
# Events: 13 cycles
#
# Overhead sys us Command Shared Object Symbol
# ........ ....... ....... ....... ................. .....................
#
48.25% 48.25% 0.00% sleep [kernel.kallsyms] [k] trace_hardirqs_off
34.99% 34.99% 0.00% sleep [kernel.kallsyms] [k] __find_get_block_slow
15.99% 15.99% 0.00% sleep [kernel.kallsyms] [k] lock_release_holdtime
0.77% 0.77% 0.00% sleep [kernel.kallsyms] [k] native_write_msr_safe--- tools/perf/util/hist.c | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-)
tools/perf/util/hist.c +18 -16
@@ -917,20 +917,6 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,fprintf (fp,"# %s" , pair ?"Baseline" :"Overhead" ); -if (symbol_conf.show_nr_samples) { -if (sep) -fprintf (fp,"%cSamples" , *sep); -else -fputs (" Samples " , fp); - } - -if (symbol_conf.show_total_period) { -if (sep) - ret +=fprintf (fp,"%cPeriod" , *sep); -else - ret +=fprintf (fp," Period " ); - } -if (symbol_conf.show_cpu_utilization) {if (sep) { ret +=fprintf (fp,"%csys" , *sep);
@@ -940,8 +926,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, ret +=fprintf (fp,"%cguest us" , *sep); } }else { - ret +=fprintf (fp," sys " ); - ret +=fprintf (fp," us " ); + ret +=fprintf (fp," sys " ); + ret +=fprintf (fp," us " );if (perf_guest) { ret +=fprintf (fp," guest sys " ); ret +=fprintf (fp," guest us " );
@@ -949,6 +935,20 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, } } +if (symbol_conf.show_nr_samples) { +if (sep) +fprintf (fp,"%cSamples" , *sep); +else +fputs (" Samples " , fp); + } + +if (symbol_conf.show_total_period) { +if (sep) + ret +=fprintf (fp,"%cPeriod" , *sep); +else + ret +=fprintf (fp," Period " ); + } +if (pair) {if (sep) ret +=fprintf (fp,"%cDelta" , *sep);
@@ -993,6 +993,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, goto print_entries;fprintf (fp,"# ........" ); +if (symbol_conf.show_cpu_utilization) +fprintf (fp," ....... ......." );if (symbol_conf.show_nr_samples)fprintf (fp," .........." );if (symbol_conf.show_total_period)
Signature · 1 line
1.7.6
PATCH 7/8 perf annotate: Get rid of field_sep check
In reply to Namhyung KimThe 'field_sep' variable is not set anywhere. Just remove the conditional.
--- tools/perf/builtin-annotate.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
tools/perf/builtin-annotate.c +0 -5
@@ -313,10 +313,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used) annotate.sym_hist_filter = argv[0 ]; } -if (field_sep && *field_sep =='.' ) { -pr_err ("'.' is the only non valid --field-separator argument\n" ); -return -1 ; - } -return __cmd_annotate (&annotate); }
Signature · 1 line
1.7.6
PATCH 6/8 perf annotate: Fix usage string
In reply to Namhyung KimThe annotate command doesn't take non-option arguments. In fact, it can take last argument as a symbol filter though, but that's a special case and, IMHO, it should be discouraged in favor of the -s option.
--- tools/perf/builtin-annotate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -235,7 +235,7 @@ out_delete: }static const char *const annotate_usage[] = { -"perf annotate [<options>] <command>" , +"perf annotate [<options>]" ,NULL };
Signature · 1 line
1.7.6
PATCH 4/8 perf kmem: Add missing closedir() calls
In reply to Namhyung KimThe setup_cpunode_map() calls opendir() but misses corresponding closedir(). Add them.
--- tools/perf/builtin-kmem.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/builtin-kmem.c +2 -0
@@ -108,7 +108,9 @@ static void setup_cpunode_map(void)continue ; cpunode_map[cpu] = mem; } +closedir (dir2); } +closedir (dir1); } static void insert_alloc_stat(unsigned long call_site, unsigned long ptr,
Signature · 1 line
1.7.6
Commit-ID: 946ef2a24523e59e5cf931068ab7e9443c63c9df Gitweb: http://git.kernel.org/tip/946ef2a24523e59e5cf931068ab7e9443c63c9df Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 8 Jan 2012 02:25:25 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 8 Jan 2012 12:35:41 -0200
perf script: Add missing closedir() calls
The get_script_path() calls opendir() but misses corresponding closedir()'s. Add them.
--- tools/perf/builtin-script.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
tools/perf/builtin-script.c +4 -0
@@ -1018,13 +1018,17 @@ static char *get_script_path(const char *script_root, const char *suffix) __script_root =get_script_root (&script_dirent, suffix);if (__script_root && !strcmp (script_root, __script_root)) {free (__script_root); +closedir (lang_dir); +closedir (scripts_dir);snprintf (script_path,MAXPATHLEN ,"%s/%s" , lang_path, script_dirent.d_name);return strdup (script_path); }free (__script_root); } +closedir (lang_dir); } +closedir (scripts_dir);return NULL ; }
[tip:perf/core] perf test: Change type of '-v' option to INCR
In reply to Namhyung KimCommit-ID: c30ab8aa084843159b4679e9a3d7f63187d5906a Gitweb: http://git.kernel.org/tip/c30ab8aa084843159b4679e9a3d7f63187d5906a Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 8 Jan 2012 02:25:26 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 8 Jan 2012 13:25:00 -0200
perf test: Change type of '-v' option to INCR
The '-v' option is usually defined via OPT_INCR not _INTEGER. Follow the trend :).
--- tools/perf/builtin-test.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/builtin-test.c +1 -1
@@ -1396,7 +1396,7 @@ int cmd_test(int argc, const char **argv, const char *prefix __used) NULL, };const struct option test_options[] = { -OPT_INTEGER ('v' ,"verbose" , &verbose, +OPT_INCR ('v' ,"verbose" , &verbose,"be more verbose (show symbol address, etc)" ),OPT_END () };
[tip:perf/core] perf top: Add error message for EMFILE
In reply to Namhyung KimCommit-ID: cdce445906852d90efdc773ca7ba460e6e41664d Gitweb: http://git.kernel.org/tip/cdce445906852d90efdc773ca7ba460e6e41664d Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 8 Jan 2012 02:25:27 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 8 Jan 2012 13:26:11 -0200
perf top: Add error message for EMFILE
When a user tries to open so many events, perf_event_open syscall may fail with EMFILE. Provide advise for that case.
--- tools/perf/builtin-top.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
tools/perf/builtin-top.c +4 -0
@@ -888,6 +888,10 @@ try_again:ui__warning ("The %s event is not supported.\n" ,event_name (counter)); goto out_err; + }else if (err ==EMFILE ) { +ui__warning ("Too many events are opened.\n" +"Try again after reducing the number of events\n" ); + goto out_err; } ui__warning("The sys_perf_event_open() syscall "
[tip:perf/core] perf kmem: Add missing closedir() calls
In reply to Namhyung KimCommit-ID: 8442da1d9f445b454accdb148355ee990ebf3b32 Gitweb: http://git.kernel.org/tip/8442da1d9f445b454accdb148355ee990ebf3b32 Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 8 Jan 2012 02:25:28 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 8 Jan 2012 13:27:06 -0200
perf kmem: Add missing closedir() calls
The setup_cpunode_map() calls opendir() but misses corresponding closedir(). Add them.
--- tools/perf/builtin-kmem.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/builtin-kmem.c +2 -0
@@ -108,7 +108,9 @@ static void setup_cpunode_map(void)continue ; cpunode_map[cpu] = mem; } +closedir (dir2); } +closedir (dir1); } static void insert_alloc_stat(unsigned long call_site, unsigned long ptr,
[tip:perf/core] perf kmem: Fix a memory leak
In reply to Namhyung KimCommit-ID: 1b22859d4320d472a7a51ff4a43f62b0578469de Gitweb: http://git.kernel.org/tip/1b22859d4320d472a7a51ff4a43f62b0578469de Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 8 Jan 2012 02:25:29 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 8 Jan 2012 13:27:54 -0200
perf kmem: Fix a memory leak
The 'str' should be freed when sort_dimension__add() failed too.
--- tools/perf/builtin-kmem.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
tools/perf/builtin-kmem.c +1 -0
@@ -647,6 +647,7 @@ static int setup_sorting(struct list_head *sort_list, const char *arg)break ;if (sort_dimension__add (tok, sort_list) <0 ) {error ("Unknown --sort key: '%s'" , tok); +free (str);return -1 ; } }
[tip:perf/core] perf annotate: Fix usage string
In reply to Namhyung KimCommit-ID: 993452541796f3637da9f2e537b9333494b3b2a1 Gitweb: http://git.kernel.org/tip/993452541796f3637da9f2e537b9333494b3b2a1 Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 8 Jan 2012 02:25:30 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 8 Jan 2012 13:28:48 -0200
perf annotate: Fix usage string
The annotate command doesn't take non-option arguments.
In fact, it can take last argument as a symbol filter though, but that's a special case and, IMHO, it should be discouraged in favor of the -s option.
--- tools/perf/builtin-annotate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -235,7 +235,7 @@ out_delete: }static const char *const annotate_usage[] = { -"perf annotate [<options>] <command>" , +"perf annotate [<options>]" ,NULL };
[tip:perf/core] perf annotate: Get rid of field_sep check
In reply to Namhyung KimCommit-ID: 6714a04114639350a7fed93edf8e1b995c5e8059 Gitweb: http://git.kernel.org/tip/6714a04114639350a7fed93edf8e1b995c5e8059 Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 8 Jan 2012 02:25:31 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 8 Jan 2012 13:29:34 -0200
perf annotate: Get rid of field_sep check
The 'field_sep' variable is not set anywhere. Just remove the conditional.
--- tools/perf/builtin-annotate.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
tools/perf/builtin-annotate.c +0 -5
@@ -313,10 +313,5 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used) annotate.sym_hist_filter = argv[0 ]; } -if (field_sep && *field_sep =='.' ) { -pr_err ("'.' is the only non valid --field-separator argument\n" ); -return -1 ; - } -return __cmd_annotate (&annotate); }
[tip:perf/core] perf report: Fix --stdio output alignment when --showcpuutilization used
In reply to Namhyung KimCommit-ID: 0ed35abc2b569e94498705d250c4767c5284f643 Gitweb: http://git.kernel.org/tip/0ed35abc2b569e94498705d250c4767c5284f643 Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 8 Jan 2012 02:25:32 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 8 Jan 2012 13:32:51 -0200
perf report: Fix --stdio output alignment when --showcpuutilization used
Current perf report output is broken if --showcpuutilization is used. Combination with -n and/or --show-total-period make things worse. This patch fixes it as follows:
before:
48.25% 48.25% 0.00% sleep [kernel.kallsyms] [k] trace_hardirqs_off
34.99% 34.99% 0.00% sleep [kernel.kallsyms] [k] __find_get_block_slow
15.99% 15.99% 0.00% sleep [kernel.kallsyms] [k] lock_release_holdtime
0.77% 0.77% 0.00% sleep [kernel.kallsyms] [k] native_write_msr_safeafter:
48.25% 48.25% 0.00% sleep [kernel.kallsyms] [k] trace_hardirqs_off
34.99% 34.99% 0.00% sleep [kernel.kallsyms] [k] __find_get_block_slow
15.99% 15.99% 0.00% sleep [kernel.kallsyms] [k] lock_release_holdtime
0.77% 0.77% 0.00% sleep [kernel.kallsyms] [k] native_write_msr_safe--- tools/perf/util/hist.c | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-)
tools/perf/util/hist.c +18 -16
@@ -919,20 +919,6 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,fprintf (fp,"# %s" , pair ?"Baseline" :"Overhead" ); -if (symbol_conf.show_nr_samples) { -if (sep) -fprintf (fp,"%cSamples" , *sep); -else -fputs (" Samples " , fp); - } - -if (symbol_conf.show_total_period) { -if (sep) - ret +=fprintf (fp,"%cPeriod" , *sep); -else - ret +=fprintf (fp," Period " ); - } -if (symbol_conf.show_cpu_utilization) {if (sep) { ret +=fprintf (fp,"%csys" , *sep);
@@ -942,8 +928,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, ret +=fprintf (fp,"%cguest us" , *sep); } }else { - ret +=fprintf (fp," sys " ); - ret +=fprintf (fp," us " ); + ret +=fprintf (fp," sys " ); + ret +=fprintf (fp," us " );if (perf_guest) { ret +=fprintf (fp," guest sys " ); ret +=fprintf (fp," guest us " );
@@ -951,6 +937,20 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, } } +if (symbol_conf.show_nr_samples) { +if (sep) +fprintf (fp,"%cSamples" , *sep); +else +fputs (" Samples " , fp); + } + +if (symbol_conf.show_total_period) { +if (sep) + ret +=fprintf (fp,"%cPeriod" , *sep); +else + ret +=fprintf (fp," Period " ); + } +if (pair) {if (sep) ret +=fprintf (fp,"%cDelta" , *sep);
@@ -995,6 +995,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, goto print_entries;fprintf (fp,"# ........" ); +if (symbol_conf.show_cpu_utilization) +fprintf (fp," ....... ......." );if (symbol_conf.show_nr_samples)fprintf (fp," .........." );if (symbol_conf.show_total_period)