Skip to content

Commit bb236de

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf tooling fixes and updates from Arnaldo Carvalho de Melo: * Fix JIT symbol resolution on heap (Namhyung Kim) * Fix wrong SVG height in 'timechart' (Stanislav Fomichev) * Free temp cpu_map in perf_session__cpu_bitmap (Stanislav Fomichev) * Fix NULL pointer reference bug with event unit in 'stat' (Stephane Eranian) * Fix memory corruption of xyarray when cpumask is used (Stephane Eranian) * Ensure sscanf does not overrun the "mem" field (Alan Cox) * Add support for the xtensa architecture (Baruch Siach) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents 15c8102 + 578c03c commit bb236de

File tree

10 files changed

+47
-15
lines changed

10 files changed

+47
-15
lines changed

tools/perf/builtin-timechart.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,9 @@ static void write_svg_file(struct timechart *tchart, const char *filename)
10451045
thresh /= 10;
10461046
} while (!process_filter && thresh && count < tchart->proc_num);
10471047

1048+
if (!tchart->proc_num)
1049+
count = 0;
1050+
10481051
open_svg(filename, tchart->numcpus, count, tchart->first_time, tchart->last_time);
10491052

10501053
svg_time_grid();

tools/perf/perf.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@
132132
#define CPUINFO_PROC "CPU"
133133
#endif
134134

135+
#ifdef __xtensa__
136+
#define mb() asm volatile("memw" ::: "memory")
137+
#define wmb() asm volatile("memw" ::: "memory")
138+
#define rmb() asm volatile("" ::: "memory")
139+
#define CPUINFO_PROC "core ID"
140+
#endif
141+
135142
#define barrier() asm volatile ("" ::: "memory")
136143

137144
#ifndef cpu_relax

tools/perf/util/evlist.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,12 @@ void perf_evlist__close(struct perf_evlist *evlist)
10031003
struct perf_evsel *evsel;
10041004
int ncpus = cpu_map__nr(evlist->cpus);
10051005
int nthreads = thread_map__nr(evlist->threads);
1006+
int n;
10061007

1007-
evlist__for_each_reverse(evlist, evsel)
1008-
perf_evsel__close(evsel, ncpus, nthreads);
1008+
evlist__for_each_reverse(evlist, evsel) {
1009+
n = evsel->cpus ? evsel->cpus->nr : ncpus;
1010+
perf_evsel__close(evsel, n, nthreads);
1011+
}
10091012
}
10101013

10111014
int perf_evlist__open(struct perf_evlist *evlist)

tools/perf/util/evsel.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,6 @@ void perf_evsel__close(struct perf_evsel *evsel, int ncpus, int nthreads)
10811081

10821082
perf_evsel__close_fd(evsel, ncpus, nthreads);
10831083
perf_evsel__free_fd(evsel);
1084-
evsel->fd = NULL;
10851084
}
10861085

10871086
static struct {

tools/perf/util/header.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ static int write_topo_node(int fd, int node)
930930
/* skip over invalid lines */
931931
if (!strchr(buf, ':'))
932932
continue;
933-
if (sscanf(buf, "%*s %*d %s %"PRIu64, field, &mem) != 2)
933+
if (sscanf(buf, "%*s %*d %31s %"PRIu64, field, &mem) != 2)
934934
goto done;
935935
if (!strcmp(field, "MemTotal:"))
936936
mem_total = mem;

tools/perf/util/map.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
6969
map->ino = ino;
7070
map->ino_generation = ino_gen;
7171

72-
if (anon) {
72+
if ((anon || no_dso) && type == MAP__FUNCTION) {
7373
snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid);
7474
filename = newfilename;
7575
}
@@ -93,7 +93,7 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
9393
* functions still return NULL, and we avoid the
9494
* unnecessary map__load warning.
9595
*/
96-
if (no_dso)
96+
if (type != MAP__FUNCTION)
9797
dso__set_loaded(dso, map->type);
9898
}
9999
}

tools/perf/util/parse-events.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
635635
struct perf_event_attr attr;
636636
struct perf_pmu *pmu;
637637
struct perf_evsel *evsel;
638-
char *unit;
638+
const char *unit;
639639
double scale;
640640

641641
pmu = perf_pmu__find(name);

tools/perf/util/pmu.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int perf_pmu__parse_scale(struct perf_pmu_alias *alias, char *dir, char *
105105
char scale[128];
106106
int fd, ret = -1;
107107
char path[PATH_MAX];
108-
char *lc;
108+
const char *lc;
109109

110110
snprintf(path, PATH_MAX, "%s/%s.scale", dir, name);
111111

@@ -609,7 +609,7 @@ static struct perf_pmu_alias *pmu_find_alias(struct perf_pmu *pmu,
609609

610610

611611
static int check_unit_scale(struct perf_pmu_alias *alias,
612-
char **unit, double *scale)
612+
const char **unit, double *scale)
613613
{
614614
/*
615615
* Only one term in event definition can
@@ -634,14 +634,18 @@ static int check_unit_scale(struct perf_pmu_alias *alias,
634634
* defined for the alias
635635
*/
636636
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
637-
char **unit, double *scale)
637+
const char **unit, double *scale)
638638
{
639639
struct parse_events_term *term, *h;
640640
struct perf_pmu_alias *alias;
641641
int ret;
642642

643+
/*
644+
* Mark unit and scale as not set
645+
* (different from default values, see below)
646+
*/
643647
*unit = NULL;
644-
*scale = 0;
648+
*scale = 0.0;
645649

646650
list_for_each_entry_safe(term, h, head_terms, list) {
647651
alias = pmu_find_alias(pmu, term);
@@ -658,6 +662,18 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
658662
list_del(&term->list);
659663
free(term);
660664
}
665+
666+
/*
667+
* if no unit or scale foundin aliases, then
668+
* set defaults as for evsel
669+
* unit cannot left to NULL
670+
*/
671+
if (*unit == NULL)
672+
*unit = "";
673+
674+
if (*scale == 0.0)
675+
*scale = 1.0;
676+
661677
return 0;
662678
}
663679

tools/perf/util/pmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int perf_pmu__config_terms(struct list_head *formats,
2929
struct perf_event_attr *attr,
3030
struct list_head *head_terms);
3131
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
32-
char **unit, double *scale);
32+
const char **unit, double *scale);
3333
struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
3434
struct list_head *head_terms);
3535
int perf_pmu_wrap(void);

tools/perf/util/session.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
15731573
int perf_session__cpu_bitmap(struct perf_session *session,
15741574
const char *cpu_list, unsigned long *cpu_bitmap)
15751575
{
1576-
int i;
1576+
int i, err = -1;
15771577
struct cpu_map *map;
15781578

15791579
for (i = 0; i < PERF_TYPE_MAX; ++i) {
@@ -1602,13 +1602,17 @@ int perf_session__cpu_bitmap(struct perf_session *session,
16021602
if (cpu >= MAX_NR_CPUS) {
16031603
pr_err("Requested CPU %d too large. "
16041604
"Consider raising MAX_NR_CPUS\n", cpu);
1605-
return -1;
1605+
goto out_delete_map;
16061606
}
16071607

16081608
set_bit(cpu, cpu_bitmap);
16091609
}
16101610

1611-
return 0;
1611+
err = 0;
1612+
1613+
out_delete_map:
1614+
cpu_map__delete(map);
1615+
return err;
16121616
}
16131617

16141618
void perf_session__fprintf_info(struct perf_session *session, FILE *fp,

0 commit comments

Comments
 (0)