Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp883102ybs; Mon, 25 May 2020 01:22:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+bw/LfC13hDPTbfrfxkEpn7THQLPdR7M4jY3G8kbPX/PX9tsFM1nsWKjkJ1aCEdg3Cre9 X-Received: by 2002:a17:906:3943:: with SMTP id g3mr17686174eje.454.1590394968030; Mon, 25 May 2020 01:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590394968; cv=none; d=google.com; s=arc-20160816; b=emSVFzAruFFT+lRRECQsR7TTB2/tzPc8Ncrm5nKpZbhQE58iAp/jFbeAr3XnQgqBmh 6pnnwzbIA1Ap9DxwKQw/p2ArHqnhviGwcAn+/eFkMp4e4OQK9VzBthTBS9UdvH2Ss8SB SxDJE0zZU4aWKW44sQbnEyrb34t+SUVRO6fGw8BidsFsxgnUi7+O2rrICn0qL3Y7daKt O59x7dlI3xKsxYoFaRjofXRimRCWbuvTaR+D5NbYFcjwLlRKkJsE14BaUFSmZoJvswyF +qPBpzeMNMCHkjlHbRj+IOEbfOs60LH6WcBu8ORHnkKAY7iZdKZOYEJl8nHGcIE2Yj/N 0iNg== 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 :ironport-sdr:ironport-sdr; bh=hZCuuVJ2hnbdnEgvmtgU9+nbYmQ72tGJFygrZHF6qjc=; b=dGgfYqfGbpyOa6Wdbd+KlqUpD7/BAyH+fzArwwU5iBcYacu/yqKZcBcFF0aXe/VdtQ LgVwCTEOIHD6w7M8uSkLGPpOedLcHNYzHUIKa4UeQNAAQxqm/NrtqneVfUmaASvYBctl siVN1/5s/F0R7cZRs6drtsqNwPP6dObtUJfSV2iDz/6WNKwdgscmS+Y++musVVZ9e2nx 4O61V9oQi+Mfirlb//rd6HY2or2flLq8hu1ZnFqKMoqKlC//o+ZAoNCLHu/Zgv+gbBEY kC47/a+IMHdjxcGDVWBRRP793w8an2X0avIKweSuZqkTYR6d6OCHuaHyne/CoeswJzpn 7V8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f20si8177815edy.274.2020.05.25.01.22.25; Mon, 25 May 2020 01:22:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2388182AbgEYIGH (ORCPT + 99 others); Mon, 25 May 2020 04:06:07 -0400 Received: from mga09.intel.com ([134.134.136.24]:29983 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387807AbgEYIGG (ORCPT ); Mon, 25 May 2020 04:06:06 -0400 IronPort-SDR: j2V5y7LrnonRlanCupUUw+MXWWkndbwZ/0snr9OteDt69lqWlGEFfBfFr09lbCH15neVbWRbr7 19ojs4+bzSBw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2020 01:06:06 -0700 IronPort-SDR: 8L5CHOboaP+ccT8y9teW+u4L28Yr93MKA3wbVSgfDA3I4YN7E7BbUS5PRblUiU7wRWz9SbBYgu wwFP8fy51QKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,432,1583222400"; d="scan'208";a="441658159" Received: from nntpdsd52-183.inn.intel.com ([10.125.52.183]) by orsmga005.jf.intel.com with ESMTP; 25 May 2020 01:06:02 -0700 From: alexander.antonov@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@linux.intel.com Subject: [RESEND PATCH v9 2/3] perf/x86/intel/uncore: Wrap the max dies calculation into an accessor Date: Mon, 25 May 2020 11:05:53 +0300 Message-Id: <20200525080554.21313-3-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200525080554.21313-1-alexander.antonov@linux.intel.com> References: <20200525080554.21313-1-alexander.antonov@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 The accessor to return number of dies on the platform. Co-developed-by: Alexander Antonov Signed-off-by: Alexander Antonov Signed-off-by: Roman Sudarikov Reviewed-by: Kan Liang Reviewed-by: Alexander Shishkin --- 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 b71e8f7529a4..e4f37dc83cf0 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; @@ -1547,7 +1547,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 8f2b77d27513..8621b66c49ef 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -181,6 +181,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