Skip to content

Commit 7f7d556

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Thomas Gleixner: "This update contains: - a fix for the bpf tools to use the new EM_BPF code - a fix for the module parser of perf to retrieve the proper text start address - add str_error_c to libapi to avoid linking against tools/lib/str_error_r.o" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: tools lib api: Add str_error_c to libapi perf s390: Fix 'start' address of module's map tools lib bpf: Use official ELF e_machine value
2 parents 228ffba + 9ecabed commit 7f7d556

File tree

8 files changed

+41
-7
lines changed

8 files changed

+41
-7
lines changed

tools/lib/api/Build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ libapi-y += fd/
22
libapi-y += fs/
33
libapi-y += cpu.o
44
libapi-y += debug.o
5+
libapi-y += str_error_r.o
6+
7+
$(OUTPUT)str_error_r.o: ../str_error_r.c FORCE
8+
$(call rule_mkdir)
9+
$(call if_changed_dep,cc_o_c)

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

tools/perf/arch/s390/util/machine.c

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ libperf-y += stat.o
7070
libperf-y += stat-shadow.o
7171
libperf-y += record.o
7272
libperf-y += srcline.o
73-
libperf-y += str_error_r.o
7473
libperf-y += data.o
7574
libperf-y += tsc.o
7675
libperf-y += cloexec.o
@@ -176,10 +175,6 @@ $(OUTPUT)util/libstring.o: ../lib/string.c FORCE
176175
$(call rule_mkdir)
177176
$(call if_changed_dep,cc_o_c)
178177

179-
$(OUTPUT)util/str_error_r.o: ../lib/str_error_r.c FORCE
180-
$(call rule_mkdir)
181-
$(call if_changed_dep,cc_o_c)
182-
183178
$(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
184179
$(call rule_mkdir)
185180
$(call if_changed_dep,cc_o_c)

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

tools/perf/util/python-ext-sources

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ util/cpumap.c
1313
../lib/bitmap.c
1414
../lib/find_bit.c
1515
../lib/hweight.c
16-
../lib/str_error_r.c
1716
../lib/vsprintf.c
1817
util/thread_map.c
1918
util/util.c

0 commit comments

Comments
 (0)