Skip to content

Commit 71c62b2

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/core improvements and fixes from Arnaldo Carvalho de Melo: User visible changes: * Add a visual cue for toggle zeroing of samples in 'perf top' (Taeung Song) * Fix for double free in 'perf stat' when using some specific invalid command line combo (Yasser Shalabi) Infrastructure changes: * Add option to copy events when queuing for sorting across cpu buffers and enable it for 'perf kvm stat live', to avoid having events left in the queue pointing to the ring buffer be rewritten in high volume sessions. (Alexander Yarygin, improving work done by David Ahern): * Document sysfs events/ interfaces (Cody P Schafer) * Add support to new style format of kernel PMU event. (Kan Liang) * Fix typos in perf/Documentation (Masanari Iida) * Improve callchains when using libunwind (Namhyung Kim) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents ec4212d + 673d659 commit 71c62b2

31 files changed

+460
-669
lines changed

Documentation/ABI/testing/sysfs-bus-event_source-devices-events

Lines changed: 49 additions & 562 deletions
Large diffs are not rendered by default.

tools/perf/Documentation/perf-diff.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ If specified the 'Weighted diff' column is displayed with value 'd' computed as:
196196

197197
- period being the hist entry period value
198198

199-
- WEIGHT-A/WEIGHT-B being user suplied weights in the the '-c' option
199+
- WEIGHT-A/WEIGHT-B being user supplied weights in the the '-c' option
200200
behind ':' separator like '-c wdiff:1,2'.
201-
- WIEGHT-A being the weight of the data file
202-
- WIEGHT-B being the weight of the baseline data file
201+
- WEIGHT-A being the weight of the data file
202+
- WEIGHT-B being the weight of the baseline data file
203203

204204
SEE ALSO
205205
--------

tools/perf/Documentation/perf-kvm.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ OPTIONS
100100
STAT REPORT OPTIONS
101101
-------------------
102102
--vcpu=<value>::
103-
analyze events which occures on this vcpu. (default: all vcpus)
103+
analyze events which occur on this vcpu. (default: all vcpus)
104104

105105
--event=<value>::
106106
event to be analyzed. Possible values: vmexit, mmio (x86 only),
@@ -134,7 +134,7 @@ STAT LIVE OPTIONS
134134
Analyze events only for given process ID(s) (comma separated list).
135135

136136
--vcpu=<value>::
137-
analyze events which occures on this vcpu. (default: all vcpus)
137+
analyze events which occur on this vcpu. (default: all vcpus)
138138

139139

140140
--event=<value>::

tools/perf/Documentation/perf-list.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ various perf commands with the -e option.
1919
EVENT MODIFIERS
2020
---------------
2121

22-
Events can optionally have a modifer by appending a colon and one or
22+
Events can optionally have a modifier by appending a colon and one or
2323
more modifiers. Modifiers allow the user to restrict the events to be
2424
counted. The following modifiers exist:
2525

tools/perf/Documentation/perf-record.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
146146

147147
-N::
148148
--no-buildid-cache::
149-
Do not update the builid cache. This saves some overhead in situations
149+
Do not update the buildid cache. This saves some overhead in situations
150150
where the information in the perf.data file (which includes buildids)
151151
is sufficient.
152152

tools/perf/Documentation/perf-script-perl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ strings for flag and symbolic fields. These correspond to the strings
181181
and values parsed from the 'print fmt' fields of the event format
182182
files:
183183

184-
flag_str($event_name, $field_name, $field_value) - returns the string represention corresponding to $field_value for the flag field $field_name of event $event_name
185-
symbol_str($event_name, $field_name, $field_value) - returns the string represention corresponding to $field_value for the symbolic field $field_name of event $event_name
184+
flag_str($event_name, $field_name, $field_value) - returns the string representation corresponding to $field_value for the flag field $field_name of event $event_name
185+
symbol_str($event_name, $field_name, $field_value) - returns the string representation corresponding to $field_value for the symbolic field $field_name of event $event_name
186186

187187
Perf::Trace::Context Module
188188
~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/perf/Documentation/perf-script-python.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ and having the counts we've tallied as values.
263263

264264
The print_syscall_totals() function iterates over the entries in the
265265
dictionary and displays a line for each entry containing the syscall
266-
name (the dictonary keys contain the syscall ids, which are passed to
266+
name (the dictionary keys contain the syscall ids, which are passed to
267267
the Util function syscall_name(), which translates the raw syscall
268268
numbers to the corresponding syscall name strings). The output is
269269
displayed after all the events in the trace have been processed, by
@@ -576,8 +576,8 @@ strings for flag and symbolic fields. These correspond to the strings
576576
and values parsed from the 'print fmt' fields of the event format
577577
files:
578578

579-
flag_str(event_name, field_name, field_value) - returns the string represention corresponding to field_value for the flag field field_name of event event_name
580-
symbol_str(event_name, field_name, field_value) - returns the string represention corresponding to field_value for the symbolic field field_name of event event_name
579+
flag_str(event_name, field_name, field_value) - returns the string representation corresponding to field_value for the flag field field_name of event event_name
580+
symbol_str(event_name, field_name, field_value) - returns the string representation corresponding to field_value for the symbolic field field_name of event event_name
581581

582582
The *autodict* function returns a special kind of Python
583583
dictionary that implements Perl's 'autovivifying' hashes in Python

tools/perf/Documentation/perf-script.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ OPTIONS
140140

141141
"Overriding previous field request for all events."
142142

143-
Alternativey, consider the order:
143+
Alternatively, consider the order:
144144

145145
-f comm,tid,time,ip,sym -f trace:
146146

tools/perf/Documentation/perf-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ OPTIONS
2525
-------
2626
-s::
2727
--skip::
28-
Tests to skip (comma separater numeric list).
28+
Tests to skip (comma separated numeric list).
2929

3030
-v::
3131
--verbose::

tools/perf/Documentation/perf-trace.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ scheduling events, etc.
2020
This is a live mode tool in addition to working with perf.data files like
2121
the other perf tools. Files can be generated using the 'perf record' command
2222
but the session needs to include the raw_syscalls events (-e 'raw_syscalls:*').
23-
Alernatively, the 'perf trace record' can be used as a shortcut to
23+
Alternatively, 'perf trace record' can be used as a shortcut to
2424
automatically include the raw_syscalls events when writing events to a file.
2525

2626
The following options apply to perf trace; options to perf trace record are

tools/perf/builtin-kvm.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
376376
struct perf_sample *sample)
377377
{
378378
/* Only kvm_entry records vcpu id. */
379-
if (!thread->priv && kvm_entry_event(evsel)) {
379+
if (!thread__priv(thread) && kvm_entry_event(evsel)) {
380380
struct vcpu_event_record *vcpu_record;
381381

382382
vcpu_record = zalloc(sizeof(*vcpu_record));
@@ -386,10 +386,10 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
386386
}
387387

388388
vcpu_record->vcpu_id = perf_evsel__intval(evsel, sample, VCPU_ID);
389-
thread->priv = vcpu_record;
389+
thread__set_priv(thread, vcpu_record);
390390
}
391391

392-
return thread->priv;
392+
return thread__priv(thread);
393393
}
394394

395395
static bool handle_kvm_event(struct perf_kvm_stat *kvm,
@@ -1358,6 +1358,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
13581358
}
13591359
kvm->session->evlist = kvm->evlist;
13601360
perf_session__set_id_hdr_size(kvm->session);
1361+
ordered_events__set_copy_on_queue(&kvm->session->ordered_events, true);
13611362
machine__synthesize_threads(&kvm->session->machines.host, &kvm->opts.target,
13621363
kvm->evlist->threads, false);
13631364
err = kvm_live_open_events(kvm);

tools/perf/builtin-report.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ static int report__setup_sample_type(struct report *rep)
257257
}
258258
}
259259

260+
if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) {
261+
if ((sample_type & PERF_SAMPLE_REGS_USER) &&
262+
(sample_type & PERF_SAMPLE_STACK_USER))
263+
callchain_param.record_mode = CALLCHAIN_DWARF;
264+
else
265+
callchain_param.record_mode = CALLCHAIN_FP;
266+
}
260267
return 0;
261268
}
262269

tools/perf/builtin-trace.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,13 +1189,13 @@ static struct thread_trace *thread__trace(struct thread *thread, FILE *fp)
11891189
if (thread == NULL)
11901190
goto fail;
11911191

1192-
if (thread->priv == NULL)
1193-
thread->priv = thread_trace__new();
1192+
if (thread__priv(thread) == NULL)
1193+
thread__set_priv(thread, thread_trace__new());
11941194

1195-
if (thread->priv == NULL)
1195+
if (thread__priv(thread) == NULL)
11961196
goto fail;
11971197

1198-
ttrace = thread->priv;
1198+
ttrace = thread__priv(thread);
11991199
++ttrace->nr_events;
12001200

12011201
return ttrace;
@@ -1248,7 +1248,7 @@ struct trace {
12481248

12491249
static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pathname)
12501250
{
1251-
struct thread_trace *ttrace = thread->priv;
1251+
struct thread_trace *ttrace = thread__priv(thread);
12521252

12531253
if (fd > ttrace->paths.max) {
12541254
char **npath = realloc(ttrace->paths.table, (fd + 1) * sizeof(char *));
@@ -1301,7 +1301,7 @@ static int thread__read_fd_path(struct thread *thread, int fd)
13011301
static const char *thread__fd_path(struct thread *thread, int fd,
13021302
struct trace *trace)
13031303
{
1304-
struct thread_trace *ttrace = thread->priv;
1304+
struct thread_trace *ttrace = thread__priv(thread);
13051305

13061306
if (ttrace == NULL)
13071307
return NULL;
@@ -1338,7 +1338,7 @@ static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size,
13381338
{
13391339
int fd = arg->val;
13401340
size_t printed = syscall_arg__scnprintf_fd(bf, size, arg);
1341-
struct thread_trace *ttrace = arg->thread->priv;
1341+
struct thread_trace *ttrace = thread__priv(arg->thread);
13421342

13431343
if (ttrace && fd >= 0 && fd <= ttrace->paths.max)
13441344
zfree(&ttrace->paths.table[fd]);
@@ -2381,7 +2381,7 @@ static int trace__fprintf_one_thread(struct thread *thread, void *priv)
23812381
FILE *fp = data->fp;
23822382
size_t printed = data->printed;
23832383
struct trace *trace = data->trace;
2384-
struct thread_trace *ttrace = thread->priv;
2384+
struct thread_trace *ttrace = thread__priv(thread);
23852385
double ratio;
23862386

23872387
if (ttrace == NULL)

tools/perf/tests/dwarf-unwind.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "perf_regs.h"
1010
#include "map.h"
1111
#include "thread.h"
12+
#include "callchain.h"
1213

1314
static int mmap_handler(struct perf_tool *tool __maybe_unused,
1415
union perf_event *event,
@@ -120,6 +121,8 @@ int test__dwarf_unwind(void)
120121
return -1;
121122
}
122123

124+
callchain_param.record_mode = CALLCHAIN_DWARF;
125+
123126
if (init_live_machine(machine)) {
124127
pr_err("Could not init machine\n");
125128
goto out;

tools/perf/tests/parse-events.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,36 @@ static int test__checkevent_pmu_events(struct perf_evlist *evlist)
457457
return 0;
458458
}
459459

460+
461+
static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist)
462+
{
463+
struct perf_evsel *evsel = perf_evlist__first(evlist);
464+
465+
/* pmu-event:u */
466+
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
467+
TEST_ASSERT_VAL("wrong exclude_user",
468+
!evsel->attr.exclude_user);
469+
TEST_ASSERT_VAL("wrong exclude_kernel",
470+
evsel->attr.exclude_kernel);
471+
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
472+
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
473+
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
474+
475+
/* cpu/pmu-event/u*/
476+
evsel = perf_evsel__next(evsel);
477+
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
478+
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
479+
TEST_ASSERT_VAL("wrong exclude_user",
480+
!evsel->attr.exclude_user);
481+
TEST_ASSERT_VAL("wrong exclude_kernel",
482+
evsel->attr.exclude_kernel);
483+
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
484+
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
485+
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
486+
487+
return 0;
488+
}
489+
460490
static int test__checkterms_simple(struct list_head *terms)
461491
{
462492
struct parse_events_term *term;
@@ -1554,6 +1584,12 @@ static int test_pmu_events(void)
15541584
e.check = test__checkevent_pmu_events;
15551585

15561586
ret = test_event(&e);
1587+
if (ret)
1588+
break;
1589+
snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
1590+
e.name = name;
1591+
e.check = test__checkevent_pmu_events_mix;
1592+
ret = test_event(&e);
15571593
#undef MAX_NAME
15581594
}
15591595

tools/perf/ui/browsers/hists.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ struct hist_browser {
3535

3636
extern void hist_browser__init_hpp(void);
3737

38-
static int hists__browser_title(struct hists *hists, char *bf, size_t size);
38+
static int hists__browser_title(struct hists *hists,
39+
struct hist_browser_timer *hbt,
40+
char *bf, size_t size);
3941
static void hist_browser__update_nr_entries(struct hist_browser *hb);
4042

4143
static struct rb_node *hists__filter_entries(struct rb_node *nd,
@@ -390,7 +392,7 @@ static int hist_browser__run(struct hist_browser *browser,
390392
browser->b.entries = &browser->hists->entries;
391393
browser->b.nr_entries = hist_browser__nr_entries(browser);
392394

393-
hists__browser_title(browser->hists, title, sizeof(title));
395+
hists__browser_title(browser->hists, hbt, title, sizeof(title));
394396

395397
if (ui_browser__show(&browser->b, title,
396398
"Press '?' for help on key bindings") < 0)
@@ -417,7 +419,8 @@ static int hist_browser__run(struct hist_browser *browser,
417419
ui_browser__warn_lost_events(&browser->b);
418420
}
419421

420-
hists__browser_title(browser->hists, title, sizeof(title));
422+
hists__browser_title(browser->hists,
423+
hbt, title, sizeof(title));
421424
ui_browser__show_title(&browser->b, title);
422425
continue;
423426
}
@@ -1204,7 +1207,15 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *browser
12041207
return browser->he_selection->thread;
12051208
}
12061209

1207-
static int hists__browser_title(struct hists *hists, char *bf, size_t size)
1210+
/* Check whether the browser is for 'top' or 'report' */
1211+
static inline bool is_report_browser(void *timer)
1212+
{
1213+
return timer == NULL;
1214+
}
1215+
1216+
static int hists__browser_title(struct hists *hists,
1217+
struct hist_browser_timer *hbt,
1218+
char *bf, size_t size)
12081219
{
12091220
char unit;
12101221
int printed;
@@ -1258,6 +1269,13 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size)
12581269
if (dso)
12591270
printed += scnprintf(bf + printed, size - printed,
12601271
", DSO: %s", dso->short_name);
1272+
if (!is_report_browser(hbt)) {
1273+
struct perf_top *top = hbt->arg;
1274+
1275+
if (top->zero)
1276+
printed += scnprintf(bf + printed, size - printed, " [z]");
1277+
}
1278+
12611279
return printed;
12621280
}
12631281

@@ -1269,12 +1287,6 @@ static inline void free_popup_options(char **options, int n)
12691287
zfree(&options[i]);
12701288
}
12711289

1272-
/* Check whether the browser is for 'top' or 'report' */
1273-
static inline bool is_report_browser(void *timer)
1274-
{
1275-
return timer == NULL;
1276-
}
1277-
12781290
/*
12791291
* Only runtime switching of perf data file will make "input_name" point
12801292
* to a malloced buffer. So add "is_input_name_malloced" flag to decide

tools/perf/util/evlist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
10031003

10041004
out_delete_threads:
10051005
thread_map__delete(evlist->threads);
1006+
evlist->threads = NULL;
10061007
return -1;
10071008
}
10081009

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#include <string.h>
22

33
void *memdup(const void *src, size_t len);
4-
int str_append(char **s, int *len, const char *a);

0 commit comments

Comments
 (0)