Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp193106pxb; Thu, 14 Jan 2021 03:33:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKt7rvy1ggNBdFMf3TIQ90ppmCpBGClGyaBVFL8113Zz0sfSa29Pj12CzR0wTTw7SFeKtB X-Received: by 2002:a17:906:f9da:: with SMTP id lj26mr4727759ejb.467.1610624020099; Thu, 14 Jan 2021 03:33:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610624020; cv=none; d=google.com; s=arc-20160816; b=Z1GCW873krTaRoFoVxpQkRulvALZ3rEy7k7d8avnvY9GEzpn0h2oaI5XpUmNtKD9GK IKdORC2y/0kvp5tzG8iKKGe+JqcUCUl05Uy2B0msVP3fy6l/K+eKeg4ZzdahKS4SRiES d0QEMOqxcmc38ALplptQKHvlUn6mkZchuzWelYzIErfojA6PAZSP9HLg24iFotnZ7WnR 1rz14UImej9kP8TA2/0dlDHVs/jLGp/NGdRswGCAISIUASOS9bIyoWkRZbqgbdsxuEda dbskqMKiHYgghBDsLFiQ30SNWODAHhQXu4M5YH5C2BgUEWGjimo4bMyCaFaCnq3d6zhT a26A== 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=JPB/l6LYFmvtproCxCZaLMkpJc1Hwdo0Nf5pwaE+DjY=; b=BQUppjzNi+OaRV9GROf3Cl0OuLFDILSQSeSNUeMIUKr/2UchqY0WhdWCCGzX61HP5V AmPxkfMYcNUiMNavnDM4X912sxkencLlfslUhukEFsMgktmdolCrO3t3l6sZAlqpton3 BQXM9JZ20Q0JJ5wBB3p6ezFo+h2KtIt0Qr94EXuumn7DdPFPt/Jg92+6CLsA7Z0YU9Nr QDC28IkF1aDG97eRtzgEaKuZrkyziMTXogJpNQNiJS0asGuX5hx2b4EJfeRxUNtRqq+D hw0MKxVBvuuJs2SsLgnjONMtlo5TU9jlqPwicUGU770UshP+EcUFWPBn6W8Q14ZJ1Ctn Cksg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pO5ZLpFS; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="5zB/hCzm"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq38si2352745ejc.21.2021.01.14.03.33.15; Thu, 14 Jan 2021 03:33:40 -0800 (PST) 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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pO5ZLpFS; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="5zB/hCzm"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728873AbhANLa3 (ORCPT + 99 others); Thu, 14 Jan 2021 06:30:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727052AbhANLaW (ORCPT ); Thu, 14 Jan 2021 06:30:22 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1AEDC0613D3; Thu, 14 Jan 2021 03:29:05 -0800 (PST) Date: Thu, 14 Jan 2021 11:29:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1610623744; 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=JPB/l6LYFmvtproCxCZaLMkpJc1Hwdo0Nf5pwaE+DjY=; b=pO5ZLpFS9fv4yvWl7Inqp36+qgIAeuGVFkvrsBvyy3ygqxrnsY59GKqTh+2ACBCRaJToXJ GYrEfb+dtLrIsPGBK2FP/uWqe3co1bXyu87/VcXujTT5t1vsFQ2fHZ28aEwNRPds3eYnUO lap5Kb5jgQfoniEwlJu0/6xVlAgMz04mMbMTCs80YvQXSCW+KK5EQwsQTxJw/8S7HtA4Js u+RMlzqsFNuWnhYGz9iHrYCQz4F2XZo5Mb/3N5Td2QBaiJbE5VLv2ULORmdfMUUD22eO35 c53uVt1WLluC16UEkr6joaOeUCMKS4weonxUZr8d7pfpCV1Az0ueOA6tCzPoWQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1610623744; 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=JPB/l6LYFmvtproCxCZaLMkpJc1Hwdo0Nf5pwaE+DjY=; b=5zB/hCzmG72d6ynFW7A0sgUlk5TPNwO26Mb08bcUwvBuD2Jga7vJGfXb32nzg95Kow2KFb yzve4cknGv2JNMAQ== From: "tip-bot2 for Steve Wahl" 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/intel/uncore: With > 8 nodes, get pci bus die id from NUMA info Cc: Steve Wahl , "Peter Zijlstra (Intel)" , Kan Liang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210108153549.108989-3-steve.wahl@hpe.com> References: <20210108153549.108989-3-steve.wahl@hpe.com> MIME-Version: 1.0 Message-ID: <161062374347.414.10709302386439251120.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 9a7832ce3d920426a36cdd78eda4b3568d4d09e3 Gitweb: https://git.kernel.org/tip/9a7832ce3d920426a36cdd78eda4b3568d4d09e3 Author: Steve Wahl AuthorDate: Fri, 08 Jan 2021 09:35:49 -06:00 Committer: Peter Zijlstra CommitterDate: Thu, 14 Jan 2021 11:20:14 +01:00 perf/x86/intel/uncore: With > 8 nodes, get pci bus die id from NUMA info The registers used to determine which die a pci bus belongs to don't contain enough information to uniquely specify more than 8 dies, so when more than 8 dies are present, use NUMA information instead. Continue to use the previous method for 8 or fewer because it works there, and covers cases of NUMA being disabled. Signed-off-by: Steve Wahl Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Kan Liang Link: https://lkml.kernel.org/r/20210108153549.108989-3-steve.wahl@hpe.com --- arch/x86/events/intel/uncore_snbep.c | 93 ++++++++++++++++++--------- 1 file changed, 65 insertions(+), 28 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 2d7014d..b79951d 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -1370,40 +1370,77 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool if (!ubox_dev) break; bus = ubox_dev->bus->number; - /* get the Node ID of the local register */ - err = pci_read_config_dword(ubox_dev, nodeid_loc, &config); - if (err) - break; - nodeid = config & NODE_ID_MASK; - /* get the Node ID mapping */ - err = pci_read_config_dword(ubox_dev, idmap_loc, &config); - if (err) - break; + /* + * The nodeid and idmap registers only contain enough + * information to handle 8 nodes. On systems with more + * than 8 nodes, we need to rely on NUMA information, + * filled in from BIOS supplied information, to determine + * the topology. + */ + if (nr_node_ids <= 8) { + /* get the Node ID of the local register */ + err = pci_read_config_dword(ubox_dev, nodeid_loc, &config); + if (err) + break; + nodeid = config & NODE_ID_MASK; + /* get the Node ID mapping */ + err = pci_read_config_dword(ubox_dev, idmap_loc, &config); + if (err) + break; - segment = pci_domain_nr(ubox_dev->bus); - raw_spin_lock(&pci2phy_map_lock); - map = __find_pci2phy_map(segment); - if (!map) { + segment = pci_domain_nr(ubox_dev->bus); + raw_spin_lock(&pci2phy_map_lock); + map = __find_pci2phy_map(segment); + if (!map) { + raw_spin_unlock(&pci2phy_map_lock); + err = -ENOMEM; + break; + } + + /* + * every three bits in the Node ID mapping register maps + * to a particular node. + */ + for (i = 0; i < 8; i++) { + if (nodeid == ((config >> (3 * i)) & 0x7)) { + if (topology_max_die_per_package() > 1) + die_id = i; + else + die_id = topology_phys_to_logical_pkg(i); + map->pbus_to_dieid[bus] = die_id; + break; + } + } raw_spin_unlock(&pci2phy_map_lock); - err = -ENOMEM; - break; - } + } 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); + if (!map) { + raw_spin_unlock(&pci2phy_map_lock); + err = -ENOMEM; + break; + } - /* - * every three bits in the Node ID mapping register maps - * to a particular node. - */ - for (i = 0; i < 8; i++) { - if (nodeid == ((config >> (3 * i)) & 0x7)) { - if (topology_max_die_per_package() > 1) - die_id = i; - else - die_id = topology_phys_to_logical_pkg(i); - map->pbus_to_dieid[bus] = die_id; + die_id = -1; + for_each_cpu(cpu, cpumask_of_pcibus(ubox_dev->bus)) { + struct cpuinfo_x86 *c = &cpu_data(cpu); + + 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)) { + err = -EINVAL; break; } } - raw_spin_unlock(&pci2phy_map_lock); } if (!err) {