Skip to content

Commit e4b3e06

Browse files
committed
Merge tag 'perf-urgent-for-mingo-20160726' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo: - Fix obtaining the 'start' address for a kernel module on s390, where .text doesn't coincide with the start of the module as reported in /proc/modules (Song Shan Gong) - Use official ELF e_machine value for BPF objects generated via perf + LLVM when specifying BPF scriptlet in 'perf record/trace --event' (Wang Nan) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents 37e13a1 + 203d8a4 commit e4b3e06

5 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎tools/lib/bpf/libbpf.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
#include "libbpf.h"
3838
#include "bpf.h"
3939

40+
#ifndef EM_BPF
41+
#define EM_BPF 247
42+
#endif
43+
4044
#define __printf(a, b) __attribute__((format(printf, a, b)))
4145

4246
__printf(1, 2)
@@ -439,7 +443,8 @@ static int bpf_object__elf_init(struct bpf_object *obj)
439443
}
440444
ep = &obj->efile.ehdr;
441445

442-
if ((ep->e_type != ET_REL) || (ep->e_machine != 0)) {
446+
/* Old LLVM set e_machine to EM_NONE */
447+
if ((ep->e_type != ET_REL) || (ep->e_machine && (ep->e_machine != EM_BPF))) {
443448
pr_warning("%s is not an eBPF object file\n",
444449
obj->path);
445450
err = -LIBBPF_ERRNO__FORMAT;

‎tools/perf/arch/s390/util/Build‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ libperf-y += header.o
22
libperf-y += kvm-stat.o
33

44
libperf-$(CONFIG_DWARF) += dwarf-regs.o
5+
6+
libperf-y += machine.o
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <unistd.h>
2+
#include <stdio.h>
3+
#include <string.h>
4+
#include "util.h"
5+
#include "machine.h"
6+
#include "api/fs/fs.h"
7+
8+
int arch__fix_module_text_start(u64 *start, const char *name)
9+
{
10+
char path[PATH_MAX];
11+
12+
snprintf(path, PATH_MAX, "module/%.*s/sections/.text",
13+
(int)strlen(name) - 2, name + 1);
14+
15+
if (sysfs__read_ull(path, (unsigned long long *)start) < 0)
16+
return -1;
17+
18+
return 0;
19+
}

‎tools/perf/util/machine.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,12 +1093,20 @@ static int machine__set_modules_path(struct machine *machine)
10931093

10941094
return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0);
10951095
}
1096+
int __weak arch__fix_module_text_start(u64 *start __maybe_unused,
1097+
const char *name __maybe_unused)
1098+
{
1099+
return 0;
1100+
}
10961101

10971102
static int machine__create_module(void *arg, const char *name, u64 start)
10981103
{
10991104
struct machine *machine = arg;
11001105
struct map *map;
11011106

1107+
if (arch__fix_module_text_start(&start, name) < 0)
1108+
return -1;
1109+
11021110
map = machine__findnew_module_map(machine, start, name);
11031111
if (map == NULL)
11041112
return -1;

‎tools/perf/util/machine.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ struct symbol *machine__find_kernel_function_by_name(struct machine *machine,
216216

217217
struct map *machine__findnew_module_map(struct machine *machine, u64 start,
218218
const char *filename);
219+
int arch__fix_module_text_start(u64 *start, const char *name);
219220

220221
int __machine__load_kallsyms(struct machine *machine, const char *filename,
221222
enum map_type type, bool no_kcore, symbol_filter_t filter);

0 commit comments

Comments
 (0)