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 dso: Add dso__filename_with_chroot() to reduce number of accesses to dso->nsinfo members

We'll need to reference count dso->nsinfo, so reduce the number of
direct accesses by having a shorter form of obtaining a filename with
a chroot (namespace one).

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/lkml/ZD26ZlqSbgSyH5lX@kernel.org
[ Used nsinfo__pid(dso->nsinfo), as it was already present ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+12 -10
+1 -3
tools/perf/builtin-inject.c
··· 630 630 if (filename__read_build_id(dso->long_name, &dso->bid) > 0) 631 631 dso->has_build_id = true; 632 632 else if (dso->nsinfo) { 633 - char *new_name; 633 + char *new_name = dso__filename_with_chroot(dso, dso->long_name); 634 634 635 - new_name = filename_with_chroot(dso->nsinfo->pid, 636 - dso->long_name); 637 635 if (new_name && filename__read_build_id(new_name, &dso->bid) > 0) 638 636 dso->has_build_id = true; 639 637 free(new_name);
+1 -2
tools/perf/util/annotate.c
··· 1692 1692 1693 1693 mutex_lock(&dso->lock); 1694 1694 if (access(filename, R_OK) && errno == ENOENT && dso->nsinfo) { 1695 - char *new_name = filename_with_chroot(dso->nsinfo->pid, 1696 - filename); 1695 + char *new_name = dso__filename_with_chroot(dso, filename); 1697 1696 if (new_name) { 1698 1697 strlcpy(filename, new_name, filename_size); 1699 1698 free(new_name);
+6 -1
tools/perf/util/dso.c
··· 491 491 return -1; 492 492 } 493 493 494 + char *dso__filename_with_chroot(const struct dso *dso, const char *filename) 495 + { 496 + return filename_with_chroot(nsinfo__pid(dso->nsinfo), filename); 497 + } 498 + 494 499 static int __open_dso(struct dso *dso, struct machine *machine) 495 500 { 496 501 int fd = -EINVAL; ··· 520 515 if (errno != ENOENT || dso->nsinfo == NULL) 521 516 goto out; 522 517 523 - new_name = filename_with_chroot(dso->nsinfo->pid, name); 518 + new_name = dso__filename_with_chroot(dso, name); 524 519 if (!new_name) 525 520 goto out; 526 521
+2
tools/perf/util/dso.h
··· 266 266 return !RB_EMPTY_ROOT(&dso->symbols.rb_root); 267 267 } 268 268 269 + char *dso__filename_with_chroot(const struct dso *dso, const char *filename); 270 + 269 271 bool dso__sorted_by_name(const struct dso *dso); 270 272 void dso__set_sorted_by_name(struct dso *dso); 271 273 void dso__sort_by_name(struct dso *dso);
+1 -2
tools/perf/util/dsos.c
··· 91 91 have_build_id = true; 92 92 pos->has_build_id = true; 93 93 } else if (errno == ENOENT && pos->nsinfo) { 94 - char *new_name = filename_with_chroot(pos->nsinfo->pid, 95 - pos->long_name); 94 + char *new_name = dso__filename_with_chroot(pos, pos->long_name); 96 95 97 96 if (new_name && filename__read_build_id(new_name, 98 97 &pos->bid) > 0) {
+1 -2
tools/perf/util/symbol.c
··· 1963 1963 1964 1964 is_reg = is_regular_file(name); 1965 1965 if (!is_reg && errno == ENOENT && dso->nsinfo) { 1966 - char *new_name = filename_with_chroot(dso->nsinfo->pid, 1967 - name); 1966 + char *new_name = dso__filename_with_chroot(dso, name); 1968 1967 if (new_name) { 1969 1968 is_reg = is_regular_file(new_name); 1970 1969 strlcpy(name, new_name, PATH_MAX);