Skip to content

Commit d4652f6

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-urgent-for-mingo-4.17-20180425' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo: perf stat: - Keep the '/' event modifier separator in fallback, for example when fallbacking from 'cpu/cpu-cycles/' to user level only, where it should become 'cpu/cpu-cycles/u' and not 'cpu/cpu-cycles/:u' (Jiri Olsa) - Fix PMU events parsing rule, improving error reporting for invalid events (Jiri Olsa) - Disable write_backward and other event attributes for !group events in a group, fixing, for instance this group: '{cycles,msr/aperf/}:S' that has leader sampling (:S) and where just the 'cycles', the leader event, should have the write_backward attribute set, in this case it all fails because the PMU where 'msr/aperf/' lives doesn't accepts write_backward style sampling (Jiri Olsa) - Only fall back group read for leader (Kan Liang) - Fix core PMU alias list for x86 platform (Kan Liang) - Print out hint for mixed PMU group error (Kan Liang) - Fix duplicate PMU name for interval print (Kan Liang) Core: - Set main kernel end address properly when reading kernel and module maps (Namhyung Kim) perf mem: - Fix incorrect entries and add missing man options (Sangwon Hong) s/390: - Remove s390 specific strcmp_cpuid_cmp function (Thomas Richter) - Adapt 'perf test' case record+probe_libc_inet_pton.sh for s390 - Fix s390 undefined record__auxtrace_init() return value in 'perf record' (Thomas Richter) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 4e949e9 + 80ee8c5 commit d4652f6

File tree

12 files changed

+123
-75
lines changed

12 files changed

+123
-75
lines changed

tools/perf/Documentation/perf-mem.txt

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,46 @@ OPTIONS
2828
<command>...::
2929
Any command you can specify in a shell.
3030

31+
-i::
32+
--input=<file>::
33+
Input file name.
34+
3135
-f::
3236
--force::
3337
Don't do ownership validation
3438

3539
-t::
36-
--type=::
40+
--type=<type>::
3741
Select the memory operation type: load or store (default: load,store)
3842

3943
-D::
40-
--dump-raw-samples=::
44+
--dump-raw-samples::
4145
Dump the raw decoded samples on the screen in a format that is easy to parse with
4246
one sample per line.
4347

4448
-x::
45-
--field-separator::
49+
--field-separator=<separator>::
4650
Specify the field separator used when dump raw samples (-D option). By default,
4751
The separator is the space character.
4852

4953
-C::
50-
--cpu-list::
51-
Restrict dump of raw samples to those provided via this option. Note that the same
52-
option can be passed in record mode. It will be interpreted the same way as perf
53-
record.
54+
--cpu=<cpu>::
55+
Monitor only on the list of CPUs provided. Multiple CPUs can be provided as a
56+
comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. Default
57+
is to monitor all CPUS.
58+
-U::
59+
--hide-unresolved::
60+
Only display entries resolved to a symbol.
61+
62+
-p::
63+
--phys-data::
64+
Record/Report sample physical addresses
65+
66+
RECORD OPTIONS
67+
--------------
68+
-e::
69+
--event <event>::
70+
Event selector. Use 'perf mem record -e list' to list available events.
5471

5572
-K::
5673
--all-kernel::
@@ -60,12 +77,12 @@ OPTIONS
6077
--all-user::
6178
Configure all used events to run in user space.
6279

63-
--ldload::
64-
Specify desired latency for loads event.
80+
-v::
81+
--verbose::
82+
Be more verbose (show counter open errors, etc)
6583

66-
-p::
67-
--phys-data::
68-
Record/Report sample physical addresses
84+
--ldlat <n>::
85+
Specify desired latency for loads event.
6986

7087
In addition, for report all perf report options are valid, and for record
7188
all perf record options.

tools/perf/arch/s390/util/auxtrace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct auxtrace_record *auxtrace_record__init(struct perf_evlist *evlist,
8787
struct perf_evsel *pos;
8888
int diagnose = 0;
8989

90+
*err = 0;
9091
if (evlist->nr_entries == 0)
9192
return NULL;
9293

tools/perf/arch/s390/util/header.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,3 @@ char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
146146
zfree(&buf);
147147
return buf;
148148
}
149-
150-
/*
151-
* Compare the cpuid string returned by get_cpuid() function
152-
* with the name generated by the jevents file read from
153-
* pmu-events/arch/s390/mapfile.csv.
154-
*
155-
* Parameter mapcpuid is the cpuid as stored in the
156-
* pmu-events/arch/s390/mapfile.csv. This is just the type number.
157-
* Parameter cpuid is the cpuid returned by function get_cpuid().
158-
*/
159-
int strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
160-
{
161-
char *cp = strchr(cpuid, ',');
162-
163-
if (cp == NULL)
164-
return -1;
165-
return strncmp(cp + 1, mapcpuid, strlen(mapcpuid));
166-
}

tools/perf/builtin-stat.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ static bool interval_count;
172172
static const char *output_name;
173173
static int output_fd;
174174
static int print_free_counters_hint;
175+
static int print_mixed_hw_group_error;
175176

176177
struct perf_stat {
177178
bool record;
@@ -1126,6 +1127,30 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
11261127
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
11271128
}
11281129

1130+
static bool is_mixed_hw_group(struct perf_evsel *counter)
1131+
{
1132+
struct perf_evlist *evlist = counter->evlist;
1133+
u32 pmu_type = counter->attr.type;
1134+
struct perf_evsel *pos;
1135+
1136+
if (counter->nr_members < 2)
1137+
return false;
1138+
1139+
evlist__for_each_entry(evlist, pos) {
1140+
/* software events can be part of any hardware group */
1141+
if (pos->attr.type == PERF_TYPE_SOFTWARE)
1142+
continue;
1143+
if (pmu_type == PERF_TYPE_SOFTWARE) {
1144+
pmu_type = pos->attr.type;
1145+
continue;
1146+
}
1147+
if (pmu_type != pos->attr.type)
1148+
return true;
1149+
}
1150+
1151+
return false;
1152+
}
1153+
11291154
static void printout(int id, int nr, struct perf_evsel *counter, double uval,
11301155
char *prefix, u64 run, u64 ena, double noise,
11311156
struct runtime_stat *st)
@@ -1178,8 +1203,11 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,
11781203
counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED,
11791204
csv_sep);
11801205

1181-
if (counter->supported)
1206+
if (counter->supported) {
11821207
print_free_counters_hint = 1;
1208+
if (is_mixed_hw_group(counter))
1209+
print_mixed_hw_group_error = 1;
1210+
}
11831211

11841212
fprintf(stat_config.output, "%-*s%s",
11851213
csv_output ? 0 : unit_width,
@@ -1256,7 +1284,8 @@ static void uniquify_event_name(struct perf_evsel *counter)
12561284
char *new_name;
12571285
char *config;
12581286

1259-
if (!counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
1287+
if (counter->uniquified_name ||
1288+
!counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
12601289
strlen(counter->pmu_name)))
12611290
return;
12621291

@@ -1274,6 +1303,8 @@ static void uniquify_event_name(struct perf_evsel *counter)
12741303
counter->name = new_name;
12751304
}
12761305
}
1306+
1307+
counter->uniquified_name = true;
12771308
}
12781309

12791310
static void collect_all_aliases(struct perf_evsel *counter,
@@ -1757,6 +1788,11 @@ static void print_footer(void)
17571788
" echo 0 > /proc/sys/kernel/nmi_watchdog\n"
17581789
" perf stat ...\n"
17591790
" echo 1 > /proc/sys/kernel/nmi_watchdog\n");
1791+
1792+
if (print_mixed_hw_group_error)
1793+
fprintf(output,
1794+
"The events in group usually have to be from "
1795+
"the same PMU. Try reorganizing the group.\n");
17601796
}
17611797

17621798
static void print_counters(struct timespec *ts, int argc, const char **argv)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Family-model,Version,Filename,EventType
2-
209[78],1,cf_z10,core
3-
281[78],1,cf_z196,core
4-
282[78],1,cf_zec12,core
5-
296[45],1,cf_z13,core
6-
3906,3,cf_z14,core
2+
^IBM.209[78].*[13]\.[1-5].[[:xdigit:]]+$,1,cf_z10,core
3+
^IBM.281[78].*[13]\.[1-5].[[:xdigit:]]+$,1,cf_z196,core
4+
^IBM.282[78].*[13]\.[1-5].[[:xdigit:]]+$,1,cf_zec12,core
5+
^IBM.296[45].*[13]\.[1-5].[[:xdigit:]]+$,1,cf_z13,core
6+
^IBM.390[67].*[13]\.[1-5].[[:xdigit:]]+$,3,cf_z14,core

tools/perf/tests/attr/test-record-group-sampling

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ inherit=0
3535
# sampling disabled
3636
sample_freq=0
3737
sample_period=0
38+
freq=0
39+
write_backward=0
40+
sample_id_all=0

tools/perf/tests/shell/record+probe_libc_inet_pton.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ trace_libc_inet_pton_backtrace() {
1919
expected[1]=".*inet_pton[[:space:]]\($libc\)$"
2020
case "$(uname -m)" in
2121
s390x)
22-
eventattr='call-graph=dwarf'
22+
eventattr='call-graph=dwarf,max-stack=4'
2323
expected[2]="gaih_inet.*[[:space:]]\($libc|inlined\)$"
24-
expected[3]="__GI_getaddrinfo[[:space:]]\($libc|inlined\)$"
24+
expected[3]="(__GI_)?getaddrinfo[[:space:]]\($libc|inlined\)$"
2525
expected[4]="main[[:space:]]\(.*/bin/ping.*\)$"
26-
expected[5]="__libc_start_main[[:space:]]\($libc\)$"
27-
expected[6]="_start[[:space:]]\(.*/bin/ping.*\)$"
2826
;;
2927
*)
3028
eventattr='max-stack=3'

tools/perf/util/evsel.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,11 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
930930
* than leader in case leader 'leads' the sampling.
931931
*/
932932
if ((leader != evsel) && leader->sample_read) {
933-
attr->sample_freq = 0;
934-
attr->sample_period = 0;
933+
attr->freq = 0;
934+
attr->sample_freq = 0;
935+
attr->sample_period = 0;
936+
attr->write_backward = 0;
937+
attr->sample_id_all = 0;
935938
}
936939

937940
if (opts->no_samples)
@@ -1922,7 +1925,8 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
19221925
goto fallback_missing_features;
19231926
} else if (!perf_missing_features.group_read &&
19241927
evsel->attr.inherit &&
1925-
(evsel->attr.read_format & PERF_FORMAT_GROUP)) {
1928+
(evsel->attr.read_format & PERF_FORMAT_GROUP) &&
1929+
perf_evsel__is_group_leader(evsel)) {
19261930
perf_missing_features.group_read = true;
19271931
pr_debug2("switching off group read\n");
19281932
goto fallback_missing_features;
@@ -2754,8 +2758,14 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
27542758
(paranoid = perf_event_paranoid()) > 1) {
27552759
const char *name = perf_evsel__name(evsel);
27562760
char *new_name;
2761+
const char *sep = ":";
27572762

2758-
if (asprintf(&new_name, "%s%su", name, strchr(name, ':') ? "" : ":") < 0)
2763+
/* Is there already the separator in the name. */
2764+
if (strchr(name, '/') ||
2765+
strchr(name, ':'))
2766+
sep = "";
2767+
2768+
if (asprintf(&new_name, "%s%su", name, sep) < 0)
27592769
return false;
27602770

27612771
if (evsel->name)

tools/perf/util/evsel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct perf_evsel {
115115
unsigned int sample_size;
116116
int id_pos;
117117
int is_pos;
118+
bool uniquified_name;
118119
bool snapshot;
119120
bool supported;
120121
bool needs_swap;

tools/perf/util/machine.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,13 +1019,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type)
10191019
return ret;
10201020
}
10211021

1022-
static void map_groups__fixup_end(struct map_groups *mg)
1023-
{
1024-
int i;
1025-
for (i = 0; i < MAP__NR_TYPES; ++i)
1026-
__map_groups__fixup_end(mg, i);
1027-
}
1028-
10291022
static char *get_kernel_version(const char *root_dir)
10301023
{
10311024
char version[PATH_MAX];
@@ -1233,6 +1226,7 @@ int machine__create_kernel_maps(struct machine *machine)
12331226
{
12341227
struct dso *kernel = machine__get_kernel(machine);
12351228
const char *name = NULL;
1229+
struct map *map;
12361230
u64 addr = 0;
12371231
int ret;
12381232

@@ -1259,13 +1253,25 @@ int machine__create_kernel_maps(struct machine *machine)
12591253
machine__destroy_kernel_maps(machine);
12601254
return -1;
12611255
}
1262-
machine__set_kernel_mmap(machine, addr, 0);
1256+
1257+
/* we have a real start address now, so re-order the kmaps */
1258+
map = machine__kernel_map(machine);
1259+
1260+
map__get(map);
1261+
map_groups__remove(&machine->kmaps, map);
1262+
1263+
/* assume it's the last in the kmaps */
1264+
machine__set_kernel_mmap(machine, addr, ~0ULL);
1265+
1266+
map_groups__insert(&machine->kmaps, map);
1267+
map__put(map);
12631268
}
12641269

1265-
/*
1266-
* Now that we have all the maps created, just set the ->end of them:
1267-
*/
1268-
map_groups__fixup_end(&machine->kmaps);
1270+
/* update end address of the kernel map using adjacent module address */
1271+
map = map__next(machine__kernel_map(machine));
1272+
if (map)
1273+
machine__set_kernel_mmap(machine, addr, map->start);
1274+
12691275
return 0;
12701276
}
12711277

0 commit comments

Comments
 (0)