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 annotate: Get rid of offsets array

The struct annotated_source.offsets[] is to save pointers to
annotation_line at each offset. We can use annotated_source__get_line()
helper instead so let's get rid of the array.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240404175716.1225482-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
cee9b860 0c053ed2

+7 -29
+1 -4
tools/perf/ui/browsers/annotate.c
··· 977 977 dso->annotate_warned = true; 978 978 symbol__strerror_disassemble(ms, err, msg, sizeof(msg)); 979 979 ui__error("Couldn't annotate %s:\n%s", sym->name, msg); 980 - goto out_free_offsets; 980 + return -1; 981 981 } 982 982 } 983 983 ··· 996 996 if(not_annotated) 997 997 annotated_source__purge(notes->src); 998 998 999 - out_free_offsets: 1000 - if(not_annotated) 1001 - zfree(&notes->src->offsets); 1002 999 return ret; 1003 1000 }
+6 -23
tools/perf/util/annotate.c
··· 1378 1378 } 1379 1379 } 1380 1380 1381 - static void annotation__set_offsets(struct annotation *notes, s64 size) 1381 + static void annotation__set_index(struct annotation *notes) 1382 1382 { 1383 1383 struct annotation_line *al; 1384 1384 struct annotated_source *src = notes->src; ··· 1393 1393 if (src->max_line_len < line_len) 1394 1394 src->max_line_len = line_len; 1395 1395 al->idx = src->nr_entries++; 1396 - if (al->offset != -1) { 1396 + if (al->offset != -1) 1397 1397 al->idx_asm = src->nr_asm_entries++; 1398 - /* 1399 - * FIXME: short term bandaid to cope with assembly 1400 - * routines that comes with labels in the same column 1401 - * as the address in objdump, sigh. 1402 - * 1403 - * E.g. copy_user_generic_unrolled 1404 - */ 1405 - if (al->offset < size) 1406 - notes->src->offsets[al->offset] = al; 1407 - } else 1398 + else 1408 1399 al->idx_asm = -1; 1409 1400 } 1410 1401 } ··· 1826 1835 size_t size = symbol__size(sym); 1827 1836 int nr_pcnt = 1, err; 1828 1837 1829 - notes->src->offsets = zalloc(size * sizeof(struct annotation_line *)); 1830 - if (notes->src->offsets == NULL) 1831 - return ENOMEM; 1832 - 1833 1838 if (evsel__is_group_event(evsel)) 1834 1839 nr_pcnt = evsel->core.nr_members; 1835 1840 1836 1841 err = symbol__annotate(ms, evsel, parch); 1837 1842 if (err) 1838 - goto out_free_offsets; 1843 + return err; 1839 1844 1840 1845 symbol__calc_percent(sym, evsel); 1841 1846 1842 - annotation__set_offsets(notes, size); 1847 + annotation__set_index(notes); 1843 1848 annotation__mark_jump_targets(notes, sym); 1844 1849 1845 1850 err = annotation__compute_ipc(notes, size); 1846 1851 if (err) 1847 - goto out_free_offsets; 1852 + return err; 1848 1853 1849 1854 annotation__init_column_widths(notes, sym); 1850 1855 notes->nr_events = nr_pcnt; ··· 1849 1862 sym->annotate2 = 1; 1850 1863 1851 1864 return 0; 1852 - 1853 - out_free_offsets: 1854 - zfree(&notes->src->offsets); 1855 - return err; 1856 1865 } 1857 1866 1858 1867 static int annotation__config(const char *var, const char *value, void *data)
-2
tools/perf/util/annotate.h
··· 246 246 * we have more than a group in a evlist, where we will want 247 247 * to see each group separately, that is why symbol__annotate2() 248 248 * sets src->nr_histograms to evsel->nr_members. 249 - * @offsets: Array of annotation_line to be accessed by offset. 250 249 * @samples: Hash map of sym_hist_entry. Keyed by event index and offset in symbol. 251 250 * @nr_entries: Number of annotated_line in the source list. 252 251 * @nr_asm_entries: Number of annotated_line with actual asm instruction in the ··· 261 262 struct annotated_source { 262 263 struct list_head source; 263 264 struct sym_hist *histograms; 264 - struct annotation_line **offsets; 265 265 struct hashmap *samples; 266 266 int nr_histograms; 267 267 int nr_entries;