1
0
Fork 0

perf/urgent fixes:

core:
 
   Arnaldo Carvalho de Melo:
 
   - Allow references to thread objects after__machine_exit(), fixing a bug with
     'perf sched lat' where that happens, i.e. after perf_session__delete() we
     still have references to threads that were in a linked list whose head was
     freed in perf_session__delete(), causing a segfault, fix it.
 
   Jiri Olsa:
 
   - Do not rely on errno values for precise_ip fallback, fixing the default
     use case for 'perf record' on some AMD servers, when no events are specified
     and we try to use "cycles:P", i.e. with the maximum precision level.
 
 BPF:
 
   Song Liu:
 
   - Assign proper ff->ph in perf_event__synthesize_features(), fixing a bug
     when using pipe mode, i.e.  'perf record -o -'.
 
 tools headers:
 
   Arnaldo Carvalho de Melo:
 
   - Sync kvm headers with the kernel sources
 
 perf tests:
 
   Seeteena Thoufeek:
 
   - Fix record+probe_libc_inet_pton.sh for powerpc64, where without the
     debuginfo package for the 'ping' utility we can't resolve its symbols,
     so admit getting "[unknown]" for that backtrace line.
 
 perf python:
 
   Arnaldo Carvalho de Melo:
 
   - Remove -fstack-protector-strong if clang doesn't have it, fixing the build
     with clang on fedora:30, oracleline:7, centos:7.
 
 perf jvmti:
 
   Jiri Olsa:
 
   - Address gcc string overflow warning for strncpy()
 
 build:
 
   Arnaldo Carvalho de Melo:
 
   - Check if gettid() is available before providing helper, as recent
     versions of glibc started to provide gettid().
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQR2GiIUctdOfX2qHhGyPKLppCJ+JwUCXSO5bQAKCRCyPKLppCJ+
 J5QdAP9RYkXC7b5FoJ2p0ZpDraDETHktYf1tXcQm1ViwtBoGJQD+JjW61UIJpO8J
 M4qeyCa6lYuxeualIH+aJA0+IQhilAs=
 =WRXE
 -----END PGP SIGNATURE-----

Merge tag 'perf-urgent-for-mingo-5.3-20190708-2' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

core:

  Arnaldo Carvalho de Melo:

  - Allow references to thread objects after__machine_exit(), fixing a bug with
    'perf sched lat' where that happens, i.e. after perf_session__delete() we
    still have references to threads that were in a linked list whose head was
    freed in perf_session__delete(), causing a segfault, fix it.

  Jiri Olsa:

  - Do not rely on errno values for precise_ip fallback, fixing the default
    use case for 'perf record' on some AMD servers, when no events are specified
    and we try to use "cycles:P", i.e. with the maximum precision level.

BPF:

  Song Liu:

  - Assign proper ff->ph in perf_event__synthesize_features(), fixing a bug
    when using pipe mode, i.e.  'perf record -o -'.

tools headers:

  Arnaldo Carvalho de Melo:

  - Sync kvm headers with the kernel sources

perf tests:

  Seeteena Thoufeek:

  - Fix record+probe_libc_inet_pton.sh for powerpc64, where without the
    debuginfo package for the 'ping' utility we can't resolve its symbols,
    so admit getting "[unknown]" for that backtrace line.

perf python:

  Arnaldo Carvalho de Melo:

  - Remove -fstack-protector-strong if clang doesn't have it, fixing the build
    with clang on fedora:30, oracleline:7, centos:7.

perf jvmti:

  Jiri Olsa:

  - Address gcc string overflow warning for strncpy()

build:

  Arnaldo Carvalho de Melo:

  - Check if gettid() is available before providing helper, as recent
    versions of glibc started to provide gettid().

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
alistair/sunxi64-5.4-dsi
Ingo Molnar 2019-07-09 13:22:03 +02:00
commit d1d59b8179
8 changed files with 90 additions and 30 deletions

View File

@ -260,6 +260,13 @@ struct kvm_vcpu_events {
KVM_REG_SIZE_U256 | \
((i) & (KVM_ARM64_SVE_MAX_SLICES - 1)))
/*
* Register values for KVM_REG_ARM64_SVE_ZREG(), KVM_REG_ARM64_SVE_PREG() and
* KVM_REG_ARM64_SVE_FFR() are represented in memory in an endianness-
* invariant layout which differs from the layout used for the FPSIMD
* V-registers on big-endian systems: see sigcontext.h for more explanation.
*/
#define KVM_ARM64_SVE_VQ_MIN __SVE_VQ_MIN
#define KVM_ARM64_SVE_VQ_MAX __SVE_VQ_MAX

View File

@ -239,12 +239,14 @@
#define X86_FEATURE_BMI1 ( 9*32+ 3) /* 1st group bit manipulation extensions */
#define X86_FEATURE_HLE ( 9*32+ 4) /* Hardware Lock Elision */
#define X86_FEATURE_AVX2 ( 9*32+ 5) /* AVX2 instructions */
#define X86_FEATURE_FDP_EXCPTN_ONLY ( 9*32+ 6) /* "" FPU data pointer updated only on x87 exceptions */
#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Protection */
#define X86_FEATURE_BMI2 ( 9*32+ 8) /* 2nd group bit manipulation extensions */
#define X86_FEATURE_ERMS ( 9*32+ 9) /* Enhanced REP MOVSB/STOSB instructions */
#define X86_FEATURE_INVPCID ( 9*32+10) /* Invalidate Processor Context ID */
#define X86_FEATURE_RTM ( 9*32+11) /* Restricted Transactional Memory */
#define X86_FEATURE_CQM ( 9*32+12) /* Cache QoS Monitoring */
#define X86_FEATURE_ZERO_FCS_FDS ( 9*32+13) /* "" Zero out FPU CS and FPU DS */
#define X86_FEATURE_MPX ( 9*32+14) /* Memory Protection Extension */
#define X86_FEATURE_RDT_A ( 9*32+15) /* Resource Director Technology Allocation */
#define X86_FEATURE_AVX512F ( 9*32+16) /* AVX-512 Foundation */
@ -269,13 +271,19 @@
#define X86_FEATURE_XGETBV1 (10*32+ 2) /* XGETBV with ECX = 1 instruction */
#define X86_FEATURE_XSAVES (10*32+ 3) /* XSAVES/XRSTORS instructions */
/* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:0 (EDX), word 11 */
#define X86_FEATURE_CQM_LLC (11*32+ 1) /* LLC QoS if 1 */
/*
* Extended auxiliary flags: Linux defined - for features scattered in various
* CPUID levels like 0xf, etc.
*
* Reuse free bits when adding new feature flags!
*/
#define X86_FEATURE_CQM_LLC (11*32+ 0) /* LLC QoS if 1 */
#define X86_FEATURE_CQM_OCCUP_LLC (11*32+ 1) /* LLC occupancy monitoring */
#define X86_FEATURE_CQM_MBM_TOTAL (11*32+ 2) /* LLC Total MBM monitoring */
#define X86_FEATURE_CQM_MBM_LOCAL (11*32+ 3) /* LLC Local MBM monitoring */
/* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:1 (EDX), word 12 */
#define X86_FEATURE_CQM_OCCUP_LLC (12*32+ 0) /* LLC occupancy monitoring */
#define X86_FEATURE_CQM_MBM_TOTAL (12*32+ 1) /* LLC Total MBM monitoring */
#define X86_FEATURE_CQM_MBM_LOCAL (12*32+ 2) /* LLC Local MBM monitoring */
/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
#define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */
/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
@ -322,6 +330,7 @@
#define X86_FEATURE_UMIP (16*32+ 2) /* User Mode Instruction Protection */
#define X86_FEATURE_PKU (16*32+ 3) /* Protection Keys for Userspace */
#define X86_FEATURE_OSPKE (16*32+ 4) /* OS Protection Keys Enable */
#define X86_FEATURE_WAITPKG (16*32+ 5) /* UMONITOR/UMWAIT/TPAUSE Instructions */
#define X86_FEATURE_AVX512_VBMI2 (16*32+ 6) /* Additional AVX512 Vector Bit Manipulation Instructions */
#define X86_FEATURE_GFNI (16*32+ 8) /* Galois Field New Instructions */
#define X86_FEATURE_VAES (16*32+ 9) /* Vector AES */

View File

@ -383,6 +383,9 @@ struct kvm_sync_regs {
#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2)
#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3)
#define KVM_STATE_NESTED_FORMAT_VMX 0
#define KVM_STATE_NESTED_FORMAT_SVM 1 /* unused */
#define KVM_STATE_NESTED_GUEST_MODE 0x00000001
#define KVM_STATE_NESTED_RUN_PENDING 0x00000002
#define KVM_STATE_NESTED_EVMCS 0x00000004
@ -390,7 +393,14 @@ struct kvm_sync_regs {
#define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001
#define KVM_STATE_NESTED_SMM_VMXON 0x00000002
struct kvm_vmx_nested_state {
#define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000
struct kvm_vmx_nested_state_data {
__u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
__u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
};
struct kvm_vmx_nested_state_hdr {
__u64 vmxon_pa;
__u64 vmcs12_pa;
@ -401,24 +411,25 @@ struct kvm_vmx_nested_state {
/* for KVM_CAP_NESTED_STATE */
struct kvm_nested_state {
/* KVM_STATE_* flags */
__u16 flags;
/* 0 for VMX, 1 for SVM. */
__u16 format;
/* 128 for SVM, 128 + VMCS size for VMX. */
__u32 size;
union {
/* VMXON, VMCS */
struct kvm_vmx_nested_state vmx;
struct kvm_vmx_nested_state_hdr vmx;
/* Pad the header to 128 bytes. */
__u8 pad[120];
};
} hdr;
__u8 data[0];
/*
* Define data region as 0 bytes to preserve backwards-compatability
* to old definition of kvm_nested_state in order to avoid changing
* KVM_{GET,PUT}_NESTED_STATE ioctl values.
*/
union {
struct kvm_vmx_nested_state_data vmx[0];
} data;
};
#endif /* _ASM_X86_KVM_H */

View File

@ -45,7 +45,7 @@ trace_libc_inet_pton_backtrace() {
eventattr='max-stack=4'
echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected
echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected
echo ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected
echo ".*(\+0x[[:xdigit:]]+|\[unknown\])[[:space:]]\(.*/bin/ping.*\)$" >> $expected
;;
*)
eventattr='max-stack=3'

View File

@ -1800,14 +1800,8 @@ static int perf_event_open(struct perf_evsel *evsel,
if (fd >= 0)
break;
/*
* Do quick precise_ip fallback if:
* - there is precise_ip set in perf_event_attr
* - maximum precise is requested
* - sys_perf_event_open failed with ENOTSUP error,
* which is associated with wrong precise_ip
*/
if (!precise_ip || !evsel->precise_max || (errno != ENOTSUP))
/* Do not try less precise if not requested. */
if (!evsel->precise_max)
break;
/*

View File

@ -3683,6 +3683,7 @@ int perf_event__synthesize_features(struct perf_tool *tool,
return -ENOMEM;
ff.size = sz - sz_hdr;
ff.ph = &session->header;
for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) {
if (!feat_ops[feat].synthesize) {

View File

@ -210,6 +210,18 @@ void machine__exit(struct machine *machine)
for (i = 0; i < THREADS__TABLE_SIZE; i++) {
struct threads *threads = &machine->threads[i];
struct thread *thread, *n;
/*
* Forget about the dead, at this point whatever threads were
* left in the dead lists better have a reference count taken
* by who is using them, and then, when they drop those references
* and it finally hits zero, thread__put() will check and see that
* its not in the dead threads list and will not try to remove it
* from there, just calling thread__delete() straight away.
*/
list_for_each_entry_safe(thread, n, &threads->dead, node)
list_del_init(&thread->node);
exit_rwsem(&threads->lock);
}
}
@ -1759,9 +1771,11 @@ static void __machine__remove_thread(struct machine *machine, struct thread *th,
if (threads->last_match == th)
threads__set_last_match(threads, NULL);
BUG_ON(refcount_read(&th->refcnt) == 0);
if (lock)
down_write(&threads->lock);
BUG_ON(refcount_read(&th->refcnt) == 0);
rb_erase_cached(&th->rb_node, &threads->entries);
RB_CLEAR_NODE(&th->rb_node);
--threads->nr;
@ -1771,9 +1785,16 @@ static void __machine__remove_thread(struct machine *machine, struct thread *th,
* will be called and we will remove it from the dead_threads list.
*/
list_add_tail(&th->node, &threads->dead);
/*
* We need to do the put here because if this is the last refcount,
* then we will be touching the threads->dead head when removing the
* thread.
*/
thread__put(th);
if (lock)
up_write(&threads->lock);
thread__put(th);
}
void machine__remove_thread(struct machine *machine, struct thread *th)

View File

@ -125,10 +125,27 @@ void thread__put(struct thread *thread)
{
if (thread && refcount_dec_and_test(&thread->refcnt)) {
/*
* Remove it from the dead_threads list, as last reference
* is gone.
* Remove it from the dead threads list, as last reference is
* gone, if it is in a dead threads list.
*
* We may not be there anymore if say, the machine where it was
* stored was already deleted, so we already removed it from
* the dead threads and some other piece of code still keeps a
* reference.
*
* This is what 'perf sched' does and finally drops it in
* perf_sched__lat(), where it calls perf_sched__read_events(),
* that processes the events by creating a session and deleting
* it, which ends up destroying the list heads for the dead
* threads, but before it does that it removes all threads from
* it using list_del_init().
*
* So we need to check here if it is in a dead threads list and
* if so, remove it before finally deleting the thread, to avoid
* an use after free situation.
*/
list_del_init(&thread->node);
if (!list_empty(&thread->node))
list_del_init(&thread->node);
thread__delete(thread);
}
}