]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - tools/perf/util/sort.c
perf tools: Bail out at "--sort dcacheline" and cacheline_size not known
[mirror_ubuntu-jammy-kernel.git] / tools / perf / util / sort.c
index a764139af485f2f745e763cec5d30b47e76a4c95..947d21f3839838c433430b01fe52165522f87295 100644 (file)
@@ -2069,7 +2069,7 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
        }
 
        full_name = !!strchr(event_name, ':');
-       evlist__for_each(evlist, pos) {
+       evlist__for_each_entry(evlist, pos) {
                /* case 2 */
                if (full_name && !strcmp(pos->name, event_name))
                        return pos;
@@ -2125,7 +2125,7 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace,
        int ret;
        struct perf_evsel *evsel;
 
-       evlist__for_each(evlist, evsel) {
+       evlist__for_each_entry(evlist, evsel) {
                if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
                        continue;
 
@@ -2143,7 +2143,7 @@ static int add_all_matching_fields(struct perf_evlist *evlist,
        struct perf_evsel *evsel;
        struct format_field *field;
 
-       evlist__for_each(evlist, evsel) {
+       evlist__for_each_entry(evlist, evsel) {
                if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
                        continue;
 
@@ -2381,6 +2381,9 @@ static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
                if (sort__mode != SORT_MODE__MEMORY)
                        return -EINVAL;
 
+               if (sd->entry == &sort_mem_dcacheline && cacheline_size == 0)
+                       return -EINVAL;
+
                if (sd->entry == &sort_mem_daddr_sym)
                        list->sym = 1;
 
@@ -2424,7 +2427,10 @@ static int setup_sort_list(struct perf_hpp_list *list, char *str,
                if (*tok) {
                        ret = sort_dimension__add(list, tok, evlist, level);
                        if (ret == -EINVAL) {
-                               error("Invalid --sort key: `%s'", tok);
+                               if (!cacheline_size && !strncasecmp(tok, "dcacheline", strlen(tok)))
+                                       error("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system");
+                               else
+                                       error("Invalid --sort key: `%s'", tok);
                                break;
                        } else if (ret == -ESRCH) {
                                error("Unknown --sort key: `%s'", tok);
@@ -2456,7 +2462,7 @@ static const char *get_default_sort_order(struct perf_evlist *evlist)
        if (evlist == NULL)
                goto out_no_evlist;
 
-       evlist__for_each(evlist, evsel) {
+       evlist__for_each_entry(evlist, evsel) {
                if (evsel->attr.type != PERF_TYPE_TRACEPOINT) {
                        use_trace = false;
                        break;