lkml.org 
[lkml]   [2016]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 17/26] perf tools: Pass perf_hpp_list all the way through setup_sort_list
Date
Passing perf_hpp_list all the way through setup_sort_list
so the sort entry could be added on the arbitrary list.

Link: http://lkml.kernel.org/n/tip-1r0tlhwdfolal61gvciii07e@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/sort.c | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 3461198217fc..020b3244aec9 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1604,14 +1604,15 @@ static struct perf_hpp_fmt *__hpp_dimension__alloc_hpp(struct hpp_dimension *hd)
return fmt;
}

-static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd)
+static int __sort_dimension__add_hpp_sort(struct perf_hpp_list *list,
+ struct sort_dimension *sd)
{
struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd);

if (hse == NULL)
return -1;

- perf_hpp__register_sort_field(&hse->hpp);
+ perf_hpp_list__register_sort_field(list, &hse->hpp);
return 0;
}

@@ -2084,12 +2085,13 @@ out:
return ret;
}

-static int __sort_dimension__add(struct sort_dimension *sd)
+static int __sort_dimension__add(struct perf_hpp_list *list,
+ struct sort_dimension *sd)
{
if (sd->taken)
return 0;

- if (__sort_dimension__add_hpp_sort(sd) < 0)
+ if (__sort_dimension__add_hpp_sort(list, sd) < 0)
return -1;

if (sd->entry->se_collapse)
@@ -2100,7 +2102,8 @@ static int __sort_dimension__add(struct sort_dimension *sd)
return 0;
}

-static int __hpp_dimension__add(struct hpp_dimension *hd)
+static int __hpp_dimension__add(struct perf_hpp_list *list,
+ struct hpp_dimension *hd)
{
struct perf_hpp_fmt *fmt;

@@ -2112,7 +2115,7 @@ static int __hpp_dimension__add(struct hpp_dimension *hd)
return -1;

hd->taken = 1;
- perf_hpp__register_sort_field(fmt);
+ perf_hpp_list__register_sort_field(list, fmt);
return 0;
}

@@ -2150,7 +2153,7 @@ int hpp_dimension__add_output(unsigned col)
return __hpp_dimension__add_output(&hpp_sort_dimensions[col]);
}

-static int sort_dimension__add(const char *tok,
+static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
struct perf_evlist *evlist __maybe_unused)
{
unsigned int i;
@@ -2188,7 +2191,7 @@ static int sort_dimension__add(const char *tok,
sort__has_socket = 1;
}

- return __sort_dimension__add(sd);
+ return __sort_dimension__add(list, sd);
}

for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
@@ -2197,7 +2200,7 @@ static int sort_dimension__add(const char *tok,
if (strncasecmp(tok, hd->name, strlen(tok)))
continue;

- return __hpp_dimension__add(hd);
+ return __hpp_dimension__add(list, hd);
}

for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
@@ -2212,7 +2215,7 @@ static int sort_dimension__add(const char *tok,
if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
sort__has_sym = 1;

- __sort_dimension__add(sd);
+ __sort_dimension__add(list, sd);
return 0;
}

@@ -2228,7 +2231,7 @@ static int sort_dimension__add(const char *tok,
if (sd->entry == &sort_mem_daddr_sym)
sort__has_sym = 1;

- __sort_dimension__add(sd);
+ __sort_dimension__add(list, sd);
return 0;
}

@@ -2238,14 +2241,15 @@ static int sort_dimension__add(const char *tok,
return -ESRCH;
}

-static int setup_sort_list(char *str, struct perf_evlist *evlist)
+static int setup_sort_list(struct perf_hpp_list *list, char *str,
+ struct perf_evlist *evlist)
{
char *tmp, *tok;
int ret = 0;

for (tok = strtok_r(str, ", ", &tmp);
tok; tok = strtok_r(NULL, ", ", &tmp)) {
- ret = sort_dimension__add(tok, evlist);
+ ret = sort_dimension__add(list, tok, evlist);
if (ret == -EINVAL) {
error("Invalid --sort key: `%s'", tok);
break;
@@ -2390,7 +2394,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
}
}

- ret = setup_sort_list(str, evlist);
+ ret = setup_sort_list(&perf_hpp_list, str, evlist);

free(str);
return ret;
@@ -2612,7 +2616,7 @@ int setup_sorting(struct perf_evlist *evlist)
return err;

if (parent_pattern != default_parent_pattern) {
- err = sort_dimension__add("parent", evlist);
+ err = sort_dimension__add(&perf_hpp_list, "parent", evlist);
if (err < 0)
return err;
}
--
2.4.3

\
 
 \ /
  Last update: 2016-01-18 11:01    [W:1.098 / U:0.580 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site