Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "Two core subsystem fixes, plus a handful of tooling fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf: Fix race in swevent hash perf: Fix race in perf_event_exec() perf list: Robustify event printing routine perf list: Add support for PERF_COUNT_SW_BPF_OUT perf hists browser: Fix segfault if use symbol filter in cmdline perf hists browser: Reset selection when refresh perf hists browser: Add NULL pointer check to prevent crash perf buildid-list: Fix return value of perf buildid-list -k perf buildid-list: Show running kernel build id fix
This commit is contained in:
commit
3ab6d1ebd5
@ -3154,15 +3154,16 @@ static int event_enable_on_exec(struct perf_event *event,
|
||||
* Enable all of a task's events that have been marked enable-on-exec.
|
||||
* This expects task == current.
|
||||
*/
|
||||
static void perf_event_enable_on_exec(struct perf_event_context *ctx)
|
||||
static void perf_event_enable_on_exec(int ctxn)
|
||||
{
|
||||
struct perf_event_context *clone_ctx = NULL;
|
||||
struct perf_event_context *ctx, *clone_ctx = NULL;
|
||||
struct perf_event *event;
|
||||
unsigned long flags;
|
||||
int enabled = 0;
|
||||
int ret;
|
||||
|
||||
local_irq_save(flags);
|
||||
ctx = current->perf_event_ctxp[ctxn];
|
||||
if (!ctx || !ctx->nr_events)
|
||||
goto out;
|
||||
|
||||
@ -3205,17 +3206,11 @@ out:
|
||||
|
||||
void perf_event_exec(void)
|
||||
{
|
||||
struct perf_event_context *ctx;
|
||||
int ctxn;
|
||||
|
||||
rcu_read_lock();
|
||||
for_each_task_context_nr(ctxn) {
|
||||
ctx = current->perf_event_ctxp[ctxn];
|
||||
if (!ctx)
|
||||
continue;
|
||||
|
||||
perf_event_enable_on_exec(ctx);
|
||||
}
|
||||
for_each_task_context_nr(ctxn)
|
||||
perf_event_enable_on_exec(ctxn);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
@ -6493,9 +6488,6 @@ struct swevent_htable {
|
||||
|
||||
/* Recursion avoidance in each contexts */
|
||||
int recursion[PERF_NR_CONTEXTS];
|
||||
|
||||
/* Keeps track of cpu being initialized/exited */
|
||||
bool online;
|
||||
};
|
||||
|
||||
static DEFINE_PER_CPU(struct swevent_htable, swevent_htable);
|
||||
@ -6753,14 +6745,8 @@ static int perf_swevent_add(struct perf_event *event, int flags)
|
||||
hwc->state = !(flags & PERF_EF_START);
|
||||
|
||||
head = find_swevent_head(swhash, event);
|
||||
if (!head) {
|
||||
/*
|
||||
* We can race with cpu hotplug code. Do not
|
||||
* WARN if the cpu just got unplugged.
|
||||
*/
|
||||
WARN_ON_ONCE(swhash->online);
|
||||
if (WARN_ON_ONCE(!head))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hlist_add_head_rcu(&event->hlist_entry, head);
|
||||
perf_event_update_userpage(event);
|
||||
@ -6828,7 +6814,6 @@ static int swevent_hlist_get_cpu(struct perf_event *event, int cpu)
|
||||
int err = 0;
|
||||
|
||||
mutex_lock(&swhash->hlist_mutex);
|
||||
|
||||
if (!swevent_hlist_deref(swhash) && cpu_online(cpu)) {
|
||||
struct swevent_hlist *hlist;
|
||||
|
||||
@ -9291,7 +9276,6 @@ static void perf_event_init_cpu(int cpu)
|
||||
struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
|
||||
|
||||
mutex_lock(&swhash->hlist_mutex);
|
||||
swhash->online = true;
|
||||
if (swhash->hlist_refcount > 0) {
|
||||
struct swevent_hlist *hlist;
|
||||
|
||||
@ -9333,14 +9317,7 @@ static void perf_event_exit_cpu_context(int cpu)
|
||||
|
||||
static void perf_event_exit_cpu(int cpu)
|
||||
{
|
||||
struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
|
||||
|
||||
perf_event_exit_cpu_context(cpu);
|
||||
|
||||
mutex_lock(&swhash->hlist_mutex);
|
||||
swhash->online = false;
|
||||
swevent_hlist_release(swhash);
|
||||
mutex_unlock(&swhash->hlist_mutex);
|
||||
}
|
||||
#else
|
||||
static inline void perf_event_exit_cpu(int cpu) { }
|
||||
|
@ -110,7 +110,7 @@ int cmd_buildid_list(int argc, const char **argv,
|
||||
setup_pager();
|
||||
|
||||
if (show_kernel)
|
||||
return sysfs__fprintf_build_id(stdout);
|
||||
return !(sysfs__fprintf_build_id(stdout) > 0);
|
||||
|
||||
return perf_session__list_build_ids(force, with_hits);
|
||||
}
|
||||
|
@ -298,6 +298,9 @@ static bool hist_browser__toggle_fold(struct hist_browser *browser)
|
||||
struct callchain_list *cl = container_of(ms, struct callchain_list, ms);
|
||||
bool has_children;
|
||||
|
||||
if (!he || !ms)
|
||||
return false;
|
||||
|
||||
if (ms == &he->ms)
|
||||
has_children = hist_entry__toggle_fold(he);
|
||||
else
|
||||
@ -928,6 +931,8 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
|
||||
}
|
||||
|
||||
ui_browser__hists_init_top(browser);
|
||||
hb->he_selection = NULL;
|
||||
hb->selection = NULL;
|
||||
|
||||
for (nd = browser->top; nd; nd = rb_next(nd)) {
|
||||
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
|
||||
@ -1033,6 +1038,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser,
|
||||
* and stop when we printed enough lines to fill the screen.
|
||||
*/
|
||||
do_offset:
|
||||
if (!nd)
|
||||
return;
|
||||
|
||||
if (offset > 0) {
|
||||
do {
|
||||
h = rb_entry(nd, struct hist_entry, rb_node);
|
||||
|
@ -91,7 +91,7 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf)
|
||||
bid += 2;
|
||||
}
|
||||
|
||||
return raw - build_id;
|
||||
return (bid - bf) + 1;
|
||||
}
|
||||
|
||||
int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id)
|
||||
|
@ -124,6 +124,10 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = {
|
||||
.symbol = "dummy",
|
||||
.alias = "",
|
||||
},
|
||||
[PERF_COUNT_SW_BPF_OUTPUT] = {
|
||||
.symbol = "bpf-output",
|
||||
.alias = "",
|
||||
},
|
||||
};
|
||||
|
||||
#define __PERF_EVENT_FIELD(config, name) \
|
||||
@ -1879,7 +1883,7 @@ restart:
|
||||
|
||||
for (i = 0; i < max; i++, syms++) {
|
||||
|
||||
if (event_glob != NULL &&
|
||||
if (event_glob != NULL && syms->symbol != NULL &&
|
||||
!(strglobmatch(syms->symbol, event_glob) ||
|
||||
(syms->alias && strglobmatch(syms->alias, event_glob))))
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user