@@ -209,29 +209,26 @@ static int __hpp__sort_acc(struct hist_entry *a, struct hist_entry *b,
209209 return ret ;
210210}
211211
212- #define __HPP_WIDTH_FN (_type , _str ) \
213- static int hpp__width_##_type(struct perf_hpp_fmt *fmt, \
214- struct perf_hpp *hpp __maybe_unused, \
215- struct perf_evsel *evsel) \
216- { \
217- int len = fmt->user_len ?: fmt->len; \
218- \
219- if (symbol_conf.event_group) \
220- len = max(len, evsel->nr_members * fmt->len); \
221- \
222- if (len < (int)strlen(_str)) \
223- len = strlen(_str); \
224- \
225- return len; \
226- }
227-
228- #define __HPP_HEADER_FN (_type , _str ) \
229- static int hpp__header_##_type(struct perf_hpp_fmt *fmt, \
230- struct perf_hpp *hpp, \
231- struct perf_evsel *evsel) \
232- { \
233- int len = hpp__width_##_type(fmt, hpp, evsel); \
234- return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \
212+ static int hpp__width_fn (struct perf_hpp_fmt * fmt ,
213+ struct perf_hpp * hpp __maybe_unused ,
214+ struct perf_evsel * evsel )
215+ {
216+ int len = fmt -> user_len ?: fmt -> len ;
217+
218+ if (symbol_conf .event_group )
219+ len = max (len , evsel -> nr_members * fmt -> len );
220+
221+ if (len < (int )strlen (fmt -> name ))
222+ len = strlen (fmt -> name );
223+
224+ return len ;
225+ }
226+
227+ static int hpp__header_fn (struct perf_hpp_fmt * fmt , struct perf_hpp * hpp ,
228+ struct perf_evsel * evsel )
229+ {
230+ int len = hpp__width_fn (fmt , hpp , evsel );
231+ return scnprintf (hpp -> buf , hpp -> size , "%*s" , len , fmt -> name );
235232}
236233
237234static int hpp_color_scnprintf (struct perf_hpp * hpp , const char * fmt , ...)
@@ -337,86 +334,80 @@ static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b) \
337334}
338335
339336
340- #define HPP_PERCENT_FNS (_type , _str , _field ) \
341- __HPP_WIDTH_FN(_type, _str) \
342- __HPP_HEADER_FN(_type, _str) \
337+ #define HPP_PERCENT_FNS (_type , _field ) \
343338__HPP_COLOR_PERCENT_FN(_type, _field) \
344339__HPP_ENTRY_PERCENT_FN(_type, _field) \
345340__HPP_SORT_FN(_type, _field)
346341
347- #define HPP_PERCENT_ACC_FNS (_type , _str , _field ) \
348- __HPP_WIDTH_FN(_type, _str) \
349- __HPP_HEADER_FN(_type, _str) \
342+ #define HPP_PERCENT_ACC_FNS (_type , _field ) \
350343__HPP_COLOR_ACC_PERCENT_FN(_type, _field) \
351344__HPP_ENTRY_ACC_PERCENT_FN(_type, _field) \
352345__HPP_SORT_ACC_FN(_type, _field)
353346
354- #define HPP_RAW_FNS (_type , _str , _field ) \
355- __HPP_WIDTH_FN(_type, _str) \
356- __HPP_HEADER_FN(_type, _str) \
347+ #define HPP_RAW_FNS (_type , _field ) \
357348__HPP_ENTRY_RAW_FN(_type, _field) \
358349__HPP_SORT_RAW_FN(_type, _field)
359350
360- __HPP_WIDTH_FN (overhead_self , "Self" )
361- __HPP_HEADER_FN (overhead_self , "Self" )
351+ HPP_PERCENT_FNS (overhead , period )
352+ HPP_PERCENT_FNS (overhead_sys , period_sys )
353+ HPP_PERCENT_FNS (overhead_us , period_us )
354+ HPP_PERCENT_FNS (overhead_guest_sys , period_guest_sys )
355+ HPP_PERCENT_FNS (overhead_guest_us , period_guest_us )
356+ HPP_PERCENT_ACC_FNS (overhead_acc , period )
362357
363- HPP_PERCENT_FNS (overhead , "Overhead" , period )
364- HPP_PERCENT_FNS (overhead_sys , "sys" , period_sys )
365- HPP_PERCENT_FNS (overhead_us , "usr" , period_us )
366- HPP_PERCENT_FNS (overhead_guest_sys , "guest sys" , period_guest_sys )
367- HPP_PERCENT_FNS (overhead_guest_us , "guest usr" , period_guest_us )
368- HPP_PERCENT_ACC_FNS (overhead_acc , "Children" , period )
369-
370- HPP_RAW_FNS (samples , "Samples" , nr_events )
371- HPP_RAW_FNS (period , "Period" , period )
358+ HPP_RAW_FNS (samples , nr_events )
359+ HPP_RAW_FNS (period , period )
372360
373361static int64_t hpp__nop_cmp (struct hist_entry * a __maybe_unused ,
374362 struct hist_entry * b __maybe_unused )
375363{
376364 return 0 ;
377365}
378366
379- #define HPP__COLOR_PRINT_FNS (_name ) \
367+ #define HPP__COLOR_PRINT_FNS (_name , _fn ) \
380368 { \
381- .header = hpp__header_ ## _name, \
382- .width = hpp__width_ ## _name, \
383- .color = hpp__color_ ## _name, \
384- .entry = hpp__entry_ ## _name, \
369+ .name = _name, \
370+ .header = hpp__header_fn, \
371+ .width = hpp__width_fn, \
372+ .color = hpp__color_ ## _fn, \
373+ .entry = hpp__entry_ ## _fn, \
385374 .cmp = hpp__nop_cmp, \
386375 .collapse = hpp__nop_cmp, \
387- .sort = hpp__sort_ ## _name , \
376+ .sort = hpp__sort_ ## _fn , \
388377 }
389378
390- #define HPP__COLOR_ACC_PRINT_FNS (_name ) \
379+ #define HPP__COLOR_ACC_PRINT_FNS (_name , _fn ) \
391380 { \
392- .header = hpp__header_ ## _name, \
393- .width = hpp__width_ ## _name, \
394- .color = hpp__color_ ## _name, \
395- .entry = hpp__entry_ ## _name, \
381+ .name = _name, \
382+ .header = hpp__header_fn, \
383+ .width = hpp__width_fn, \
384+ .color = hpp__color_ ## _fn, \
385+ .entry = hpp__entry_ ## _fn, \
396386 .cmp = hpp__nop_cmp, \
397387 .collapse = hpp__nop_cmp, \
398- .sort = hpp__sort_ ## _name , \
388+ .sort = hpp__sort_ ## _fn , \
399389 }
400390
401- #define HPP__PRINT_FNS (_name ) \
391+ #define HPP__PRINT_FNS (_name , _fn ) \
402392 { \
403- .header = hpp__header_ ## _name, \
404- .width = hpp__width_ ## _name, \
405- .entry = hpp__entry_ ## _name, \
393+ .name = _name, \
394+ .header = hpp__header_fn, \
395+ .width = hpp__width_fn, \
396+ .entry = hpp__entry_ ## _fn, \
406397 .cmp = hpp__nop_cmp, \
407398 .collapse = hpp__nop_cmp, \
408- .sort = hpp__sort_ ## _name , \
399+ .sort = hpp__sort_ ## _fn , \
409400 }
410401
411402struct perf_hpp_fmt perf_hpp__format [] = {
412- HPP__COLOR_PRINT_FNS (overhead ),
413- HPP__COLOR_PRINT_FNS (overhead_sys ),
414- HPP__COLOR_PRINT_FNS (overhead_us ),
415- HPP__COLOR_PRINT_FNS (overhead_guest_sys ),
416- HPP__COLOR_PRINT_FNS (overhead_guest_us ),
417- HPP__COLOR_ACC_PRINT_FNS (overhead_acc ),
418- HPP__PRINT_FNS (samples ),
419- HPP__PRINT_FNS (period )
403+ HPP__COLOR_PRINT_FNS ("Overhead" , overhead ),
404+ HPP__COLOR_PRINT_FNS ("sys" , overhead_sys ),
405+ HPP__COLOR_PRINT_FNS ("usr" , overhead_us ),
406+ HPP__COLOR_PRINT_FNS ("guest sys" , overhead_guest_sys ),
407+ HPP__COLOR_PRINT_FNS ("guest usr" , overhead_guest_us ),
408+ HPP__COLOR_ACC_PRINT_FNS ("Children" , overhead_acc ),
409+ HPP__PRINT_FNS ("Samples" , samples ),
410+ HPP__PRINT_FNS ("Period" , period )
420411};
421412
422413LIST_HEAD (perf_hpp__list );
@@ -466,11 +457,7 @@ void perf_hpp__init(void)
466457
467458 if (symbol_conf .cumulate_callchain ) {
468459 perf_hpp__column_enable (PERF_HPP__OVERHEAD_ACC );
469-
470- perf_hpp__format [PERF_HPP__OVERHEAD ].header =
471- hpp__header_overhead_self ;
472- perf_hpp__format [PERF_HPP__OVERHEAD ].width =
473- hpp__width_overhead_self ;
460+ perf_hpp__format [PERF_HPP__OVERHEAD ].name = "Self" ;
474461 }
475462
476463 perf_hpp__column_enable (PERF_HPP__OVERHEAD );
@@ -536,8 +523,7 @@ void perf_hpp__cancel_cumulate(void)
536523 return ;
537524
538525 perf_hpp__column_disable (PERF_HPP__OVERHEAD_ACC );
539- perf_hpp__format [PERF_HPP__OVERHEAD ].header = hpp__header_overhead ;
540- perf_hpp__format [PERF_HPP__OVERHEAD ].width = hpp__width_overhead ;
526+ perf_hpp__format [PERF_HPP__OVERHEAD ].name = "Overhead" ;
541527}
542528
543529void perf_hpp__setup_output_field (void )
0 commit comments