Commit ce03b6d2 authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-urgent-for-mingo-4.18-20180730' of...

Merge tag 'perf-urgent-for-mingo-4.18-20180730' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

- Update the tools copy of several files, including perf_event.h,
  powerpc's asm/unistd.h (new io_pgetevents syscall), bpf.h and
  x86's memcpy_64.s (used in 'perf bench mem'), silencing the
  respective warnings during the perf tools build.

- Fix the build on the alpine:edge distro.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 156c8b58 44fe619b
...@@ -399,5 +399,6 @@ ...@@ -399,5 +399,6 @@
#define __NR_pkey_free 385 #define __NR_pkey_free 385
#define __NR_pkey_mprotect 386 #define __NR_pkey_mprotect 386
#define __NR_rseq 387 #define __NR_rseq 387
#define __NR_io_pgetevents 388
#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _MCSAFE_TEST_H_
#define _MCSAFE_TEST_H_
.macro MCSAFE_TEST_CTL
.endm
.macro MCSAFE_TEST_SRC reg count target
.endm
.macro MCSAFE_TEST_DST reg count target
.endm
#endif /* _MCSAFE_TEST_H_ */
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/errno.h> #include <asm/errno.h>
#include <asm/cpufeatures.h> #include <asm/cpufeatures.h>
#include <asm/mcsafe_test.h>
#include <asm/alternative-asm.h> #include <asm/alternative-asm.h>
#include <asm/export.h> #include <asm/export.h>
...@@ -183,12 +184,15 @@ ENTRY(memcpy_orig) ...@@ -183,12 +184,15 @@ ENTRY(memcpy_orig)
ENDPROC(memcpy_orig) ENDPROC(memcpy_orig)
#ifndef CONFIG_UML #ifndef CONFIG_UML
MCSAFE_TEST_CTL
/* /*
* memcpy_mcsafe_unrolled - memory copy with machine check exception handling * __memcpy_mcsafe - memory copy with machine check exception handling
* Note that we only catch machine checks when reading the source addresses. * Note that we only catch machine checks when reading the source addresses.
* Writes to target are posted and don't generate machine checks. * Writes to target are posted and don't generate machine checks.
*/ */
ENTRY(memcpy_mcsafe_unrolled) ENTRY(__memcpy_mcsafe)
cmpl $8, %edx cmpl $8, %edx
/* Less than 8 bytes? Go to byte copy loop */ /* Less than 8 bytes? Go to byte copy loop */
jb .L_no_whole_words jb .L_no_whole_words
...@@ -204,58 +208,33 @@ ENTRY(memcpy_mcsafe_unrolled) ...@@ -204,58 +208,33 @@ ENTRY(memcpy_mcsafe_unrolled)
subl $8, %ecx subl $8, %ecx
negl %ecx negl %ecx
subl %ecx, %edx subl %ecx, %edx
.L_copy_leading_bytes: .L_read_leading_bytes:
movb (%rsi), %al movb (%rsi), %al
MCSAFE_TEST_SRC %rsi 1 .E_leading_bytes
MCSAFE_TEST_DST %rdi 1 .E_leading_bytes
.L_write_leading_bytes:
movb %al, (%rdi) movb %al, (%rdi)
incq %rsi incq %rsi
incq %rdi incq %rdi
decl %ecx decl %ecx
jnz .L_copy_leading_bytes jnz .L_read_leading_bytes
.L_8byte_aligned: .L_8byte_aligned:
/* Figure out how many whole cache lines (64-bytes) to copy */
movl %edx, %ecx
andl $63, %edx
shrl $6, %ecx
jz .L_no_whole_cache_lines
/* Loop copying whole cache lines */
.L_cache_w0: movq (%rsi), %r8
.L_cache_w1: movq 1*8(%rsi), %r9
.L_cache_w2: movq 2*8(%rsi), %r10
.L_cache_w3: movq 3*8(%rsi), %r11
movq %r8, (%rdi)
movq %r9, 1*8(%rdi)
movq %r10, 2*8(%rdi)
movq %r11, 3*8(%rdi)
.L_cache_w4: movq 4*8(%rsi), %r8
.L_cache_w5: movq 5*8(%rsi), %r9
.L_cache_w6: movq 6*8(%rsi), %r10
.L_cache_w7: movq 7*8(%rsi), %r11
movq %r8, 4*8(%rdi)
movq %r9, 5*8(%rdi)
movq %r10, 6*8(%rdi)
movq %r11, 7*8(%rdi)
leaq 64(%rsi), %rsi
leaq 64(%rdi), %rdi
decl %ecx
jnz .L_cache_w0
/* Are there any trailing 8-byte words? */
.L_no_whole_cache_lines:
movl %edx, %ecx movl %edx, %ecx
andl $7, %edx andl $7, %edx
shrl $3, %ecx shrl $3, %ecx
jz .L_no_whole_words jz .L_no_whole_words
/* Copy trailing words */ .L_read_words:
.L_copy_trailing_words:
movq (%rsi), %r8 movq (%rsi), %r8
mov %r8, (%rdi) MCSAFE_TEST_SRC %rsi 8 .E_read_words
leaq 8(%rsi), %rsi MCSAFE_TEST_DST %rdi 8 .E_write_words
leaq 8(%rdi), %rdi .L_write_words:
movq %r8, (%rdi)
addq $8, %rsi
addq $8, %rdi
decl %ecx decl %ecx
jnz .L_copy_trailing_words jnz .L_read_words
/* Any trailing bytes? */ /* Any trailing bytes? */
.L_no_whole_words: .L_no_whole_words:
...@@ -264,38 +243,55 @@ ENTRY(memcpy_mcsafe_unrolled) ...@@ -264,38 +243,55 @@ ENTRY(memcpy_mcsafe_unrolled)
/* Copy trailing bytes */ /* Copy trailing bytes */
movl %edx, %ecx movl %edx, %ecx
.L_copy_trailing_bytes: .L_read_trailing_bytes:
movb (%rsi), %al movb (%rsi), %al
MCSAFE_TEST_SRC %rsi 1 .E_trailing_bytes
MCSAFE_TEST_DST %rdi 1 .E_trailing_bytes
.L_write_trailing_bytes:
movb %al, (%rdi) movb %al, (%rdi)
incq %rsi incq %rsi
incq %rdi incq %rdi
decl %ecx decl %ecx
jnz .L_copy_trailing_bytes jnz .L_read_trailing_bytes
/* Copy successful. Return zero */ /* Copy successful. Return zero */
.L_done_memcpy_trap: .L_done_memcpy_trap:
xorq %rax, %rax xorq %rax, %rax
ret ret
ENDPROC(memcpy_mcsafe_unrolled) ENDPROC(__memcpy_mcsafe)
EXPORT_SYMBOL_GPL(memcpy_mcsafe_unrolled) EXPORT_SYMBOL_GPL(__memcpy_mcsafe)
.section .fixup, "ax" .section .fixup, "ax"
/* Return -EFAULT for any failure */ /*
.L_memcpy_mcsafe_fail: * Return number of bytes not copied for any failure. Note that
mov $-EFAULT, %rax * there is no "tail" handling since the source buffer is 8-byte
* aligned and poison is cacheline aligned.
*/
.E_read_words:
shll $3, %ecx
.E_leading_bytes:
addl %edx, %ecx
.E_trailing_bytes:
mov %ecx, %eax
ret ret
/*
* For write fault handling, given the destination is unaligned,
* we handle faults on multi-byte writes with a byte-by-byte
* copy up to the write-protected page.
*/
.E_write_words:
shll $3, %ecx
addl %edx, %ecx
movl %ecx, %edx
jmp mcsafe_handle_tail
.previous .previous
_ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_read_leading_bytes, .E_leading_bytes)
_ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_read_words, .E_read_words)
_ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_read_trailing_bytes, .E_trailing_bytes)
_ASM_EXTABLE_FAULT(.L_cache_w2, .L_memcpy_mcsafe_fail) _ASM_EXTABLE(.L_write_leading_bytes, .E_leading_bytes)
_ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) _ASM_EXTABLE(.L_write_words, .E_write_words)
_ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail) _ASM_EXTABLE(.L_write_trailing_bytes, .E_trailing_bytes)
_ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail)
_ASM_EXTABLE_FAULT(.L_cache_w6, .L_memcpy_mcsafe_fail)
_ASM_EXTABLE_FAULT(.L_cache_w7, .L_memcpy_mcsafe_fail)
_ASM_EXTABLE_FAULT(.L_copy_trailing_words, .L_memcpy_mcsafe_fail)
_ASM_EXTABLE_FAULT(.L_copy_trailing_bytes, .L_memcpy_mcsafe_fail)
#endif #endif
...@@ -1857,7 +1857,8 @@ union bpf_attr { ...@@ -1857,7 +1857,8 @@ union bpf_attr {
* is resolved), the nexthop address is returned in ipv4_dst * is resolved), the nexthop address is returned in ipv4_dst
* or ipv6_dst based on family, smac is set to mac address of * or ipv6_dst based on family, smac is set to mac address of
* egress device, dmac is set to nexthop mac address, rt_metric * egress device, dmac is set to nexthop mac address, rt_metric
* is set to metric from route (IPv4/IPv6 only). * is set to metric from route (IPv4/IPv6 only), and ifindex
* is set to the device index of the nexthop from the FIB lookup.
* *
* *plen* argument is the size of the passed in struct. * *plen* argument is the size of the passed in struct.
* *flags* argument can be a combination of one or more of the * *flags* argument can be a combination of one or more of the
...@@ -1873,9 +1874,10 @@ union bpf_attr { ...@@ -1873,9 +1874,10 @@ union bpf_attr {
* *ctx* is either **struct xdp_md** for XDP programs or * *ctx* is either **struct xdp_md** for XDP programs or
* **struct sk_buff** tc cls_act programs. * **struct sk_buff** tc cls_act programs.
* Return * Return
* Egress device index on success, 0 if packet needs to continue * * < 0 if any input argument is invalid
* up the stack for further processing or a negative error in case * * 0 on success (packet is forwarded, nexthop neighbor exists)
* of failure. * * > 0 one of **BPF_FIB_LKUP_RET_** codes explaining why the
* * packet is not forwarded or needs assist from full stack
* *
* int bpf_sock_hash_update(struct bpf_sock_ops_kern *skops, struct bpf_map *map, void *key, u64 flags) * int bpf_sock_hash_update(struct bpf_sock_ops_kern *skops, struct bpf_map *map, void *key, u64 flags)
* Description * Description
...@@ -2612,6 +2614,18 @@ struct bpf_raw_tracepoint_args { ...@@ -2612,6 +2614,18 @@ struct bpf_raw_tracepoint_args {
#define BPF_FIB_LOOKUP_DIRECT BIT(0) #define BPF_FIB_LOOKUP_DIRECT BIT(0)
#define BPF_FIB_LOOKUP_OUTPUT BIT(1) #define BPF_FIB_LOOKUP_OUTPUT BIT(1)
enum {
BPF_FIB_LKUP_RET_SUCCESS, /* lookup successful */
BPF_FIB_LKUP_RET_BLACKHOLE, /* dest is blackholed; can be dropped */
BPF_FIB_LKUP_RET_UNREACHABLE, /* dest is unreachable; can be dropped */
BPF_FIB_LKUP_RET_PROHIBIT, /* dest not allowed; can be dropped */
BPF_FIB_LKUP_RET_NOT_FWDED, /* packet is not forwarded */
BPF_FIB_LKUP_RET_FWD_DISABLED, /* fwding is not enabled on ingress */
BPF_FIB_LKUP_RET_UNSUPP_LWT, /* fwd requires encapsulation */
BPF_FIB_LKUP_RET_NO_NEIGH, /* no neighbor entry for nh */
BPF_FIB_LKUP_RET_FRAG_NEEDED, /* fragmentation required to fwd */
};
struct bpf_fib_lookup { struct bpf_fib_lookup {
/* input: network family for lookup (AF_INET, AF_INET6) /* input: network family for lookup (AF_INET, AF_INET6)
* output: network family of egress nexthop * output: network family of egress nexthop
...@@ -2625,7 +2639,11 @@ struct bpf_fib_lookup { ...@@ -2625,7 +2639,11 @@ struct bpf_fib_lookup {
/* total length of packet from network header - used for MTU check */ /* total length of packet from network header - used for MTU check */
__u16 tot_len; __u16 tot_len;
__u32 ifindex; /* L3 device index for lookup */
/* input: L3 device index for lookup
* output: device index from FIB lookup
*/
__u32 ifindex;
union { union {
/* inputs to lookup */ /* inputs to lookup */
......
...@@ -143,6 +143,8 @@ enum perf_event_sample_format { ...@@ -143,6 +143,8 @@ enum perf_event_sample_format {
PERF_SAMPLE_PHYS_ADDR = 1U << 19, PERF_SAMPLE_PHYS_ADDR = 1U << 19,
PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */ PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */
__PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63,
}; };
/* /*
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <string.h> #include <string.h>
#include <linux/stddef.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include "../../util/intel-pt.h" #include "../../util/intel-pt.h"
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <errno.h> #include <errno.h>
#include <linux/stddef.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include "../../perf.h" #include "../../perf.h"
......
...@@ -7,6 +7,7 @@ perf-y += futex-wake-parallel.o ...@@ -7,6 +7,7 @@ perf-y += futex-wake-parallel.o
perf-y += futex-requeue.o perf-y += futex-requeue.o
perf-y += futex-lock-pi.o perf-y += futex-lock-pi.o
perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-lib.o
perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o
perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define altinstr_replacement text #define altinstr_replacement text
#define globl p2align 4; .globl #define globl p2align 4; .globl
#define _ASM_EXTABLE_FAULT(x, y) #define _ASM_EXTABLE_FAULT(x, y)
#define _ASM_EXTABLE(x, y)
#include "../../arch/x86/lib/memcpy_64.S" #include "../../arch/x86/lib/memcpy_64.S"
/* /*
......
/*
* From code in arch/x86/lib/usercopy_64.c, copied to keep tools/ copy
* of the kernel's arch/x86/lib/memcpy_64.s used in 'perf bench mem memcpy'
* happy.
*/
#include <linux/types.h>
unsigned long __memcpy_mcsafe(void *dst, const void *src, size_t cnt);
unsigned long mcsafe_handle_tail(char *to, char *from, unsigned len);
unsigned long mcsafe_handle_tail(char *to, char *from, unsigned len)
{
for (; len; --len, to++, from++) {
/*
* Call the assembly routine back directly since
* memcpy_mcsafe() may silently fallback to memcpy.
*/
unsigned long rem = __memcpy_mcsafe(to, from, 1);
if (rem)
break;
}
return len;
}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <time.h> #include <time.h>
#include <stdbool.h> #include <stdbool.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/stddef.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
extern bool test_attr__enabled; extern bool test_attr__enabled;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#ifndef __PERF_HEADER_H #ifndef __PERF_HEADER_H
#define __PERF_HEADER_H #define __PERF_HEADER_H
#include <linux/stddef.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdbool.h> #include <stdbool.h>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define __PERF_NAMESPACES_H #define __PERF_NAMESPACES_H
#include <sys/types.h> #include <sys/types.h>
#include <linux/stddef.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <linux/types.h> #include <linux/types.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment