Skip to content

Commit 116b081

Browse files
committed
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar: "The main changes in this cycle on the kernel side: - rework kprobes blacklist handling (Masami Hiramatsu) - misc cleanups on the tooling side these areas were the main focus: - 'perf trace' enhancements (Arnaldo Carvalho de Melo) - 'perf bench' enhancements (Davidlohr Bueso) - 'perf record' enhancements (Alexey Budankov) - 'perf annotate' enhancements (Jin Yao) - 'perf top' enhancements (Jiri Olsa) - Intel hw tracing enhancements (Adrian Hunter) - ARM hw tracing enhancements (Leo Yan, Mathieu Poirier) - ... plus lots of other enhancements, cleanups and fixes" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (171 commits) tools uapi asm: Update asm-generic/unistd.h copy perf symbols: Relax checks on perf-PID.map ownership perf trace: Wire up the fadvise 'advice' table generator perf beauty: Add generator for fadvise64's 'advice' arg constants tools headers uapi: Grab a copy of fadvise.h perf beauty mmap: Print mmap's 'offset' arg in hexadecimal perf beauty mmap: Print PROT_READ before PROT_EXEC to match strace output perf trace beauty: Beautify arch_prctl()'s arguments perf trace: When showing string prefixes show prefix + ??? for unknown entries perf trace: Move strarrays to beauty.h for further reuse perf beauty: Wire up the x86_arch prctl code table generator perf beauty: Add a string table generator for x86's 'arch_prctl' codes tools include arch: Grab a copy of x86's prctl.h perf trace: Show NULL when syscall pointer args are 0 perf trace: Enclose the errno strings with () perf augmented_raw_syscalls: Copy 'access' arg as well perf trace: Add alignment spaces after the closing parens perf trace beauty: Print O_RDONLY when (flags & O_ACCMODE) == 0 perf trace: Allow asking for not suppressing common string prefixes perf trace: Add a prefix member to the strarray class ...
2 parents 1eefdec + 883f4de commit 116b081

File tree

204 files changed

+35652
-944
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+35652
-944
lines changed

arch/x86/kernel/kprobes/core.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,12 +1026,10 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
10261026
}
10271027
NOKPROBE_SYMBOL(kprobe_fault_handler);
10281028

1029-
bool arch_within_kprobe_blacklist(unsigned long addr)
1029+
int __init arch_populate_kprobe_blacklist(void)
10301030
{
1031-
return (addr >= (unsigned long)__kprobes_text_start &&
1032-
addr < (unsigned long)__kprobes_text_end) ||
1033-
(addr >= (unsigned long)__entry_text_start &&
1034-
addr < (unsigned long)__entry_text_end);
1031+
return kprobe_add_area_blacklist((unsigned long)__entry_text_start,
1032+
(unsigned long)__entry_text_end);
10351033
}
10361034

10371035
int __init arch_init_kprobes(void)

include/linux/kprobes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,13 @@ extern int arch_init_kprobes(void);
242242
extern void show_registers(struct pt_regs *regs);
243243
extern void kprobes_inc_nmissed_count(struct kprobe *p);
244244
extern bool arch_within_kprobe_blacklist(unsigned long addr);
245+
extern int arch_populate_kprobe_blacklist(void);
245246
extern bool arch_kprobe_on_func_entry(unsigned long offset);
246247
extern bool kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset);
247248

248249
extern bool within_kprobe_blacklist(unsigned long addr);
250+
extern int kprobe_add_ksym_blacklist(unsigned long entry);
251+
extern int kprobe_add_area_blacklist(unsigned long start, unsigned long end);
249252

250253
struct kprobe_insn_cache {
251254
struct mutex mutex;

include/linux/perf_event.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ struct pmu {
262262
*/
263263
int capabilities;
264264

265-
int * __percpu pmu_disable_count;
266-
struct perf_cpu_context * __percpu pmu_cpu_context;
265+
int __percpu *pmu_disable_count;
266+
struct perf_cpu_context __percpu *pmu_cpu_context;
267267
atomic_t exclusive_cnt; /* < 0: cpu; > 0: tsk */
268268
int task_ctx_nr;
269269
int hrtimer_interval_ms;

kernel/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5541,7 +5541,7 @@ static void perf_mmap_close(struct vm_area_struct *vma)
55415541

55425542
static const struct vm_operations_struct perf_mmap_vmops = {
55435543
.open = perf_mmap_open,
5544-
.close = perf_mmap_close, /* non mergable */
5544+
.close = perf_mmap_close, /* non mergeable */
55455545
.fault = perf_mmap_fault,
55465546
.page_mkwrite = perf_mmap_fault,
55475547
};

kernel/events/hw_breakpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ __weak void arch_unregister_hw_breakpoint(struct perf_event *bp)
238238
}
239239

240240
/*
241-
* Contraints to check before allowing this new breakpoint counter:
241+
* Constraints to check before allowing this new breakpoint counter:
242242
*
243243
* == Non-pinned counter == (Considered as pinned for now)
244244
*

kernel/kprobes.c

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,47 @@ void dump_kprobe(struct kprobe *kp)
20932093
}
20942094
NOKPROBE_SYMBOL(dump_kprobe);
20952095

2096+
int kprobe_add_ksym_blacklist(unsigned long entry)
2097+
{
2098+
struct kprobe_blacklist_entry *ent;
2099+
unsigned long offset = 0, size = 0;
2100+
2101+
if (!kernel_text_address(entry) ||
2102+
!kallsyms_lookup_size_offset(entry, &size, &offset))
2103+
return -EINVAL;
2104+
2105+
ent = kmalloc(sizeof(*ent), GFP_KERNEL);
2106+
if (!ent)
2107+
return -ENOMEM;
2108+
ent->start_addr = entry;
2109+
ent->end_addr = entry + size;
2110+
INIT_LIST_HEAD(&ent->list);
2111+
list_add_tail(&ent->list, &kprobe_blacklist);
2112+
2113+
return (int)size;
2114+
}
2115+
2116+
/* Add all symbols in given area into kprobe blacklist */
2117+
int kprobe_add_area_blacklist(unsigned long start, unsigned long end)
2118+
{
2119+
unsigned long entry;
2120+
int ret = 0;
2121+
2122+
for (entry = start; entry < end; entry += ret) {
2123+
ret = kprobe_add_ksym_blacklist(entry);
2124+
if (ret < 0)
2125+
return ret;
2126+
if (ret == 0) /* In case of alias symbol */
2127+
ret = 1;
2128+
}
2129+
return 0;
2130+
}
2131+
2132+
int __init __weak arch_populate_kprobe_blacklist(void)
2133+
{
2134+
return 0;
2135+
}
2136+
20962137
/*
20972138
* Lookup and populate the kprobe_blacklist.
20982139
*
@@ -2104,26 +2145,24 @@ NOKPROBE_SYMBOL(dump_kprobe);
21042145
static int __init populate_kprobe_blacklist(unsigned long *start,
21052146
unsigned long *end)
21062147
{
2148+
unsigned long entry;
21072149
unsigned long *iter;
2108-
struct kprobe_blacklist_entry *ent;
2109-
unsigned long entry, offset = 0, size = 0;
2150+
int ret;
21102151

21112152
for (iter = start; iter < end; iter++) {
21122153
entry = arch_deref_entry_point((void *)*iter);
2113-
2114-
if (!kernel_text_address(entry) ||
2115-
!kallsyms_lookup_size_offset(entry, &size, &offset))
2154+
ret = kprobe_add_ksym_blacklist(entry);
2155+
if (ret == -EINVAL)
21162156
continue;
2117-
2118-
ent = kmalloc(sizeof(*ent), GFP_KERNEL);
2119-
if (!ent)
2120-
return -ENOMEM;
2121-
ent->start_addr = entry;
2122-
ent->end_addr = entry + size;
2123-
INIT_LIST_HEAD(&ent->list);
2124-
list_add_tail(&ent->list, &kprobe_blacklist);
2157+
if (ret < 0)
2158+
return ret;
21252159
}
2126-
return 0;
2160+
2161+
/* Symbols in __kprobes_text are blacklisted */
2162+
ret = kprobe_add_area_blacklist((unsigned long)__kprobes_text_start,
2163+
(unsigned long)__kprobes_text_end);
2164+
2165+
return ret ? : arch_populate_kprobe_blacklist();
21272166
}
21282167

21292168
/* Module notifier call back, checking kprobes on the module */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _ASM_X86_PRCTL_H
3+
#define _ASM_X86_PRCTL_H
4+
5+
#define ARCH_SET_GS 0x1001
6+
#define ARCH_SET_FS 0x1002
7+
#define ARCH_GET_FS 0x1003
8+
#define ARCH_GET_GS 0x1004
9+
10+
#define ARCH_GET_CPUID 0x1011
11+
#define ARCH_SET_CPUID 0x1012
12+
13+
#define ARCH_MAP_VDSO_X32 0x2001
14+
#define ARCH_MAP_VDSO_32 0x2002
15+
#define ARCH_MAP_VDSO_64 0x2003
16+
17+
#endif /* _ASM_X86_PRCTL_H */

tools/build/Makefile.feature

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ FEATURE_TESTS_BASIC := \
3131
backtrace \
3232
dwarf \
3333
dwarf_getlocations \
34+
eventfd \
3435
fortify-source \
3536
sync-compare-and-swap \
3637
get_current_dir_name \
@@ -69,7 +70,8 @@ FEATURE_TESTS_BASIC := \
6970
sched_getcpu \
7071
sdt \
7172
setns \
72-
libopencsd
73+
libopencsd \
74+
libaio
7375

7476
# FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
7577
# of all feature tests
@@ -115,7 +117,8 @@ FEATURE_DISPLAY ?= \
115117
zlib \
116118
lzma \
117119
get_cpuid \
118-
bpf
120+
bpf \
121+
libaio
119122

120123
# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
121124
# If in the future we need per-feature checks/flags for features not

tools/build/feature/Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ FILES= \
55
test-bionic.bin \
66
test-dwarf.bin \
77
test-dwarf_getlocations.bin \
8+
test-eventfd.bin \
89
test-fortify-source.bin \
910
test-sync-compare-and-swap.bin \
1011
test-get_current_dir_name.bin \
@@ -54,12 +55,14 @@ FILES= \
5455
test-sdt.bin \
5556
test-cxx.bin \
5657
test-jvmti.bin \
58+
test-jvmti-cmlr.bin \
5759
test-sched_getcpu.bin \
5860
test-setns.bin \
5961
test-libopencsd.bin \
6062
test-clang.bin \
6163
test-llvm.bin \
62-
test-llvm-version.bin
64+
test-llvm-version.bin \
65+
test-libaio.bin
6366

6467
FILES := $(addprefix $(OUTPUT),$(FILES))
6568

@@ -102,6 +105,9 @@ $(OUTPUT)test-bionic.bin:
102105
$(OUTPUT)test-libelf.bin:
103106
$(BUILD) -lelf
104107

108+
$(OUTPUT)test-eventfd.bin:
109+
$(BUILD)
110+
105111
$(OUTPUT)test-get_current_dir_name.bin:
106112
$(BUILD)
107113

@@ -263,6 +269,9 @@ $(OUTPUT)test-cxx.bin:
263269
$(OUTPUT)test-jvmti.bin:
264270
$(BUILD)
265271

272+
$(OUTPUT)test-jvmti-cmlr.bin:
273+
$(BUILD)
274+
266275
$(OUTPUT)test-llvm.bin:
267276
$(BUILDXX) -std=gnu++11 \
268277
-I$(shell $(LLVM_CONFIG) --includedir) \
@@ -289,6 +298,9 @@ $(OUTPUT)test-clang.bin:
289298

290299
-include $(OUTPUT)*.d
291300

301+
$(OUTPUT)test-libaio.bin:
302+
$(BUILD) -lrt
303+
292304
###############################
293305

294306
clean:

tools/build/feature/test-all.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
# include "test-dwarf_getlocations.c"
5151
#undef main
5252

53+
#define main main_test_eventfd
54+
# include "test-eventfd.c"
55+
#undef main
56+
5357
#define main main_test_libelf_getphdrnum
5458
# include "test-libelf-getphdrnum.c"
5559
#undef main
@@ -170,6 +174,10 @@
170174
# include "test-libopencsd.c"
171175
#undef main
172176

177+
#define main main_test_libaio
178+
# include "test-libaio.c"
179+
#undef main
180+
173181
int main(int argc, char *argv[])
174182
{
175183
main_test_libpython();
@@ -182,6 +190,7 @@ int main(int argc, char *argv[])
182190
main_test_glibc();
183191
main_test_dwarf();
184192
main_test_dwarf_getlocations();
193+
main_test_eventfd();
185194
main_test_libelf_getphdrnum();
186195
main_test_libelf_gelf_getnote();
187196
main_test_libelf_getshdrstrndx();
@@ -209,6 +218,7 @@ int main(int argc, char *argv[])
209218
main_test_sdt();
210219
main_test_setns();
211220
main_test_libopencsd();
221+
main_test_libaio();
212222

213223
return 0;
214224
}

tools/build/feature/test-eventfd.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
3+
4+
#include <sys/eventfd.h>
5+
6+
int main(void)
7+
{
8+
return eventfd(0, EFD_NONBLOCK);
9+
}

tools/build/feature/test-jvmti-cmlr.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <jvmti.h>
3+
#include <jvmticmlr.h>
4+
5+
int main(void)
6+
{
7+
jvmtiCompiledMethodLoadInlineRecord rec __attribute__((unused));
8+
jvmtiCompiledMethodLoadRecordHeader hdr __attribute__((unused));
9+
PCStackInfo p __attribute__((unused));
10+
return 0;
11+
}

tools/build/feature/test-jvmti.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <jvmti.h>
3-
#include <jvmticmlr.h>
43

54
int main(void)
65
{

tools/build/feature/test-libaio.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <aio.h>
3+
4+
int main(void)
5+
{
6+
struct aiocb aiocb;
7+
8+
aiocb.aio_fildes = 0;
9+
aiocb.aio_offset = 0;
10+
aiocb.aio_buf = 0;
11+
aiocb.aio_nbytes = 0;
12+
aiocb.aio_reqprio = 0;
13+
aiocb.aio_sigevent.sigev_notify = 1 /*SIGEV_NONE*/;
14+
15+
return (int)aio_return(&aiocb);
16+
}

tools/build/feature/test-libopencsd.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <opencsd/c_api/opencsd_c_api.h>
33

4+
/*
5+
* Check OpenCSD library version is sufficient to provide required features
6+
*/
7+
#define OCSD_MIN_VER ((0 << 16) | (10 << 8) | (0))
8+
#if !defined(OCSD_VER_NUM) || (OCSD_VER_NUM < OCSD_MIN_VER)
9+
#error "OpenCSD >= 0.10.0 is required"
10+
#endif
11+
412
int main(void)
513
{
614
(void)ocsd_get_version();

tools/include/linux/err.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,17 @@ static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
5959
else
6060
return 0;
6161
}
62+
63+
/**
64+
* ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
65+
* @ptr: The pointer to cast.
66+
*
67+
* Explicitly cast an error-valued pointer to another pointer type in such a
68+
* way as to make it clear that's what's going on.
69+
*/
70+
static inline void * __must_check ERR_CAST(__force const void *ptr)
71+
{
72+
/* cast away the const */
73+
return (void *) ptr;
74+
}
6275
#endif /* _LINUX_ERR_H */

tools/include/uapi/asm-generic/unistd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,10 @@ __SYSCALL(__NR_rseq, sys_rseq)
760760
#define __NR_ftruncate __NR3264_ftruncate
761761
#define __NR_lseek __NR3264_lseek
762762
#define __NR_sendfile __NR3264_sendfile
763+
#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
763764
#define __NR_newfstatat __NR3264_fstatat
764765
#define __NR_fstat __NR3264_fstat
766+
#endif
765767
#define __NR_mmap __NR3264_mmap
766768
#define __NR_fadvise64 __NR3264_fadvise64
767769
#ifdef __NR3264_stat
@@ -776,8 +778,10 @@ __SYSCALL(__NR_rseq, sys_rseq)
776778
#define __NR_ftruncate64 __NR3264_ftruncate
777779
#define __NR_llseek __NR3264_lseek
778780
#define __NR_sendfile64 __NR3264_sendfile
781+
#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
779782
#define __NR_fstatat64 __NR3264_fstatat
780783
#define __NR_fstat64 __NR3264_fstat
784+
#endif
781785
#define __NR_mmap2 __NR3264_mmap
782786
#define __NR_fadvise64_64 __NR3264_fadvise64
783787
#ifdef __NR3264_stat

0 commit comments

Comments
 (0)