Skip to content

Commit

Permalink
Merge tag 'perf-urgent-for-mingo-5.1-20190419' of git://git.kernel.or…
Browse files Browse the repository at this point in the history
…g/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

perf top:

  Jiri Olsa:

  - Fix 'perf top --pid', it needs PERF_SAMPLE_TIME since we switched to using
    a different thread to sort the events and then even for just a single
    thread we now need timestamps.

BPF:

  Jiri Olsa:

  - Fix bpf_prog and btf lookup functions failure path to to properly return
    NULL.

  - Fix side band thread draining, used to process PERF_RECORD_BPF_EVENT
    metadata records.

core:

  Jiri Olsa:

  - Fix map lookup by name to get a refcount when the name is already in
    the tree. Found

  Song Liu:

  - Fix __map__is_kmodule() by taking into account recently added BPF
    maps.

UAPI:

  Arnaldo Carvalho de Melo:

  - Sync sound/asound.h copy

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Ingo Molnar committed Apr 19, 2019
2 parents b191fa9 + 2db7b1e commit 7579dfc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
1 change: 1 addition & 0 deletions tools/include/uapi/sound/asound.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#ifndef __KERNEL__
#include <stdlib.h>
#include <time.h>
#endif

/*
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ int cmd_top(int argc, const char **argv)
* */
.overwrite = 0,
.sample_time = true,
.sample_time_set = true,
},
.max_stack = sysctl__max_stack(),
.annotation_opts = annotation__default_options,
Expand Down
8 changes: 6 additions & 2 deletions tools/perf/util/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ struct bpf_prog_info_node *perf_env__find_bpf_prog_info(struct perf_env *env,
else if (prog_id > node->info_linear->info.id)
n = n->rb_right;
else
break;
goto out;
}
node = NULL;

out:
up_read(&env->bpf_progs.lock);
return node;
}
Expand Down Expand Up @@ -109,10 +111,12 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
else if (btf_id > node->id)
n = n->rb_right;
else
break;
goto out;
}
node = NULL;

up_read(&env->bpf_progs.lock);
out:
return node;
}

Expand Down
14 changes: 9 additions & 5 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,12 +1868,12 @@ static void *perf_evlist__poll_thread(void *arg)
{
struct perf_evlist *evlist = arg;
bool draining = false;
int i;
int i, done = 0;

while (!done) {
bool got_data = false;

while (draining || !(evlist->thread.done)) {
if (draining)
draining = false;
else if (evlist->thread.done)
if (evlist->thread.done)
draining = true;

if (!draining)
Expand All @@ -1894,9 +1894,13 @@ static void *perf_evlist__poll_thread(void *arg)
pr_warning("cannot locate proper evsel for the side band event\n");

perf_mmap__consume(map);
got_data = true;
}
perf_mmap__read_done(map);
}

if (draining && !got_data)
break;
}
return NULL;
}
Expand Down
20 changes: 17 additions & 3 deletions tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,22 @@ bool __map__is_extra_kernel_map(const struct map *map)
return kmap && kmap->name[0];
}

bool __map__is_bpf_prog(const struct map *map)
{
const char *name;

if (map->dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO)
return true;

/*
* If PERF_RECORD_BPF_EVENT is not included, the dso will not have
* type of DSO_BINARY_TYPE__BPF_PROG_INFO. In such cases, we can
* guess the type based on name.
*/
name = map->dso->short_name;
return name && (strstr(name, "bpf_prog_") == name);
}

bool map__has_symbols(const struct map *map)
{
return dso__has_symbols(map->dso);
Expand Down Expand Up @@ -910,10 +926,8 @@ static void __maps__insert_name(struct maps *maps, struct map *map)
rc = strcmp(m->dso->short_name, map->dso->short_name);
if (rc < 0)
p = &(*p)->rb_left;
else if (rc > 0)
p = &(*p)->rb_right;
else
return;
p = &(*p)->rb_right;
}
rb_link_node(&map->rb_node_name, parent, p);
rb_insert_color(&map->rb_node_name, &maps->names);
Expand Down
4 changes: 3 additions & 1 deletion tools/perf/util/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name,

bool __map__is_kernel(const struct map *map);
bool __map__is_extra_kernel_map(const struct map *map);
bool __map__is_bpf_prog(const struct map *map);

static inline bool __map__is_kmodule(const struct map *map)
{
return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map);
return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) &&
!__map__is_bpf_prog(map);
}

bool map__has_symbols(const struct map *map);
Expand Down

0 comments on commit 7579dfc

Please sign in to comment.