Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3427502ybf; Tue, 3 Mar 2020 05:55:56 -0800 (PST) X-Google-Smtp-Source: ADFU+vsUM8iiikzu6cJ7GNiYwQxr865FqxTLah0YXvDdP8W/jLpvSG3wymmey+G8HxyKrWLHm1n4 X-Received: by 2002:a05:6830:1e37:: with SMTP id t23mr3597608otr.16.1583243756813; Tue, 03 Mar 2020 05:55:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583243756; cv=none; d=google.com; s=arc-20160816; b=GyCyox/kG6pPLyvNWnAnBo8n39kw7UuQ4QoLYLl5/ZlSFoJrRhWi+K0CXq6ZVbX/Pp s4oxpL3tY9Nzow6rMCX4y/rmZAcLtLFaJqnxVgYj7wOzyXKgq0BQ9SzRnbcLtcsUMCaQ 09FeWRlXcgS6ymJ1kuqjjLuUhTw3WE3KJQe9FCfWzcy/HZdRuxdKC2EVwxTylHsYDlFf SLflLpnL2mKZYyzBA+myycLuaiCxic7bfVBqD4lbxig3MjicG9rIzXDqpiyxMpr6sGEO wZNYh17cq3uOrCIvb/kboa4AtqmpJgbF5ZIDVAyVlBk5QYdkUKY6KCinFGhoOULaQXrr jBEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=slUDvWV1wmJaqDBAcqS7SCww7jGZiBqTCfXU68cbT8s=; b=TM/ShIAMdeT67diIqyZEKRT/c4Vula9cBv2dyk0nN84J4EW5dDza5G5SfgZAnUUZF3 p2QmnqrhdcUtXcgKpfN9kEpfZ73TdoS4Gz7pnRx/985gv1yZZan1W3w08MS0eYUTg3J6 d0BCAtR2sXROL+S4hBuD68zZTqZChrFRg8OchABzb5iF/rOGkOIb3KmcTEykWLJVl1a4 tMSDY93HJz7TPDRqB1o5o4eSNRcoCkr9yUwnTlVlwg/awCN86FiGV9la0IaRqAZlra2+ rKrG02VMwCzb7z26jMjPcKF9QWFf9m0Otf5iqcBCIObuEpzznAF0S10epHUbbQSdZ2ma SunA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si8557242otg.179.2020.03.03.05.55.46; Tue, 03 Mar 2020 05:55:56 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729221AbgCCNyb (ORCPT + 99 others); Tue, 3 Mar 2020 08:54:31 -0500 Received: from mga18.intel.com ([134.134.136.126]:4960 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727079AbgCCNyb (ORCPT ); Tue, 3 Mar 2020 08:54:31 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2020 05:54:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,511,1574150400"; d="scan'208";a="386790894" Received: from nntpdsd52-183.inn.intel.com ([10.125.52.183]) by orsmga004.jf.intel.com with ESMTP; 03 Mar 2020 05:54:27 -0800 From: roman.sudarikov@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, eranian@google.com, bgregg@netflix.com, ak@linux.intel.com, kan.liang@linux.intel.com Cc: alexander.antonov@intel.com, roman.sudarikov@linux.intel.com Subject: [PATCH v7 2/3] perf x86: Topology max dies for whole system Date: Tue, 3 Mar 2020 16:54:17 +0300 Message-Id: <20200303135418.9621-3-roman.sudarikov@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200303135418.9621-1-roman.sudarikov@linux.intel.com> References: <20200303135418.9621-1-roman.sudarikov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Sudarikov Helper function to return number of dies on the platform. Co-developed-by: Alexander Antonov Signed-off-by: Alexander Antonov Signed-off-by: Roman Sudarikov --- arch/x86/events/intel/uncore.c | 13 +++++++------ arch/x86/events/intel/uncore.h | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index fb693608c223..aee64c96785d 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -16,7 +16,7 @@ struct pci_driver *uncore_pci_driver; DEFINE_RAW_SPINLOCK(pci2phy_map_lock); struct list_head pci2phy_map_head = LIST_HEAD_INIT(pci2phy_map_head); struct pci_extra_dev *uncore_extra_pci_dev; -static int max_dies; +int __uncore_max_dies; /* mask of cpus that collect uncore events */ static cpumask_t uncore_cpu_mask; @@ -108,7 +108,7 @@ struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu * The unsigned check also catches the '-1' return value for non * existent mappings in the topology map. */ - return dieid < max_dies ? pmu->boxes[dieid] : NULL; + return dieid < uncore_max_dies() ? pmu->boxes[dieid] : NULL; } u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event) @@ -879,7 +879,7 @@ static void uncore_free_boxes(struct intel_uncore_pmu *pmu) { int die; - for (die = 0; die < max_dies; die++) + for (die = 0; die < uncore_max_dies(); die++) kfree(pmu->boxes[die]); kfree(pmu->boxes); } @@ -920,7 +920,7 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) if (!pmus) return -ENOMEM; - size = max_dies * sizeof(struct intel_uncore_box *); + size = uncore_max_dies() * sizeof(struct intel_uncore_box *); for (i = 0; i < type->num_boxes; i++) { pmus[i].func_id = setid ? i : -1; @@ -1120,7 +1120,7 @@ static int __init uncore_pci_init(void) size_t size; int ret; - size = max_dies * sizeof(struct pci_extra_dev); + size = uncore_max_dies() * sizeof(struct pci_extra_dev); uncore_extra_pci_dev = kzalloc(size, GFP_KERNEL); if (!uncore_extra_pci_dev) { ret = -ENOMEM; @@ -1532,7 +1532,8 @@ static int __init intel_uncore_init(void) if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) return -ENODEV; - max_dies = topology_max_packages() * topology_max_die_per_package(); + __uncore_max_dies = + topology_max_packages() * topology_max_die_per_package(); uncore_init = (struct intel_uncore_init_fun *)id->driver_data; if (uncore_init->pci_init) { diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index d41f8874adc5..c1da2b8218cd 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -174,6 +174,9 @@ int uncore_pcibus_to_physid(struct pci_bus *bus); ssize_t uncore_event_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf); +extern int __uncore_max_dies; +#define uncore_max_dies() (__uncore_max_dies) + #define INTEL_UNCORE_EVENT_DESC(_name, _config) \ { \ .attr = __ATTR(_name, 0444, uncore_event_show, NULL), \ -- 2.19.1