Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1528902ybm; Thu, 23 May 2019 02:34:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpB549ejWr4x+Jy2GhZHzfTDlDO39O7b2K1Ge6C3FllPLWimGSf/v34YBR2jTlauFU4wv9 X-Received: by 2002:a63:5608:: with SMTP id k8mr95797871pgb.393.1558604092163; Thu, 23 May 2019 02:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558604092; cv=none; d=google.com; s=arc-20160816; b=zJDtcYkfFf29B3rP3vPUP3mAUqn5SYJhXyNp5wCyHjhY7s+CLkdEnWVKVlwgohiyDX QaRpOU4GAKQqirJQrw4mqkAXuBiN7WJvv1r6gb+XdgwR608EyIEnvcnLojqd+rE/aXrZ SJmTOXCMlnJlgNn74imHKPyYi0EYPPb228lsKHYZ+ggo/DgDUYu3iFWXoFOaLHb6l4yx XGyUx0o1pjQD/mT6GFdFEnHk3L2rdAkgk6wKt+pIAgKWVuJloTT31S/+vIp9OFeF6PbF U/xpb+1PPQ+Gr1aWhQhmTDAUYSaJsbCPp/l27QWlzNAu4077SZ0Lxrd8bcu+RTWWCGAZ oI3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=+M7EPqU26h0B1Z1u98UjZuykFHUDbS0wqvAvgIAiVWU=; b=RJISvfoiakcH2JF/O1FcAOSbyc28PB9/XkWB5Colb78zp4SJ/Jv6xKNuM88CcBAVih VSPR2j/Eo4GZB3TlWKcwfrku0CnJTlYLIFmYrRkXglS22zE261ERmfvWt9RUpR4qdsbF GGyooZSAzfKpCGram8hrW+vr4Vnj6TYQ38x88WfzXnd2ZfH/tMidhbMPufVBd/ED/GaW KTB5d6DSj4uNIxBoDSy5VXgjD6MhKDm+TXhvKpUWdvWbOdV/Me/ngFNJJSQink8nvyQe nl2Da+DkYN/shYHgtKBTaiFad2sLOA9xosR4twHfPyyoPeYzhatXMWIcHEIwPpem1klJ THXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=noyZXq8Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24si25447879pga.515.2019.05.23.02.34.36; Thu, 23 May 2019 02:34:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=noyZXq8Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730316AbfEWJd1 (ORCPT + 99 others); Thu, 23 May 2019 05:33:27 -0400 Received: from terminus.zytor.com ([198.137.202.136]:46171 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726913AbfEWJd0 (ORCPT ); Thu, 23 May 2019 05:33:26 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x4N9VGVs4042683 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 23 May 2019 02:31:16 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x4N9VGVs4042683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1558603876; bh=+M7EPqU26h0B1Z1u98UjZuykFHUDbS0wqvAvgIAiVWU=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=noyZXq8Qce3/Jxjrmg1kUegqU5mDUtY+Uo+hQYVWGW6+S/meEZXcx37N20/ppnJ5S 4B+Yp6fWzBLJpBu29+n5N3/V3cFUVp0FDvoQmPHCfBvxtdDajNGhMBir9gs4haPSsD mT/1ImEUBrVfaciCj9dkHdKqnll2oqfMCKjAMBj4VEUXol9QBHmCyIvbsPTKNXBJW5 UQNrjDqH/vGQnlTpYaGxXQ0F6rEH9DIijwIA1QZmASK/DeE7CO3cq9WSZkEziHGsK4 Zbz0wKa+rjnjrz+6axP6Jlnul65tQqsL3NIKe5Gy/YKd6bZArNPf0VIACyJ4D0gMX0 Z67VQNhAAlOFg== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x4N9VFAp4042680; Thu, 23 May 2019 02:31:15 -0700 Date: Thu, 23 May 2019 02:31:15 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Kan Liang Message-ID: Cc: mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, kan.liang@linux.intel.com, len.brown@intel.com Reply-To: hpa@zytor.com, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, kan.liang@linux.intel.com, len.brown@intel.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/topology] perf/x86/intel/uncore: Support multi-die/package Git-Commit-ID: 1ff4a47b2d0c13b755b2eeeb0e23be6c056d5dd9 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1ff4a47b2d0c13b755b2eeeb0e23be6c056d5dd9 Gitweb: https://git.kernel.org/tip/1ff4a47b2d0c13b755b2eeeb0e23be6c056d5dd9 Author: Kan Liang AuthorDate: Mon, 13 May 2019 13:58:57 -0400 Committer: Thomas Gleixner CommitDate: Thu, 23 May 2019 10:08:35 +0200 perf/x86/intel/uncore: Support multi-die/package Uncore becomes die-scope on Xeon Cascade Lake-AP. Uncore driver needs to support die-scope uncore units. Use topology_logical_die_id() to replace topology_logical_package_id(). For previous platforms which doesn't have multi-die, topology_logical_die_id() is identical as topology_logical_package_id(). In pci_probe()/remove(), the group id reads from PCI BUS is logical die id for multi-die systems. Use topology_die_cpumask() to replace topology_core_cpumask(). For previous platforms which doesn't have multi-die, topology_die_cpumask() is identical as topology_core_cpumask(). There is no functional change for previous platforms. Signed-off-by: Kan Liang Signed-off-by: Len Brown Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar Acked-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/a25bba4a5b480aa4e9f8190005d7f5f53e29c8da.1557769318.git.len.brown@intel.com --- arch/x86/events/intel/uncore.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index fc40a1473058..aeb5eae83750 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -100,7 +100,7 @@ ssize_t uncore_event_show(struct kobject *kobj, struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu) { - unsigned int pkgid = topology_logical_package_id(cpu); + unsigned int pkgid = topology_logical_die_id(cpu); /* * The unsigned check also catches the '-1' return value for non @@ -942,7 +942,8 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id if (phys_id < 0) return -ENODEV; - pkg = topology_phys_to_logical_pkg(phys_id); + pkg = (topology_max_die_per_package() > 1) ? phys_id : + topology_phys_to_logical_pkg(phys_id); if (pkg < 0) return -EINVAL; @@ -1033,7 +1034,8 @@ static void uncore_pci_remove(struct pci_dev *pdev) box = pci_get_drvdata(pdev); if (!box) { - pkg = topology_phys_to_logical_pkg(phys_id); + pkg = (topology_max_die_per_package() > 1) ? phys_id : + topology_phys_to_logical_pkg(phys_id); for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) { if (uncore_extra_pci_dev[pkg].dev[i] == pdev) { uncore_extra_pci_dev[pkg].dev[i] = NULL; @@ -1110,7 +1112,7 @@ static void uncore_change_type_ctx(struct intel_uncore_type *type, int old_cpu, struct intel_uncore_box *box; int i, pkg; - pkg = topology_logical_package_id(old_cpu < 0 ? new_cpu : old_cpu); + pkg = topology_logical_die_id(old_cpu < 0 ? new_cpu : old_cpu); for (i = 0; i < type->num_boxes; i++, pmu++) { box = pmu->boxes[pkg]; if (!box) @@ -1151,7 +1153,7 @@ static int uncore_event_cpu_offline(unsigned int cpu) if (!cpumask_test_and_clear_cpu(cpu, &uncore_cpu_mask)) goto unref; /* Find a new cpu to collect uncore events */ - target = cpumask_any_but(topology_core_cpumask(cpu), cpu); + target = cpumask_any_but(topology_die_cpumask(cpu), cpu); /* Migrate uncore events to the new target */ if (target < nr_cpu_ids) @@ -1164,7 +1166,7 @@ static int uncore_event_cpu_offline(unsigned int cpu) unref: /* Clear the references */ - pkg = topology_logical_package_id(cpu); + pkg = topology_logical_die_id(cpu); for (; *types; types++) { type = *types; pmu = type->pmus; @@ -1223,7 +1225,7 @@ static int uncore_event_cpu_online(unsigned int cpu) struct intel_uncore_box *box; int i, ret, pkg, target; - pkg = topology_logical_package_id(cpu); + pkg = topology_logical_die_id(cpu); ret = allocate_boxes(types, pkg, cpu); if (ret) return ret; @@ -1242,7 +1244,7 @@ static int uncore_event_cpu_online(unsigned int cpu) * Check if there is an online cpu in the package * which collects uncore events already. */ - target = cpumask_any_and(&uncore_cpu_mask, topology_core_cpumask(cpu)); + target = cpumask_any_and(&uncore_cpu_mask, topology_die_cpumask(cpu)); if (target < nr_cpu_ids) return 0; @@ -1417,7 +1419,7 @@ static int __init intel_uncore_init(void) if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) return -ENODEV; - max_packages = topology_max_packages(); + max_packages = topology_max_packages() * topology_max_die_per_package(); uncore_init = (struct intel_uncore_init_fun *)id->driver_data; if (uncore_init->pci_init) {