Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf tools: Parse aux-action

Add parsing for aux-action to accept "pause", "resume" or "start-paused"
values.

"start-paused" is valid only for AUX area events.

"pause" and "resume" are valid only for events grouped with an AUX area
event as the group leader. However, like with aux-output, the events
will be automatically grouped if they are not currently in a group, and
the AUX area event precedes the other events.

Reviewed-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20241216070244.14450-4-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
8a0f49a7 314bf84e

+74 -8
+4
tools/perf/Documentation/perf-record.txt
··· 68 68 like this: name=\'CPU_CLK_UNHALTED.THREAD:cmask=0x1\'. 69 69 - 'aux-output': Generate AUX records instead of events. This requires 70 70 that an AUX area event is also provided. 71 + - 'aux-action': "pause" or "resume" to pause or resume an AUX 72 + area event (the group leader) when this event occurs. 73 + "start-paused" on an AUX area event itself, will 74 + start in a paused state. 71 75 - 'aux-sample-size': Set sample size for AUX area sampling. If the 72 76 '--aux-sample' option has been used, set aux-sample-size=0 to disable 73 77 AUX area sampling for the event.
+3 -1
tools/perf/builtin-record.c
··· 860 860 if (err) 861 861 return err; 862 862 863 - auxtrace_regroup_aux_output(rec->evlist); 863 + err = auxtrace_parse_aux_action(rec->evlist); 864 + if (err) 865 + return err; 864 866 865 867 return auxtrace_parse_filters(rec->evlist); 866 868 }
+62 -5
tools/perf/util/auxtrace.c
··· 810 810 return auxtrace_validate_aux_sample_size(evlist, opts); 811 811 } 812 812 813 - void auxtrace_regroup_aux_output(struct evlist *evlist) 813 + static struct aux_action_opt { 814 + const char *str; 815 + u32 aux_action; 816 + bool aux_event_opt; 817 + } aux_action_opts[] = { 818 + {"start-paused", BIT(0), true}, 819 + {"pause", BIT(1), false}, 820 + {"resume", BIT(2), false}, 821 + {.str = NULL}, 822 + }; 823 + 824 + static const struct aux_action_opt *auxtrace_parse_aux_action_str(const char *str) 814 825 { 815 - struct evsel *evsel, *aux_evsel = NULL; 826 + const struct aux_action_opt *opt; 827 + 828 + if (!str) 829 + return NULL; 830 + 831 + for (opt = aux_action_opts; opt->str; opt++) 832 + if (!strcmp(str, opt->str)) 833 + return opt; 834 + 835 + return NULL; 836 + } 837 + 838 + int auxtrace_parse_aux_action(struct evlist *evlist) 839 + { 816 840 struct evsel_config_term *term; 841 + struct evsel *aux_evsel = NULL; 842 + struct evsel *evsel; 817 843 818 844 evlist__for_each_entry(evlist, evsel) { 819 - if (evsel__is_aux_event(evsel)) 845 + bool is_aux_event = evsel__is_aux_event(evsel); 846 + const struct aux_action_opt *opt; 847 + 848 + if (is_aux_event) 820 849 aux_evsel = evsel; 821 - term = evsel__get_config_term(evsel, AUX_OUTPUT); 850 + term = evsel__get_config_term(evsel, AUX_ACTION); 851 + if (!term) { 852 + if (evsel__get_config_term(evsel, AUX_OUTPUT)) 853 + goto regroup; 854 + continue; 855 + } 856 + opt = auxtrace_parse_aux_action_str(term->val.str); 857 + if (!opt) { 858 + pr_err("Bad aux-action '%s'\n", term->val.str); 859 + return -EINVAL; 860 + } 861 + if (opt->aux_event_opt && !is_aux_event) { 862 + pr_err("aux-action '%s' can only be used with AUX area event\n", 863 + term->val.str); 864 + return -EINVAL; 865 + } 866 + if (!opt->aux_event_opt && is_aux_event) { 867 + pr_err("aux-action '%s' cannot be used for AUX area event itself\n", 868 + term->val.str); 869 + return -EINVAL; 870 + } 871 + evsel->core.attr.aux_action = opt->aux_action; 872 + regroup: 822 873 /* If possible, group with the AUX event */ 823 - if (term && aux_evsel) 874 + if (aux_evsel) 824 875 evlist__regroup(evlist, aux_evsel, evsel); 876 + if (!evsel__is_aux_event(evsel__leader(evsel))) { 877 + pr_err("Events with aux-action must have AUX area event group leader\n"); 878 + return -EINVAL; 879 + } 825 880 } 881 + 882 + return 0; 826 883 } 827 884 828 885 struct auxtrace_record *__weak
+4 -2
tools/perf/util/auxtrace.h
··· 578 578 int auxtrace_parse_sample_options(struct auxtrace_record *itr, 579 579 struct evlist *evlist, 580 580 struct record_opts *opts, const char *str); 581 - void auxtrace_regroup_aux_output(struct evlist *evlist); 581 + int auxtrace_parse_aux_action(struct evlist *evlist); 582 582 int auxtrace_record__options(struct auxtrace_record *itr, 583 583 struct evlist *evlist, 584 584 struct record_opts *opts); ··· 799 799 } 800 800 801 801 static inline 802 - void auxtrace_regroup_aux_output(struct evlist *evlist __maybe_unused) 802 + int auxtrace_parse_aux_action(struct evlist *evlist __maybe_unused) 803 803 { 804 + pr_err("AUX area tracing not supported\n"); 805 + return -EINVAL; 804 806 } 805 807 806 808 static inline
+1
tools/perf/util/evsel.c
··· 1152 1152 attr->aux_output = term->val.aux_output ? 1 : 0; 1153 1153 break; 1154 1154 case EVSEL__CONFIG_TERM_AUX_ACTION: 1155 + /* Already applied by auxtrace */ 1155 1156 break; 1156 1157 case EVSEL__CONFIG_TERM_AUX_SAMPLE_SIZE: 1157 1158 /* Already applied by auxtrace */