aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorYan, Zheng <zheng.z.yan@intel.com>2014-09-04 19:08:27 -0400
committerIngo Molnar <mingo@kernel.org>2014-09-24 08:48:22 -0400
commit513d793e5fe138d779ad6c532cd20c289a6897fc (patch)
tree4a95b41c4e2296366f2ad16aa6ff20ecb3eaf827 /arch/x86
parente735b9db12d76d45f74aee78bd63bbd2f8f480e1 (diff)
perf/x86/intel/uncore: Register the PMU only if the uncore pci device exists
Current code registers PMUs for all possible uncore pci devices. This is not good because, on some machines, one or more uncore pci devices can be missing. The missing pci device make corresponding PMU unusable. Register the PMU only if the uncore device exists. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: eranian@google.com Link: http://lkml.kernel.org/r/1409872109-31645-3-git-send-email-andi@firstfloor.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 2b0fa02268b7..42d00e53175d 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -793,6 +793,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
793 struct intel_uncore_box *box; 793 struct intel_uncore_box *box;
794 struct intel_uncore_type *type; 794 struct intel_uncore_type *type;
795 int phys_id; 795 int phys_id;
796 bool first_box = false;
796 797
797 phys_id = uncore_pcibus_to_physid[pdev->bus->number]; 798 phys_id = uncore_pcibus_to_physid[pdev->bus->number];
798 if (phys_id < 0) 799 if (phys_id < 0)
@@ -827,9 +828,13 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
827 pci_set_drvdata(pdev, box); 828 pci_set_drvdata(pdev, box);
828 829
829 raw_spin_lock(&uncore_box_lock); 830 raw_spin_lock(&uncore_box_lock);
831 if (list_empty(&pmu->box_list))
832 first_box = true;
830 list_add_tail(&box->list, &pmu->box_list); 833 list_add_tail(&box->list, &pmu->box_list);
831 raw_spin_unlock(&uncore_box_lock); 834 raw_spin_unlock(&uncore_box_lock);
832 835
836 if (first_box)
837 uncore_pmu_register(pmu);
833 return 0; 838 return 0;
834} 839}
835 840
@@ -838,6 +843,7 @@ static void uncore_pci_remove(struct pci_dev *pdev)
838 struct intel_uncore_box *box = pci_get_drvdata(pdev); 843 struct intel_uncore_box *box = pci_get_drvdata(pdev);
839 struct intel_uncore_pmu *pmu; 844 struct intel_uncore_pmu *pmu;
840 int i, cpu, phys_id = uncore_pcibus_to_physid[pdev->bus->number]; 845 int i, cpu, phys_id = uncore_pcibus_to_physid[pdev->bus->number];
846 bool last_box = false;
841 847
842 box = pci_get_drvdata(pdev); 848 box = pci_get_drvdata(pdev);
843 if (!box) { 849 if (!box) {
@@ -859,6 +865,8 @@ static void uncore_pci_remove(struct pci_dev *pdev)
859 865
860 raw_spin_lock(&uncore_box_lock); 866 raw_spin_lock(&uncore_box_lock);
861 list_del(&box->list); 867 list_del(&box->list);
868 if (list_empty(&pmu->box_list))
869 last_box = true;
862 raw_spin_unlock(&uncore_box_lock); 870 raw_spin_unlock(&uncore_box_lock);
863 871
864 for_each_possible_cpu(cpu) { 872 for_each_possible_cpu(cpu) {
@@ -870,6 +878,9 @@ static void uncore_pci_remove(struct pci_dev *pdev)
870 878
871 WARN_ON_ONCE(atomic_read(&box->refcnt) != 1); 879 WARN_ON_ONCE(atomic_read(&box->refcnt) != 1);
872 kfree(box); 880 kfree(box);
881
882 if (last_box)
883 perf_pmu_unregister(&pmu->pmu);
873} 884}
874 885
875static int __init uncore_pci_init(void) 886static int __init uncore_pci_init(void)
@@ -1221,14 +1232,6 @@ static int __init uncore_pmus_register(void)
1221 } 1232 }
1222 } 1233 }
1223 1234
1224 for (i = 0; uncore_pci_uncores[i]; i++) {
1225 type = uncore_pci_uncores[i];
1226 for (j = 0; j < type->num_boxes; j++) {
1227 pmu = &type->pmus[j];
1228 uncore_pmu_register(pmu);
1229 }
1230 }
1231
1232 return 0; 1235 return 0;
1233} 1236}
1234 1237