Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Ingo writes:
"perf fixes:
- fix a CPU#0 hot unplug bug and a PCI enumeration bug in the x86 Intel uncore PMU driver
- fix a CPU event enumeration bug in the x86 AMD PMU driver
- fix a perf ring-buffer corruption bug when using tracepoints
- fix a PMU unregister locking bug"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf/x86/amd/uncore: Set ThreadMask and SliceMask for L3 Cache perf events
perf/x86/intel/uncore: Fix PCI BDF address of M3UPI on SKX
perf/ring_buffer: Prevent concurent ring buffer access
perf/x86/intel/uncore: Use boot_cpu_data.phys_proc_id instead of hardcorded physical package ID 0
perf/core: Fix perf_pmu_unregister() locking

+29 -14
+10
arch/x86/events/amd/uncore.c
··· 36 36 37 37 static int num_counters_llc; 38 38 static int num_counters_nb; 39 + static bool l3_mask; 39 40 40 41 static HLIST_HEAD(uncore_unused_list); 41 42 ··· 209 208 /* and we do not enable counter overflow interrupts */ 210 209 hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; 211 210 hwc->idx = -1; 211 + 212 + /* 213 + * SliceMask and ThreadMask need to be set for certain L3 events in 214 + * Family 17h. For other events, the two fields do not affect the count. 215 + */ 216 + if (l3_mask) 217 + hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK); 212 218 213 219 if (event->cpu < 0) 214 220 return -EINVAL; ··· 533 525 amd_llc_pmu.name = "amd_l3"; 534 526 format_attr_event_df.show = &event_show_df; 535 527 format_attr_event_l3.show = &event_show_l3; 528 + l3_mask = true; 536 529 } else { 537 530 num_counters_nb = NUM_COUNTERS_NB; 538 531 num_counters_llc = NUM_COUNTERS_L2; ··· 541 532 amd_llc_pmu.name = "amd_l2"; 542 533 format_attr_event_df = format_attr_event; 543 534 format_attr_event_l3 = format_attr_event; 535 + l3_mask = false; 544 536 } 545 537 546 538 amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df;
+7 -7
arch/x86/events/intel/uncore_snbep.c
··· 3061 3061 3062 3062 void bdx_uncore_cpu_init(void) 3063 3063 { 3064 - int pkg = topology_phys_to_logical_pkg(0); 3064 + int pkg = topology_phys_to_logical_pkg(boot_cpu_data.phys_proc_id); 3065 3065 3066 3066 if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) 3067 3067 bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; ··· 3931 3931 .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3), 3932 3932 }, 3933 3933 { /* M3UPI0 Link 0 */ 3934 - PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), 3935 - .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 0, SKX_PCI_UNCORE_M3UPI, 0), 3934 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), 3935 + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 0), 3936 3936 }, 3937 3937 { /* M3UPI0 Link 1 */ 3938 - PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), 3939 - .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 1), 3938 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204E), 3939 + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 2, SKX_PCI_UNCORE_M3UPI, 1), 3940 3940 }, 3941 3941 { /* M3UPI1 Link 2 */ 3942 - PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), 3943 - .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 4, SKX_PCI_UNCORE_M3UPI, 2), 3942 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), 3943 + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 5, SKX_PCI_UNCORE_M3UPI, 2), 3944 3944 }, 3945 3945 { /* end: all zeroes */ } 3946 3946 };
+8
arch/x86/include/asm/perf_event.h
··· 46 46 #define INTEL_ARCH_EVENT_MASK \ 47 47 (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT) 48 48 49 + #define AMD64_L3_SLICE_SHIFT 48 50 + #define AMD64_L3_SLICE_MASK \ 51 + ((0xFULL) << AMD64_L3_SLICE_SHIFT) 52 + 53 + #define AMD64_L3_THREAD_SHIFT 56 54 + #define AMD64_L3_THREAD_MASK \ 55 + ((0xFFULL) << AMD64_L3_THREAD_SHIFT) 56 + 49 57 #define X86_RAW_EVENT_MASK \ 50 58 (ARCH_PERFMON_EVENTSEL_EVENT | \ 51 59 ARCH_PERFMON_EVENTSEL_UMASK | \
+4 -7
kernel/events/core.c
··· 8314 8314 goto unlock; 8315 8315 8316 8316 list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { 8317 + if (event->cpu != smp_processor_id()) 8318 + continue; 8317 8319 if (event->attr.type != PERF_TYPE_TRACEPOINT) 8318 8320 continue; 8319 8321 if (event->attr.config != entry->type) ··· 9433 9431 if (pmu->task_ctx_nr > perf_invalid_context) 9434 9432 return; 9435 9433 9436 - mutex_lock(&pmus_lock); 9437 9434 free_percpu(pmu->pmu_cpu_context); 9438 - mutex_unlock(&pmus_lock); 9439 9435 } 9440 9436 9441 9437 /* ··· 9689 9689 9690 9690 void perf_pmu_unregister(struct pmu *pmu) 9691 9691 { 9692 - int remove_device; 9693 - 9694 9692 mutex_lock(&pmus_lock); 9695 - remove_device = pmu_bus_running; 9696 9693 list_del_rcu(&pmu->entry); 9697 - mutex_unlock(&pmus_lock); 9698 9694 9699 9695 /* 9700 9696 * We dereference the pmu list under both SRCU and regular RCU, so ··· 9702 9706 free_percpu(pmu->pmu_disable_count); 9703 9707 if (pmu->type >= PERF_TYPE_MAX) 9704 9708 idr_remove(&pmu_idr, pmu->type); 9705 - if (remove_device) { 9709 + if (pmu_bus_running) { 9706 9710 if (pmu->nr_addr_filters) 9707 9711 device_remove_file(pmu->dev, &dev_attr_nr_addr_filters); 9708 9712 device_del(pmu->dev); 9709 9713 put_device(pmu->dev); 9710 9714 } 9711 9715 free_pmu_context(pmu); 9716 + mutex_unlock(&pmus_lock); 9712 9717 } 9713 9718 EXPORT_SYMBOL_GPL(perf_pmu_unregister); 9714 9719