Skip to content

Commit cfaa154

Browse files
namhyungolsajiri
authored andcommitted
perf tools: Get rid of obsolete hist_entry__sort_list
Now we moved to the perf_hpp_[_sort]_list so no need to keep the old hist_entry__sort_list and sort__first_dimension. Also the hist_entry__sort_snprintf() can be gone as hist_entry__snprintf() provides the functionality. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1400480762-22852-18-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa <jolsa@kernel.org>
1 parent 678a500 commit cfaa154

3 files changed

Lines changed: 43 additions & 50 deletions

File tree

‎tools/perf/ui/hist.c‎

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -459,47 +459,29 @@ void perf_hpp__append_sort_keys(void)
459459
}
460460
}
461461

462-
int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size,
463-
struct hists *hists)
464-
{
465-
const char *sep = symbol_conf.field_sep;
466-
struct sort_entry *se;
467-
int ret = 0;
468-
469-
list_for_each_entry(se, &hist_entry__sort_list, list) {
470-
if (se->elide)
471-
continue;
472-
473-
ret += scnprintf(s + ret, size - ret, "%s", sep ?: " ");
474-
ret += se->se_snprintf(he, s + ret, size - ret,
475-
hists__col_len(hists, se->se_width_idx));
476-
}
477-
478-
return ret;
479-
}
480-
481462
/*
482463
* See hists__fprintf to match the column widths
483464
*/
484465
unsigned int hists__sort_list_width(struct hists *hists)
485466
{
486467
struct perf_hpp_fmt *fmt;
487-
struct sort_entry *se;
488-
int i = 0, ret = 0;
468+
int ret = 0;
469+
bool first = true;
489470
struct perf_hpp dummy_hpp;
490471

491472
perf_hpp__for_each_format(fmt) {
492-
if (i)
473+
if (perf_hpp__should_skip(fmt))
474+
continue;
475+
476+
if (first)
477+
first = false;
478+
else
493479
ret += 2;
494480

495481
ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists));
496482
}
497483

498-
list_for_each_entry(se, &hist_entry__sort_list, list)
499-
if (!se->elide)
500-
ret += 2 + hists__col_len(hists, se->se_width_idx);
501-
502-
if (verbose) /* Addr + origin */
484+
if (verbose && sort__has_sym) /* Addr + origin */
503485
ret += 3 + BITS_PER_LONG / 4;
504486

505487
return ret;

‎tools/perf/ui/stdio/hist.c‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
183183
* the symbol. No need to print it otherwise it appears as
184184
* displayed twice.
185185
*/
186-
if (!i++ && sort__first_dimension == SORT_SYM)
186+
if (!i++ && field_order == NULL &&
187+
sort_order && !prefixcmp(sort_order, "sym"))
187188
continue;
188189
if (!printed) {
189190
ret += callchain__fprintf_left_margin(fp, left_margin);
@@ -296,13 +297,20 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
296297
int left_margin = 0;
297298
u64 total_period = hists->stats.total_period;
298299

299-
if (sort__first_dimension == SORT_COMM) {
300-
struct sort_entry *se = list_first_entry(&hist_entry__sort_list,
301-
typeof(*se), list);
302-
left_margin = hists__col_len(hists, se->se_width_idx);
303-
left_margin -= thread__comm_len(he->thread);
304-
}
300+
if (field_order == NULL && (sort_order == NULL ||
301+
!prefixcmp(sort_order, "comm"))) {
302+
struct perf_hpp_fmt *fmt;
303+
304+
perf_hpp__for_each_format(fmt) {
305+
if (!perf_hpp__is_sort_entry(fmt))
306+
continue;
305307

308+
/* must be 'comm' sort entry */
309+
left_margin = fmt->width(fmt, NULL, hists_to_evsel(hists));
310+
left_margin -= thread__comm_len(he->thread);
311+
break;
312+
}
313+
}
306314
return hist_entry_callchain__fprintf(he, total_period, left_margin, fp);
307315
}
308316

‎tools/perf/util/sort.c‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ int sort__has_sym = 0;
2222
int sort__has_dso = 0;
2323
enum sort_mode sort__mode = SORT_MODE__NORMAL;
2424

25-
enum sort_type sort__first_dimension;
26-
27-
LIST_HEAD(hist_entry__sort_list);
2825

2926
static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...)
3027
{
@@ -1190,7 +1187,7 @@ static int __sort_dimension__add_hpp_output(struct sort_dimension *sd)
11901187
return 0;
11911188
}
11921189

1193-
static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
1190+
static int __sort_dimension__add(struct sort_dimension *sd)
11941191
{
11951192
if (sd->taken)
11961193
return 0;
@@ -1201,10 +1198,6 @@ static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
12011198
if (sd->entry->se_collapse)
12021199
sort__need_collapse = 1;
12031200

1204-
if (list_empty(&hist_entry__sort_list))
1205-
sort__first_dimension = idx;
1206-
1207-
list_add_tail(&sd->entry->list, &hist_entry__sort_list);
12081201
sd->taken = 1;
12091202

12101203
return 0;
@@ -1268,7 +1261,7 @@ int sort_dimension__add(const char *tok)
12681261
sort__has_dso = 1;
12691262
}
12701263

1271-
return __sort_dimension__add(sd, i);
1264+
return __sort_dimension__add(sd);
12721265
}
12731266

12741267
for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
@@ -1292,7 +1285,7 @@ int sort_dimension__add(const char *tok)
12921285
if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
12931286
sort__has_sym = 1;
12941287

1295-
__sort_dimension__add(sd, i + __SORT_BRANCH_STACK);
1288+
__sort_dimension__add(sd);
12961289
return 0;
12971290
}
12981291

@@ -1308,7 +1301,7 @@ int sort_dimension__add(const char *tok)
13081301
if (sd->entry == &sort_mem_daddr_sym)
13091302
sort__has_sym = 1;
13101303

1311-
__sort_dimension__add(sd, i + __SORT_MEMORY_MODE);
1304+
__sort_dimension__add(sd);
13121305
return 0;
13131306
}
13141307

@@ -1395,7 +1388,8 @@ static void sort_entry__setup_elide(struct sort_entry *se,
13951388

13961389
void sort__setup_elide(FILE *output)
13971390
{
1398-
struct sort_entry *se;
1391+
struct perf_hpp_fmt *fmt;
1392+
struct hpp_sort_entry *hse;
13991393

14001394
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
14011395
"dso", output);
@@ -1436,13 +1430,22 @@ void sort__setup_elide(FILE *output)
14361430
* It makes no sense to elide all of sort entries.
14371431
* Just revert them to show up again.
14381432
*/
1439-
list_for_each_entry(se, &hist_entry__sort_list, list) {
1440-
if (!se->elide)
1433+
perf_hpp__for_each_format(fmt) {
1434+
if (!perf_hpp__is_sort_entry(fmt))
1435+
continue;
1436+
1437+
hse = container_of(fmt, struct hpp_sort_entry, hpp);
1438+
if (!hse->se->elide)
14411439
return;
14421440
}
14431441

1444-
list_for_each_entry(se, &hist_entry__sort_list, list)
1445-
se->elide = false;
1442+
perf_hpp__for_each_format(fmt) {
1443+
if (!perf_hpp__is_sort_entry(fmt))
1444+
continue;
1445+
1446+
hse = container_of(fmt, struct hpp_sort_entry, hpp);
1447+
hse->se->elide = false;
1448+
}
14461449
}
14471450

14481451
static int output_field_add(char *tok)

0 commit comments

Comments
 (0)