Skip to content

Commit d46b4c1

Browse files
Andi KleenKAGA-KOKO
authored andcommitted
perf/x86/intel/uncore: Cache logical pkg id in uncore driver
The SNB-EP uncore driver is the only user of topology_phys_to_logical_pkg in a performance critical path. Change it query the logical pkg ID only once at initialization time and then cache it in box structure. This allows to change the logical package management without affecting the performance critical path. Signed-off-by: Andi Kleen <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Prarit Bhargava <[email protected]> Cc: Tom Lendacky <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kan Liang <[email protected]> Cc: He Chen <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Piotr Luc <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arvind Yadav <[email protected]> Cc: Vitaly Kuznetsov <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Tim Chen <[email protected]> Cc: Mathias Krause <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 4ee2ec1 commit d46b4c1

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,10 @@ static void uncore_pci_remove(struct pci_dev *pdev)
975975
int i, phys_id, pkg;
976976

977977
phys_id = uncore_pcibus_to_physid(pdev->bus);
978-
pkg = topology_phys_to_logical_pkg(phys_id);
979978

980979
box = pci_get_drvdata(pdev);
981980
if (!box) {
981+
pkg = topology_phys_to_logical_pkg(phys_id);
982982
for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
983983
if (uncore_extra_pci_dev[pkg].dev[i] == pdev) {
984984
uncore_extra_pci_dev[pkg].dev[i] = NULL;
@@ -994,7 +994,7 @@ static void uncore_pci_remove(struct pci_dev *pdev)
994994
return;
995995

996996
pci_set_drvdata(pdev, NULL);
997-
pmu->boxes[pkg] = NULL;
997+
pmu->boxes[box->pkgid] = NULL;
998998
if (atomic_dec_return(&pmu->activeboxes) == 0)
999999
uncore_pmu_unregister(pmu);
10001000
uncore_box_exit(box);

arch/x86/events/intel/uncore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct intel_uncore_extra_reg {
100100

101101
struct intel_uncore_box {
102102
int pci_phys_id;
103-
int pkgid;
103+
int pkgid; /* Logical package ID */
104104
int n_active; /* number of active events */
105105
int n_events;
106106
int cpu; /* cpu to collect events */

arch/x86/events/intel/uncore_snbep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ static void snbep_qpi_enable_event(struct intel_uncore_box *box, struct perf_eve
10571057

10581058
if (reg1->idx != EXTRA_REG_NONE) {
10591059
int idx = box->pmu->pmu_idx + SNBEP_PCI_QPI_PORT0_FILTER;
1060-
int pkg = topology_phys_to_logical_pkg(box->pci_phys_id);
1060+
int pkg = box->pkgid;
10611061
struct pci_dev *filter_pdev = uncore_extra_pci_dev[pkg].dev[idx];
10621062

10631063
if (filter_pdev) {

0 commit comments

Comments
 (0)