Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/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 <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Oct 16, 2014
2 parents ec4212d + 673d659 commit 71c62b2
Show file tree
Hide file tree
Showing 31 changed files with 460 additions and 669 deletions.
611 changes: 49 additions & 562 deletions Documentation/ABI/testing/sysfs-bus-event_source-devices-events

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tools/perf/Documentation/perf-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ If specified the 'Weighted diff' column is displayed with value 'd' computed as:

- period being the hist entry period value

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

SEE ALSO
--------
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/Documentation/perf-kvm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ OPTIONS
STAT REPORT OPTIONS
-------------------
--vcpu=<value>::
analyze events which occures on this vcpu. (default: all vcpus)
analyze events which occur on this vcpu. (default: all vcpus)

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

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


--event=<value>::
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ various perf commands with the -e option.
EVENT MODIFIERS
---------------

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

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.

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

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/Documentation/perf-script-perl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ strings for flag and symbolic fields. These correspond to the strings
and values parsed from the 'print fmt' fields of the event format
files:

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
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
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
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

Perf::Trace::Context Module
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
6 changes: 3 additions & 3 deletions tools/perf/Documentation/perf-script-python.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ and having the counts we've tallied as values.

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

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
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
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
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

The *autodict* function returns a special kind of Python
dictionary that implements Perl's 'autovivifying' hashes in Python
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ OPTIONS

"Overriding previous field request for all events."

Alternativey, consider the order:
Alternatively, consider the order:

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

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ OPTIONS
-------
-s::
--skip::
Tests to skip (comma separater numeric list).
Tests to skip (comma separated numeric list).

-v::
--verbose::
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-trace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ scheduling events, etc.
This is a live mode tool in addition to working with perf.data files like
the other perf tools. Files can be generated using the 'perf record' command
but the session needs to include the raw_syscalls events (-e 'raw_syscalls:*').
Alernatively, the 'perf trace record' can be used as a shortcut to
Alternatively, 'perf trace record' can be used as a shortcut to
automatically include the raw_syscalls events when writing events to a file.

The following options apply to perf trace; options to perf trace record are
Expand Down
7 changes: 4 additions & 3 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
struct perf_sample *sample)
{
/* Only kvm_entry records vcpu id. */
if (!thread->priv && kvm_entry_event(evsel)) {
if (!thread__priv(thread) && kvm_entry_event(evsel)) {
struct vcpu_event_record *vcpu_record;

vcpu_record = zalloc(sizeof(*vcpu_record));
Expand All @@ -386,10 +386,10 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
}

vcpu_record->vcpu_id = perf_evsel__intval(evsel, sample, VCPU_ID);
thread->priv = vcpu_record;
thread__set_priv(thread, vcpu_record);
}

return thread->priv;
return thread__priv(thread);
}

static bool handle_kvm_event(struct perf_kvm_stat *kvm,
Expand Down Expand Up @@ -1358,6 +1358,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
}
kvm->session->evlist = kvm->evlist;
perf_session__set_id_hdr_size(kvm->session);
ordered_events__set_copy_on_queue(&kvm->session->ordered_events, true);
machine__synthesize_threads(&kvm->session->machines.host, &kvm->opts.target,
kvm->evlist->threads, false);
err = kvm_live_open_events(kvm);
Expand Down
7 changes: 7 additions & 0 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ static int report__setup_sample_type(struct report *rep)
}
}

if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) {
if ((sample_type & PERF_SAMPLE_REGS_USER) &&
(sample_type & PERF_SAMPLE_STACK_USER))
callchain_param.record_mode = CALLCHAIN_DWARF;
else
callchain_param.record_mode = CALLCHAIN_FP;
}
return 0;
}

Expand Down
16 changes: 8 additions & 8 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,13 +1189,13 @@ static struct thread_trace *thread__trace(struct thread *thread, FILE *fp)
if (thread == NULL)
goto fail;

if (thread->priv == NULL)
thread->priv = thread_trace__new();
if (thread__priv(thread) == NULL)
thread__set_priv(thread, thread_trace__new());

if (thread->priv == NULL)
if (thread__priv(thread) == NULL)
goto fail;

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

return ttrace;
Expand Down Expand Up @@ -1248,7 +1248,7 @@ struct trace {

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

if (fd > ttrace->paths.max) {
char **npath = realloc(ttrace->paths.table, (fd + 1) * sizeof(char *));
Expand Down Expand Up @@ -1301,7 +1301,7 @@ static int thread__read_fd_path(struct thread *thread, int fd)
static const char *thread__fd_path(struct thread *thread, int fd,
struct trace *trace)
{
struct thread_trace *ttrace = thread->priv;
struct thread_trace *ttrace = thread__priv(thread);

if (ttrace == NULL)
return NULL;
Expand Down Expand Up @@ -1338,7 +1338,7 @@ static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size,
{
int fd = arg->val;
size_t printed = syscall_arg__scnprintf_fd(bf, size, arg);
struct thread_trace *ttrace = arg->thread->priv;
struct thread_trace *ttrace = thread__priv(arg->thread);

if (ttrace && fd >= 0 && fd <= ttrace->paths.max)
zfree(&ttrace->paths.table[fd]);
Expand Down Expand Up @@ -2381,7 +2381,7 @@ static int trace__fprintf_one_thread(struct thread *thread, void *priv)
FILE *fp = data->fp;
size_t printed = data->printed;
struct trace *trace = data->trace;
struct thread_trace *ttrace = thread->priv;
struct thread_trace *ttrace = thread__priv(thread);
double ratio;

if (ttrace == NULL)
Expand Down
3 changes: 3 additions & 0 deletions tools/perf/tests/dwarf-unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "perf_regs.h"
#include "map.h"
#include "thread.h"
#include "callchain.h"

static int mmap_handler(struct perf_tool *tool __maybe_unused,
union perf_event *event,
Expand Down Expand Up @@ -120,6 +121,8 @@ int test__dwarf_unwind(void)
return -1;
}

callchain_param.record_mode = CALLCHAIN_DWARF;

if (init_live_machine(machine)) {
pr_err("Could not init machine\n");
goto out;
Expand Down
36 changes: 36 additions & 0 deletions tools/perf/tests/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,36 @@ static int test__checkevent_pmu_events(struct perf_evlist *evlist)
return 0;
}


static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist)
{
struct perf_evsel *evsel = perf_evlist__first(evlist);

/* pmu-event:u */
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
TEST_ASSERT_VAL("wrong exclude_user",
!evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel",
evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);

/* cpu/pmu-event/u*/
evsel = perf_evsel__next(evsel);
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
TEST_ASSERT_VAL("wrong exclude_user",
!evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel",
evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);

return 0;
}

static int test__checkterms_simple(struct list_head *terms)
{
struct parse_events_term *term;
Expand Down Expand Up @@ -1554,6 +1584,12 @@ static int test_pmu_events(void)
e.check = test__checkevent_pmu_events;

ret = test_event(&e);
if (ret)
break;
snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
e.name = name;
e.check = test__checkevent_pmu_events_mix;
ret = test_event(&e);
#undef MAX_NAME
}

Expand Down
32 changes: 22 additions & 10 deletions tools/perf/ui/browsers/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ struct hist_browser {

extern void hist_browser__init_hpp(void);

static int hists__browser_title(struct hists *hists, char *bf, size_t size);
static int hists__browser_title(struct hists *hists,
struct hist_browser_timer *hbt,
char *bf, size_t size);
static void hist_browser__update_nr_entries(struct hist_browser *hb);

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

hists__browser_title(browser->hists, title, sizeof(title));
hists__browser_title(browser->hists, hbt, title, sizeof(title));

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

hists__browser_title(browser->hists, title, sizeof(title));
hists__browser_title(browser->hists,
hbt, title, sizeof(title));
ui_browser__show_title(&browser->b, title);
continue;
}
Expand Down Expand Up @@ -1204,7 +1207,15 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *browser
return browser->he_selection->thread;
}

static int hists__browser_title(struct hists *hists, char *bf, size_t size)
/* Check whether the browser is for 'top' or 'report' */
static inline bool is_report_browser(void *timer)
{
return timer == NULL;
}

static int hists__browser_title(struct hists *hists,
struct hist_browser_timer *hbt,
char *bf, size_t size)
{
char unit;
int printed;
Expand Down Expand Up @@ -1258,6 +1269,13 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size)
if (dso)
printed += scnprintf(bf + printed, size - printed,
", DSO: %s", dso->short_name);
if (!is_report_browser(hbt)) {
struct perf_top *top = hbt->arg;

if (top->zero)
printed += scnprintf(bf + printed, size - printed, " [z]");
}

return printed;
}

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

/* Check whether the browser is for 'top' or 'report' */
static inline bool is_report_browser(void *timer)
{
return timer == NULL;
}

/*
* Only runtime switching of perf data file will make "input_name" point
* to a malloced buffer. So add "is_input_name_malloced" flag to decide
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)

out_delete_threads:
thread_map__delete(evlist->threads);
evlist->threads = NULL;
return -1;
}

Expand Down
1 change: 0 additions & 1 deletion tools/perf/util/include/linux/string.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <string.h>

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

0 comments on commit 71c62b2

Please sign in to comment.