aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-05 19:07:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-05 19:07:13 -0400
commit31d099085d5415a073b52358a5fc61d50e9ab614 (patch)
tree813eb23d211235e96db942c2dcdf218fc4b030b9
parent247373b5dd685fd307d2ea7fd0e58353486e4ad4 (diff)
parentd7cbbe49a9304520181fb8c9272d1327deec8453 (diff)
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
-rw-r--r--arch/x86/events/amd/uncore.c10
-rw-r--r--arch/x86/events/intel/uncore_snbep.c14
-rw-r--r--arch/x86/include/asm/perf_event.h8
-rw-r--r--kernel/events/core.c11
4 files changed, 29 insertions, 14 deletions
diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c
index 981ba5e8241b..8671de126eac 100644
--- a/arch/x86/events/amd/uncore.c
+++ b/arch/x86/events/amd/uncore.c
@@ -36,6 +36,7 @@
36 36
37static int num_counters_llc; 37static int num_counters_llc;
38static int num_counters_nb; 38static int num_counters_nb;
39static bool l3_mask;
39 40
40static HLIST_HEAD(uncore_unused_list); 41static HLIST_HEAD(uncore_unused_list);
41 42
@@ -209,6 +210,13 @@ static int amd_uncore_event_init(struct perf_event *event)
209 hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; 210 hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB;
210 hwc->idx = -1; 211 hwc->idx = -1;
211 212
213 /*
214 * SliceMask and ThreadMask need to be set for certain L3 events in
215 * Family 17h. For other events, the two fields do not affect the count.
216 */
217 if (l3_mask)
218 hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK);
219
212 if (event->cpu < 0) 220 if (event->cpu < 0)
213 return -EINVAL; 221 return -EINVAL;
214 222
@@ -525,6 +533,7 @@ static int __init amd_uncore_init(void)
525 amd_llc_pmu.name = "amd_l3"; 533 amd_llc_pmu.name = "amd_l3";
526 format_attr_event_df.show = &event_show_df; 534 format_attr_event_df.show = &event_show_df;
527 format_attr_event_l3.show = &event_show_l3; 535 format_attr_event_l3.show = &event_show_l3;
536 l3_mask = true;
528 } else { 537 } else {
529 num_counters_nb = NUM_COUNTERS_NB; 538 num_counters_nb = NUM_COUNTERS_NB;
530 num_counters_llc = NUM_COUNTERS_L2; 539 num_counters_llc = NUM_COUNTERS_L2;
@@ -532,6 +541,7 @@ static int __init amd_uncore_init(void)
532 amd_llc_pmu.name = "amd_l2"; 541 amd_llc_pmu.name = "amd_l2";
533 format_attr_event_df = format_attr_event; 542 format_attr_event_df = format_attr_event;
534 format_attr_event_l3 = format_attr_event; 543 format_attr_event_l3 = format_attr_event;
544 l3_mask = false;
535 } 545 }
536 546
537 amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df; 547 amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df;
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index 51d7c117e3c7..c07bee31abe8 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -3061,7 +3061,7 @@ static struct event_constraint bdx_uncore_pcu_constraints[] = {
3061 3061
3062void bdx_uncore_cpu_init(void) 3062void 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 if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) 3066 if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)
3067 bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; 3067 bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;
@@ -3931,16 +3931,16 @@ static const struct pci_device_id skx_uncore_pci_ids[] = {
3931 .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3), 3931 .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3),
3932 }, 3932 },
3933 { /* M3UPI0 Link 0 */ 3933 { /* M3UPI0 Link 0 */
3934 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), 3934 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
3935 .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 0, SKX_PCI_UNCORE_M3UPI, 0), 3935 .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 0),
3936 }, 3936 },
3937 { /* M3UPI0 Link 1 */ 3937 { /* M3UPI0 Link 1 */
3938 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), 3938 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204E),
3939 .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 1), 3939 .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 2, SKX_PCI_UNCORE_M3UPI, 1),
3940 }, 3940 },
3941 { /* M3UPI1 Link 2 */ 3941 { /* M3UPI1 Link 2 */
3942 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), 3942 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
3943 .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 4, SKX_PCI_UNCORE_M3UPI, 2), 3943 .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 5, SKX_PCI_UNCORE_M3UPI, 2),
3944 }, 3944 },
3945 { /* end: all zeroes */ } 3945 { /* end: all zeroes */ }
3946}; 3946};
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index 12f54082f4c8..78241b736f2a 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -46,6 +46,14 @@
46#define INTEL_ARCH_EVENT_MASK \ 46#define INTEL_ARCH_EVENT_MASK \
47 (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT) 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#define X86_RAW_EVENT_MASK \ 57#define X86_RAW_EVENT_MASK \
50 (ARCH_PERFMON_EVENTSEL_EVENT | \ 58 (ARCH_PERFMON_EVENTSEL_EVENT | \
51 ARCH_PERFMON_EVENTSEL_UMASK | \ 59 ARCH_PERFMON_EVENTSEL_UMASK | \
diff --git a/kernel/events/core.c b/kernel/events/core.c
index dcb093e7b377..5a97f34bc14c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8314,6 +8314,8 @@ void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size,
8314 goto unlock; 8314 goto unlock;
8315 8315
8316 list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { 8316 list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
8317 if (event->cpu != smp_processor_id())
8318 continue;
8317 if (event->attr.type != PERF_TYPE_TRACEPOINT) 8319 if (event->attr.type != PERF_TYPE_TRACEPOINT)
8318 continue; 8320 continue;
8319 if (event->attr.config != entry->type) 8321 if (event->attr.config != entry->type)
@@ -9431,9 +9433,7 @@ static void free_pmu_context(struct pmu *pmu)
9431 if (pmu->task_ctx_nr > perf_invalid_context) 9433 if (pmu->task_ctx_nr > perf_invalid_context)
9432 return; 9434 return;
9433 9435
9434 mutex_lock(&pmus_lock);
9435 free_percpu(pmu->pmu_cpu_context); 9436 free_percpu(pmu->pmu_cpu_context);
9436 mutex_unlock(&pmus_lock);
9437} 9437}
9438 9438
9439/* 9439/*
@@ -9689,12 +9689,8 @@ EXPORT_SYMBOL_GPL(perf_pmu_register);
9689 9689
9690void perf_pmu_unregister(struct pmu *pmu) 9690void perf_pmu_unregister(struct pmu *pmu)
9691{ 9691{
9692 int remove_device;
9693
9694 mutex_lock(&pmus_lock); 9692 mutex_lock(&pmus_lock);
9695 remove_device = pmu_bus_running;
9696 list_del_rcu(&pmu->entry); 9693 list_del_rcu(&pmu->entry);
9697 mutex_unlock(&pmus_lock);
9698 9694
9699 /* 9695 /*
9700 * We dereference the pmu list under both SRCU and regular RCU, so 9696 * We dereference the pmu list under both SRCU and regular RCU, so
@@ -9706,13 +9702,14 @@ void perf_pmu_unregister(struct pmu *pmu)
9706 free_percpu(pmu->pmu_disable_count); 9702 free_percpu(pmu->pmu_disable_count);
9707 if (pmu->type >= PERF_TYPE_MAX) 9703 if (pmu->type >= PERF_TYPE_MAX)
9708 idr_remove(&pmu_idr, pmu->type); 9704 idr_remove(&pmu_idr, pmu->type);
9709 if (remove_device) { 9705 if (pmu_bus_running) {
9710 if (pmu->nr_addr_filters) 9706 if (pmu->nr_addr_filters)
9711 device_remove_file(pmu->dev, &dev_attr_nr_addr_filters); 9707 device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
9712 device_del(pmu->dev); 9708 device_del(pmu->dev);
9713 put_device(pmu->dev); 9709 put_device(pmu->dev);
9714 } 9710 }
9715 free_pmu_context(pmu); 9711 free_pmu_context(pmu);
9712 mutex_unlock(&pmus_lock);
9716} 9713}
9717EXPORT_SYMBOL_GPL(perf_pmu_unregister); 9714EXPORT_SYMBOL_GPL(perf_pmu_unregister);
9718 9715