perf tools: Add +field argument support for --field/--sort options
Jiri Olsa
reviewercover perf tools: Add +field argument support for --field/--sort options
hi,
adding support to add field(s) to default field and sort orders via using the '+' prefix, like for report:
$ perf report -F +period,sample $ perf report -s +cpu
thanks,
jirka
---
Jiri Olsa (2):
perf tools: Add +field argument support for --field option perf tools: Add +field argument support for --sort option
tools/perf/ui/hist.c | 4 ++-- tools/perf/util/sort.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ tools/perf/util/sort.h | 1 + 3 files changed, 49 insertions(+), 8 deletions(-)
Jiri Olsa
reviewerPATCH 1/2 perf tools: Add +field argument support for --field option
Adding support to add field(s) to default field order via using the '+' prefix, like for report:
$ perf report
Samples: 10 of event 'cycles', Event count (approx.): 4463799
Overhead Command Shared Object Symbol
32.40% ls [kernel.kallsyms] [k] filemap_fault
28.19% ls [kernel.kallsyms] [k] get_page_from_freelist
23.38% ls [kernel.kallsyms] [k] enqueue_entity
15.04% ls [kernel.kallsyms] [k] mmap_region $ perf report -F +period,sample
Samples: 10 of event 'cycles', Event count (approx.): 4463799
Overhead Period Samples Command Shared Object Symbol
32.40% 1446493 1 ls [kernel.kallsyms] [k] filemap_fault
28.19% 1258486 1 ls [kernel.kallsyms] [k] get_page_from_freelist
23.38% 1043754 1 ls [kernel.kallsyms] [k] enqueue_entity
15.04% 671160 1 ls [kernel.kallsyms] [k] mmap_regionWorks in general for commands using --field option.
--- tools/perf/ui/hist.c | 4 ++-- tools/perf/util/sort.c | 24 +++++++++++++++++++----- tools/perf/util/sort.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-)
tools/perf/ui/hist.c +2 -2
@@ -452,7 +452,7 @@ void perf_hpp__init(void)/* * If user specified field order, no need to setup default fields. */ -if (field_order) +if (is_strict_order (field_order))return ;if (symbol_conf.cumulate_callchain) {
@@ -519,7 +519,7 @@ void perf_hpp__column_disable(unsigned col)void perf_hpp__cancel_cumulate (void ) { -if (field_order) +if (is_strict_order (field_order))return ;perf_hpp__column_disable (PERF_HPP__OVERHEAD_ACC );
tools/perf/util/sort.c +19 -5
@@ -1453,7 +1453,7 @@ static int __setup_sorting(void)int ret =0 ;if (sort_keys ==NULL ) { -if (field_order) { +if (is_strict_order (field_order)) {/* * If user specified field order but no sort order, * we'll honor it and not add default sort orders.
@@ -1639,23 +1639,36 @@ static void reset_dimensions(void) memory_sort_dimensions[i].taken =0 ; } +bool is_strict_order (const char *order) +{ +return order && (*order !='+' ); +} +static int __setup_output_field (void ) { -char *tmp, *tok, *str; -int ret =0 ; +char *tmp, *tok, *str, *strp; +int ret = -EINVAL ;if (field_order ==NULL )return 0 ;reset_dimensions (); - str =strdup (field_order); + strp = str =strdup (field_order);if (str ==NULL ) {error ("Not enough memory to setup output fields" );return -ENOMEM ; } -for (tok =strtok_r (str,", " , &tmp); +if (!is_strict_order (field_order)) + strp++; + +if (!strlen (strp)) { +error ("Invalid --fields key: `+'" ); + goto out; + } + +for (tok =strtok_r (strp,", " , &tmp); tok; tok =strtok_r (NULL ,", " , &tmp)) { ret =output_field_add (tok);if (ret == -EINVAL ) {
@@ -1667,6 +1680,7 @@ static int __setup_output_field(void) } } +out:free (str);return ret; }
tools/perf/util/sort.h +1 -0
@@ -218,4 +218,5 @@ void perf_hpp__set_elide(int idx, bool elide);int report_parse_ignore_callees_opt (const struct option *opt,const char *arg,int unset); +bool is_strict_order (const char *order);#endif /* __PERF_SORT_H */
Signature · 1 line
1.8.3.1
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Add +field argument support for --field option
perf tools: Add +field argument support for --field option
Commit-ID: 2f3f9bcf000b2043a480e7cc0cae582559fb0f13 Gitweb: http://git.kernel.org/tip/2f3f9bcf000b2043a480e7cc0cae582559fb0f13 Author: Jiri Olsa <[email protected]> AuthorDate: Fri, 22 Aug 2014 15:58:38 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sun, 24 Aug 2014 08:11:19 -0300
perf tools: Add +field argument support for --field option
Adding support to add field(s) to default field order via using the '+' prefix, like for report:
$ perf report
Samples: 10 of event 'cycles', Event count (approx.): 4463799
Overhead Command Shared Object Symbol
32.40% ls [kernel.kallsyms] [k] filemap_fault
28.19% ls [kernel.kallsyms] [k] get_page_from_freelist
23.38% ls [kernel.kallsyms] [k] enqueue_entity
15.04% ls [kernel.kallsyms] [k] mmap_region $ perf report -F +period,sample
Samples: 10 of event 'cycles', Event count (approx.): 4463799
Overhead Period Samples Command Shared Object Symbol
32.40% 1446493 1 ls [kernel.kallsyms] [k] filemap_fault
28.19% 1258486 1 ls [kernel.kallsyms] [k] get_page_from_freelist
23.38% 1043754 1 ls [kernel.kallsyms] [k] enqueue_entity
15.04% 671160 1 ls [kernel.kallsyms] [k] mmap_regionWorks in general for commands using --field option.
--- tools/perf/ui/hist.c | 4 ++-- tools/perf/util/sort.c | 24 +++++++++++++++++++----- tools/perf/util/sort.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-)
tools/perf/ui/hist.c +2 -2
@@ -452,7 +452,7 @@ void perf_hpp__init(void)/* * If user specified field order, no need to setup default fields. */ -if (field_order) +if (is_strict_order (field_order))return ;if (symbol_conf.cumulate_callchain) {
@@ -519,7 +519,7 @@ void perf_hpp__column_disable(unsigned col)void perf_hpp__cancel_cumulate (void ) { -if (field_order) +if (is_strict_order (field_order))return ;perf_hpp__column_disable (PERF_HPP__OVERHEAD_ACC );
tools/perf/util/sort.c +19 -5
@@ -1453,7 +1453,7 @@ static int __setup_sorting(void)int ret =0 ;if (sort_keys ==NULL ) { -if (field_order) { +if (is_strict_order (field_order)) {/* * If user specified field order but no sort order, * we'll honor it and not add default sort orders.
@@ -1639,23 +1639,36 @@ static void reset_dimensions(void) memory_sort_dimensions[i].taken =0 ; } +bool is_strict_order (const char *order) +{ +return order && (*order !='+' ); +} +static int __setup_output_field (void ) { -char *tmp, *tok, *str; -int ret =0 ; +char *tmp, *tok, *str, *strp; +int ret = -EINVAL ;if (field_order ==NULL )return 0 ;reset_dimensions (); - str =strdup (field_order); + strp = str =strdup (field_order);if (str ==NULL ) {error ("Not enough memory to setup output fields" );return -ENOMEM ; } -for (tok =strtok_r (str,", " , &tmp); +if (!is_strict_order (field_order)) + strp++; + +if (!strlen (strp)) { +error ("Invalid --fields key: `+'" ); + goto out; + } + +for (tok =strtok_r (strp,", " , &tmp); tok; tok =strtok_r (NULL ,", " , &tmp)) { ret =output_field_add (tok);if (ret == -EINVAL ) {
@@ -1667,6 +1680,7 @@ static int __setup_output_field(void) } } +out:free (str);return ret; }
tools/perf/util/sort.h +1 -0
@@ -218,4 +218,5 @@ void perf_hpp__set_elide(int idx, bool elide);int report_parse_ignore_callees_opt (const struct option *opt,const char *arg,int unset); +bool is_strict_order (const char *order);#endif /* __PERF_SORT_H */
Jiri Olsa
reviewerPATCH 2/2 perf tools: Add +field argument support for --sort option
In reply to Jiri OlsaAdding support to add field(s) to default sort order via using the '+' prefix, like for report:
$ perf report
Samples: 2K of event 'cycles', Event count (approx.): 882172583
Overhead Command Shared Object Symbol
7.39% swapper [kernel.kallsyms] [k] intel_idle
1.97% firefox libpthread-2.17.so [.] pthread_mutex_lock
1.39% firefox [snd_hda_intel] [k] azx_get_position
1.11% firefox libpthread-2.17.so [.] pthread_mutex_unlock $ perf report -s +cpu
Samples: 2K of event 'cycles', Event count (approx.): 882172583
Overhead Command Shared Object Symbol CPU
2.89% swapper [kernel.kallsyms] [k] intel_idle 000
2.61% swapper [kernel.kallsyms] [k] intel_idle 002
1.20% swapper [kernel.kallsyms] [k] intel_idle 001
0.82% firefox libpthread-2.17.so [.] pthread_mutex_lock 002Works in general for commands using --sort option.
--- tools/perf/util/sort.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
tools/perf/util/sort.c +27 -1
@@ -1446,12 +1446,38 @@ static const char *get_default_sort_order(void)return default_sort_orders[sort__mode]; } +static int setup_sort_order (void ) +{ +#define BUF_MAX 4096 +static char buf[BUF_MAX ]; + +if (!sort_order ||is_strict_order (sort_order)) +return 0 ; + +if (!strlen (sort_order +1 )) { +error ("Invalid --fields key: `+'" ); +return -EINVAL ; + } + +scnprintf (buf,BUF_MAX ,"%s,%s" , +get_default_sort_order (), + sort_order +1 ); + + sort_order = buf; +return 0 ; +#undef BUF_MAX +} +static int __setup_sorting (void ) {char *tmp, *tok, *str; -const char *sort_keys = sort_order; +const char *sort_keys;int ret =0 ; +if (setup_sort_order ()) +return -EINVAL ; + + sort_keys = sort_order;if (sort_keys ==NULL ) {if (is_strict_order (field_order)) {/*
Signature · 1 line
1.8.3.1
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/2] perf tools: Add +field argument support for --sort option
Em Fri, Aug 22, 2014 at 03:58:39PM +0200, Jiri Olsa escreveu:
Quoted 40 lines
Adding support to add field(s) to default sort order via using the '+' prefix, like for report:
$ perf report Samples: 2K of event 'cycles', Event count (approx.): 882172583 Overhead Command Shared Object Symbol 7.39% swapper [kernel.kallsyms] [k] intel_idle 1.97% firefox libpthread-2.17.so [.] pthread_mutex_lock 1.39% firefox [snd_hda_intel] [k] azx_get_position 1.11% firefox libpthread-2.17.so [.] pthread_mutex_unlock$ perf report -s +cpu Samples: 2K of event 'cycles', Event count (approx.): 882172583 Overhead Command Shared Object Symbol CPU 2.89% swapper [kernel.kallsyms] [k] intel_idle 000 2.61% swapper [kernel.kallsyms] [k] intel_idle 002 1.20% swapper [kernel.kallsyms] [k] intel_idle 001 0.82% firefox libpthread-2.17.so [.] pthread_mutex_lock 002Works in general for commands using --sort option.
Cc Arnaldo Carvalho de Melo <[email protected]>Cc Corey Ashford <[email protected]>Cc David Ahern <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jean Pihet <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/util/sort.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)tools/perf/util/sort.c +0
-0
tools/perf/util/sort.c static const char *get_default_sort_order(void) · line 1451
Quoted 6 lines
tools/perf/util/sort.c +3
-0@@ -1446,12 +1446,38 @@ static const char *get_default_sort_order(void)return default_sort_orders[sort__mode]; } +static int setup_sort_order (void ) +{ +#define BUF_MAX 4096
This is an arbitrary value, and you will use this just here, so you could just have used a number and later used sizeof(buf).
Anyway, what bothers me is the use of yet another static buffer.
The thing to use here is asprintf, that will do it all for you, format _and_ allocate a buffer the size you need.
Quoted 5 lines
tools/perf/util/sort.c +5
-0+static char buf[BUF_MAX ]; + +if (!sort_order ||is_strict_order (sort_order)) +return 0 ; +
tools/perf/util/sort.c static const char *get_default_sort_order(void) · line 1466
Quoted 10 lines
tools/perf/util/sort.c +10
-0+if (!strlen (sort_order +1 )) { +error ("Invalid --fields key: `+'" ); +return -EINVAL ; + } + +scnprintf (buf,BUF_MAX ,"%s,%s" , +get_default_sort_order (), + sort_order +1 ); + + sort_order = buf;
I.e. it would be better to have this as:
char *new_sort_order;
if (sort_order[1] == '\0') {
error("Invalid --fields key: `+'");
return -EINVAL;
}
if (asprintf(&new_sort_order, "%s,%s",
get_default_sort_order(), sort_order + 1) < 0) {
error("Not enough memory to set up --sort");
return -ENOMEM;
}
sort_order = new_sort_order;tools/perf/util/sort.c static const char *get_default_sort_order(void) · line 1467
Quoted 1 line
tools/perf/util/sort.c +1
-0+return 0 ;
Also please fix the error message, there is a cut'n'paste error there :-)
I applied the --fields one.
- Arnaldo
Quoted 19 lines
tools/perf/util/sort.c +8
-1+#undef BUF_MAX +} +static int __setup_sorting (void ) {char *tmp, *tok, *str; -const char *sort_keys = sort_order; +const char *sort_keys;int ret =0 ; +if (setup_sort_order ()) +return -EINVAL ; + + sort_keys = sort_order;if (sort_keys ==NULL ) {if (is_strict_order (field_order)) {/* Signature · 1 line
1.8.3.1
Re: [PATCH 2/2] perf tools: Add +field argument support for --sort option
On Fri, Aug 22, 2014 at 12:16:51PM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
Quoted 32 lines
tools/perf/util/sort.c static const char *get_default_sort_order(void) · line 1451
Quoted 5 lines
}
tools/perf/util/sort.c +3
-0+static int setup_sort_order (void ) +{ +#define BUF_MAX 4096This is an arbitrary value, and you will use this just here, so you could just have used a number and later used sizeof(buf).
Anyway, what bothers me is the use of yet another static buffer.
The thing to use here is asprintf, that will do it all for you, format _and_ allocate a buffer the size you need.
Quoted 5 lines
tools/perf/util/sort.c +5
-0+static char buf[BUF_MAX ]; + +if (!sort_order ||is_strict_order (sort_order)) +return 0 ; +tools/perf/util/sort.c static const char *get_default_sort_order(void) · line 1466
Quoted 10 lines
tools/perf/util/sort.c +10
-0+if (!strlen (sort_order +1 )) { +error ("Invalid --fields key: `+'" ); +return -EINVAL ; + } + +scnprintf (buf,BUF_MAX ,"%s,%s" , +get_default_sort_order (), + sort_order +1 ); + + sort_order = buf;I.e. it would be better to have this as:
Quoted 12 lines
char *new_sort_order;
if (sort_order[1] == '\0') {
error("Invalid --fields key: `+'");
return -EINVAL;
}
if (asprintf(&new_sort_order, "%s,%s",
get_default_sort_order(), sort_order + 1) < 0) {
error("Not enough memory to set up --sort");
return -ENOMEM;
}ok, will check the asprintf
Quoted 7 lines
sort_order = new_sort_order;Review
Quoted 1 line
(quoted diff) +1
-0+ return 0;Also please fix the error message, there is a cut'n'paste error there :-)
aargh right ;-)
I'll send v2
thanks,
jirka
PATCH v2 1/1 perf tools: Add +field argument support for --sort option
Quoted 54 lines · Jiri Olsa
On Fri, Aug 22, 2014 at 12:16:51PM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
Quoted 32 lines
Review
Quoted 5 lines
}
(quoted diff) +3
-0+static int setup_sort_order(void) +{ +#define BUF_MAX 4096This is an arbitrary value, and you will use this just here, so you could just have used a number and later used sizeof(buf).
Anyway, what bothers me is the use of yet another static buffer.
The thing to use here is asprintf, that will do it all for you, format _and_ allocate a buffer the size you need.
Quoted 5 lines
(quoted diff) +5
-0+ static char buf[BUF_MAX]; + + if (!sort_order || is_strict_order(sort_order)) + return 0; +Review
Quoted 10 lines
(quoted diff) +10
-0+ if (!strlen(sort_order + 1)) { + error("Invalid --fields key: `+'"); + return -EINVAL; + } + + scnprintf(buf, BUF_MAX, "%s,%s", + get_default_sort_order(), + sort_order + 1); + + sort_order = buf;I.e. it would be better to have this as:
Quoted 12 lines
char *new_sort_order; if (sort_order[1] == '\0') { error("Invalid --fields key: `+'"); return -EINVAL; } if (asprintf(&new_sort_order, "%s,%s", get_default_sort_order(), sort_order + 1) < 0) { error("Not enough memory to set up --sort"); return -ENOMEM; }ok, will check the asprintf
Quoted 3 lines
sort_order = new_sort_order;
Quoted 8 lines
Quoted 4 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ return 0;Also please fix the error message, there is a cut'n'paste error there :-)
aargh right ;-)
I'll send v2
attached v2 with changes suggested above:
- use dynamic memory instead static buffer
- fix error message typo
thanks,
jirka
---
Adding support to add field(s) to default sort order via using the '+' prefix, like for report:
$ perf report
Samples: 2K of event 'cycles', Event count (approx.): 882172583
Overhead Command Shared Object Symbol
7.39% swapper [kernel.kallsyms] [k] intel_idle
1.97% firefox libpthread-2.17.so [.] pthread_mutex_lock
1.39% firefox [snd_hda_intel] [k] azx_get_position
1.11% firefox libpthread-2.17.so [.] pthread_mutex_unlock $ perf report -s +cpu
Samples: 2K of event 'cycles', Event count (approx.): 882172583
Overhead Command Shared Object Symbol CPU
2.89% swapper [kernel.kallsyms] [k] intel_idle 000
2.61% swapper [kernel.kallsyms] [k] intel_idle 002
1.20% swapper [kernel.kallsyms] [k] intel_idle 001
0.82% firefox libpthread-2.17.so [.] pthread_mutex_lock 002Works in general for commands using --sort option.
--- tools/perf/util/sort.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
tools/perf/util/sort.c +36 -1
@@ -1446,12 +1446,47 @@ static const char *get_default_sort_order(void)return default_sort_orders[sort__mode]; } +static int setup_sort_order (void ) +{ +char *new_sort_order; + +/* +* Append '+'-prefixed sort order to the default sort +* order string. +*/ +if (!sort_order ||is_strict_order (sort_order)) +return 0 ; + +if (sort_order[1 ] =='\0' ) { +error ("Invalid --sort key: `+'" ); +return -EINVAL ; + } + +/* +* We allocate new sort_order string, but we never free it, +* because it's checked over the rest of the code. +*/ +if (asprintf (&new_sort_order,"%s,%s" , +get_default_sort_order (), sort_order +1 ) <0 ) { +error ("Not enough memory to set up --sort" ); +return -ENOMEM ; + } + + sort_order = new_sort_order; +return 0 ; +} +static int __setup_sorting (void ) {char *tmp, *tok, *str; -const char *sort_keys = sort_order; +const char *sort_keys;int ret =0 ; + ret =setup_sort_order (); +if (ret) +return ret; + + sort_keys = sort_order;if (sort_keys ==NULL ) {if (is_strict_order (field_order)) {/*
Signature · 1 line
1.8.3.1
Re: [PATCHv2] perf tools: Add +field argument support for --sort option
Hi Jiri,
Quoted 21 lines · Jiri Olsa
Adding support to add field(s) to default sort order via using the '+' prefix, like for report:
$ perf report Samples: 2K of event 'cycles', Event count (approx.): 882172583 Overhead Command Shared Object Symbol 7.39% swapper [kernel.kallsyms] [k] intel_idle 1.97% firefox libpthread-2.17.so [.] pthread_mutex_lock 1.39% firefox [snd_hda_intel] [k] azx_get_position 1.11% firefox libpthread-2.17.so [.] pthread_mutex_unlock$ perf report -s +cpu Samples: 2K of event 'cycles', Event count (approx.): 882172583 Overhead Command Shared Object Symbol CPU 2.89% swapper [kernel.kallsyms] [k] intel_idle 000 2.61% swapper [kernel.kallsyms] [k] intel_idle 002 1.20% swapper [kernel.kallsyms] [k] intel_idle 001 0.82% firefox libpthread-2.17.so [.] pthread_mutex_lock 002Works in general for commands using --sort option.
Quoted 9 lines
Cc Arnaldo Carvalho de Melo <[email protected]>Cc Corey Ashford <[email protected]>Cc David Ahern <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jean Pihet <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Jiri Olsa <[email protected]>
Thanks,
Namhyung
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Add +field argument support for --sort option
In reply to Jiri Olsaperf tools: Add +field argument support for --sort option
Commit-ID: 1a1c0ffb2adb2d2ce7bb9c4dfd2935ba345cf2c2 Gitweb: http://git.kernel.org/tip/1a1c0ffb2adb2d2ce7bb9c4dfd2935ba345cf2c2 Author: Jiri Olsa <[email protected]> AuthorDate: Sat, 23 Aug 2014 14:59:48 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 17 Sep 2014 17:08:07 -0300
perf tools: Add +field argument support for --sort option
Adding support to add field(s) to default sort order via using the '+' prefix, like for report:
$ perf report
Samples: 2K of event 'cycles', Event count (approx.): 882172583
Overhead Command Shared Object Symbol
7.39% swapper [kernel.kallsyms] [k] intel_idle
1.97% firefox libpthread-2.17.so [.] pthread_mutex_lock
1.39% firefox [snd_hda_intel] [k] azx_get_position
1.11% firefox libpthread-2.17.so [.] pthread_mutex_unlock $ perf report -s +cpu
Samples: 2K of event 'cycles', Event count (approx.): 882172583
Overhead Command Shared Object Symbol CPU
2.89% swapper [kernel.kallsyms] [k] intel_idle 000
2.61% swapper [kernel.kallsyms] [k] intel_idle 002
1.20% swapper [kernel.kallsyms] [k] intel_idle 001
0.82% firefox libpthread-2.17.so [.] pthread_mutex_lock 002Works in general for commands using --sort option.
v2 with changes suggested:
- Use dynamic memory instead static buffer
- Fix error message typo
--- tools/perf/util/sort.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
tools/perf/util/sort.c +36 -1
@@ -1446,12 +1446,47 @@ static const char *get_default_sort_order(void)return default_sort_orders[sort__mode]; } +static int setup_sort_order (void ) +{ +char *new_sort_order; + +/* +* Append '+'-prefixed sort order to the default sort +* order string. +*/ +if (!sort_order ||is_strict_order (sort_order)) +return 0 ; + +if (sort_order[1 ] =='\0' ) { +error ("Invalid --sort key: `+'" ); +return -EINVAL ; + } + +/* +* We allocate new sort_order string, but we never free it, +* because it's checked over the rest of the code. +*/ +if (asprintf (&new_sort_order,"%s,%s" , +get_default_sort_order (), sort_order +1 ) <0 ) { +error ("Not enough memory to set up --sort" ); +return -ENOMEM ; + } + + sort_order = new_sort_order; +return 0 ; +} +static int __setup_sorting (void ) {char *tmp, *tok, *str; -const char *sort_keys = sort_order; +const char *sort_keys;int ret =0 ; + ret =setup_sort_order (); +if (ret) +return ret; + + sort_keys = sort_order;if (sort_keys ==NULL ) {if (is_strict_order (field_order)) {/*
Arnaldo Carvalho de Melo
maintainerEm Fri, Aug 22, 2014 at 03:58:37PM +0200, Jiri Olsa escreveu:
Quoted 8 lines
hi,
adding support to add field(s) to default field and sort orders via using the '+' prefix, like for report:$ perf report -F +period,sample $ perf report -s +cputhanks,
jirka
Really cool feature, (lightly) tested and applied,
Thanks,
- Arnaldo
Quoted 20 lines
Cc Arnaldo Carvalho de Melo <[email protected]>Cc Corey Ashford <[email protected]>Cc David Ahern <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jean Pihet <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Jiri Olsa <[email protected]>---
Jiri Olsa (2):
perf tools: Add +field argument support for --field option perf tools: Add +field argument support for --sort optiontools/perf/ui/hist.c | 4 ++-- tools/perf/util/sort.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ tools/perf/util/sort.h | 1 + 3 files changed, 49 insertions(+), 8 deletions(-)