From patchwork Sat Jan 21 09:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 46794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp651652wrn; Sat, 21 Jan 2023 01:54:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9bT0FfflqatvM+zPpoK2ooShbQ1Tq1QvcPVH53n7kbIsz3RZbmcJ2WPqWUHtq8gWGrnDf X-Received: by 2002:a17:906:cd1f:b0:84d:4a2b:73b9 with SMTP id oz31-20020a170906cd1f00b0084d4a2b73b9mr19528232ejb.59.1674294860153; Sat, 21 Jan 2023 01:54:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674294860; cv=none; d=google.com; s=arc-20160816; b=oJfDk9h1Lz34pOy3RryS5XWyb8havLlpBERfXkV+DGlbvEpjo6IhSBlzQIJKPqe9Le WWEzbi/D9q7lrl94yrJYfQsdE56847WsllE/ZmdNbuT4YfRjruUc8TBd6DDE0E7Svo1j nxRT6PgVvOVUUeK6WrmeB7zCZf7shjXTH7NUs20839IR3D0gGB4CjebdqJxwuOPkHZI9 3SL2t4JOxZpnkrYfSEq2N9RA1g02lfFB/r9/zX3zrP921KdIPx8nsH1bDo9NM8bzAe6H 6ITba/Df85yupFT96tRjiHrdI9JvGZUBhs9hYmVqnx59FBtMeIzob6OWopGC4lpqm22V 0uaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=Cux3u5RitqESrW0kZWqOAJ/Kos4RVxzC1jiribYIxfA=; b=E3x4z1JBoLo3snT9FeDJNKOhSR+oVyE6pEB5aKCMJn1bzAwmz9TJuZVqvhIf6EV+I8 9Ehs0s485u6GPYm3UDI9cUiHoZW8AVsKLahpSG4Qy/F7aVhJPW/OHlbCBArU0A7C7msM oGESCN/ow8FJTlEHJZwc5AF0fMwm6mZXT2hkuefj5ZA63tPMAOo6Upd1MAxp/Vu6sY4x 8IP4/IUbT/Q43PTeSmDXVl9V2J+LgOPkU3u5gefKAl/BNBI9aer4g7FxBENpOgeBH4gA 0V+azr/zM+bSASWoNDWNgpcZvSKKxZrYD1wClHVeDanEFk18Pp+cCrns6GCpxTPKgOhb NjcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=H55ylvZB; dkim=neutral (no key) header.i=@linutronix.de header.b=MHU1a7D2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp15-20020a170906c14f00b008717c29397csi19035263ejc.55.2023.01.21.01.53.56; Sat, 21 Jan 2023 01:54:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=H55ylvZB; dkim=neutral (no key) header.i=@linutronix.de header.b=MHU1a7D2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229707AbjAUJtx (ORCPT + 99 others); Sat, 21 Jan 2023 04:49:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbjAUJtd (ORCPT ); Sat, 21 Jan 2023 04:49:33 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5848E5B596; Sat, 21 Jan 2023 01:49:32 -0800 (PST) Date: Sat, 21 Jan 2023 09:49:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1674294567; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cux3u5RitqESrW0kZWqOAJ/Kos4RVxzC1jiribYIxfA=; b=H55ylvZB9UyFVEKlgIQPxlVuQ/UjUR+9f3gAoHEPE95BqVMnYk/fETalTnji5flYqfd/cn m3o+COC8JtHBvYYKGjISZO0h8OexDTdIb2iofXvLqc/quuTbVOmlz+n4gBbZJOCZUVdbo2 Ru4P8S0HwBailhbZEpjN55BW8ZeRZs9vLcnp1vq8Bzho/jJ4Zmyon+DcRq7ZCl452HF6wo DEw7mC3Tnqf0+rAYS2EQopCVZhQS8pyWE+6KfldeVK48siKLoehPlTX9oS4/9t3jYoNRV2 MWTTj+eVWTwSALPBzqqXswMDU057GSfTgHBNf7VLA2v8dPJ2ZL5qeEO+yqgfpw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1674294567; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cux3u5RitqESrW0kZWqOAJ/Kos4RVxzC1jiribYIxfA=; b=MHU1a7D2MSmR/UVA4QdjfWvvIhyFbS1Dv3PqaQWmEFy089/gJe+ZAtpRVof2jCwtPhUMSL UZ5jtqtylL+LMIAw== From: "tip-bot2 for Kan Liang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/uncore: Factor out uncore_device_to_die() Cc: Kan Liang , "Peter Zijlstra (Intel)" , Michael Petlan , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230112200105.733466-2-kan.liang@linux.intel.com> References: <20230112200105.733466-2-kan.liang@linux.intel.com> MIME-Version: 1.0 Message-ID: <167429456670.4906.2068459695458312637.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754848643939356980?= X-GMAIL-MSGID: =?utf-8?q?1755625406955092665?= The following commit has been merged into the perf/core branch of tip: Commit-ID: dbf061b26221fa1a99e6489dd61f5b4ee97a24e8 Gitweb: https://git.kernel.org/tip/dbf061b26221fa1a99e6489dd61f5b4ee97a24e8 Author: Kan Liang AuthorDate: Thu, 12 Jan 2023 12:01:01 -08:00 Committer: Peter Zijlstra CommitterDate: Sat, 21 Jan 2023 00:06:11 +01:00 perf/x86/uncore: Factor out uncore_device_to_die() The same code is used to retrieve the logical die ID with a given PCI device in both the discovery code and the code that supports a system with > 8 nodes. Factor out uncore_device_to_die() to replace the duplicate code. No functional change. Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Tested-by: Michael Petlan Link: https://lore.kernel.org/r/20230112200105.733466-2-kan.liang@linux.intel.com --- arch/x86/events/intel/uncore.c | 15 +++++++++++++++ arch/x86/events/intel/uncore.h | 1 + arch/x86/events/intel/uncore_discovery.c | 16 ++-------------- arch/x86/events/intel/uncore_snbep.c | 12 +----------- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 459b1aa..eeaa92f 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -65,6 +65,21 @@ int uncore_die_to_segment(int die) return bus ? pci_domain_nr(bus) : -EINVAL; } +int uncore_device_to_die(struct pci_dev *dev) +{ + int node = pcibus_to_node(dev->bus); + int cpu; + + for_each_cpu(cpu, cpumask_of_pcibus(dev->bus)) { + struct cpuinfo_x86 *c = &cpu_data(cpu); + + if (c->initialized && cpu_to_node(cpu) == node) + return c->logical_die_id; + } + + return -1; +} + static void uncore_free_pcibus_map(void) { struct pci2phy_map *map, *tmp; diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index e278e2e..8d493be 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -208,6 +208,7 @@ struct pci2phy_map { struct pci2phy_map *__find_pci2phy_map(int segment); int uncore_pcibus_to_dieid(struct pci_bus *bus); int uncore_die_to_segment(int die); +int uncore_device_to_die(struct pci_dev *dev); ssize_t uncore_event_show(struct device *dev, struct device_attribute *attr, char *buf); diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c index 5fd72d4..08af92a 100644 --- a/arch/x86/events/intel/uncore_discovery.c +++ b/arch/x86/events/intel/uncore_discovery.c @@ -33,7 +33,7 @@ static int logical_die_id; static int get_device_die_id(struct pci_dev *dev) { - int cpu, node = pcibus_to_node(dev->bus); + int node = pcibus_to_node(dev->bus); /* * If the NUMA info is not available, assume that the logical die id is @@ -43,19 +43,7 @@ static int get_device_die_id(struct pci_dev *dev) if (node < 0) return logical_die_id++; - for_each_cpu(cpu, cpumask_of_node(node)) { - struct cpuinfo_x86 *c = &cpu_data(cpu); - - if (c->initialized && cpu_to_node(cpu) == node) - return c->logical_die_id; - } - - /* - * All CPUs of a node may be offlined. For this case, - * the PCI and MMIO type of uncore blocks which are - * enumerated by the device will be unavailable. - */ - return -1; + return uncore_device_to_die(dev); } #define __node_2_type(cur) \ diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 44c2f87..31acc96 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -1453,9 +1453,6 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool } raw_spin_unlock(&pci2phy_map_lock); } else { - int node = pcibus_to_node(ubox_dev->bus); - int cpu; - segment = pci_domain_nr(ubox_dev->bus); raw_spin_lock(&pci2phy_map_lock); map = __find_pci2phy_map(segment); @@ -1465,15 +1462,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool break; } - die_id = -1; - for_each_cpu(cpu, cpumask_of_pcibus(ubox_dev->bus)) { - struct cpuinfo_x86 *c = &cpu_data(cpu); + map->pbus_to_dieid[bus] = die_id = uncore_device_to_die(ubox_dev); - if (c->initialized && cpu_to_node(cpu) == node) { - map->pbus_to_dieid[bus] = die_id = c->logical_die_id; - break; - } - } raw_spin_unlock(&pci2phy_map_lock); if (WARN_ON_ONCE(die_id == -1)) {