Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1197649rwb; Fri, 28 Jul 2023 06:15:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlGke8rBugpfRt/R36L8l6CLMaSq1oJycddCI6vK8x8lQ+nIiEU+HHqEohKAtGxbPPNYD6F7 X-Received: by 2002:a17:906:30ca:b0:98e:419b:4cbc with SMTP id b10-20020a17090630ca00b0098e419b4cbcmr2471569ejb.12.1690550148849; Fri, 28 Jul 2023 06:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690550148; cv=none; d=google.com; s=arc-20160816; b=cVvtnCDddbqgy4mk/K+z2ii1xpfY7mg3wIgNcggiUiFEA+PqClR2xVE2x3QLNzHZz4 dAK7KIfTUsTPl0c8/cPmpa97YJ6lCD33+IH1sUuLSq+kWOIyapjvXuLPaeW7/BMDA7KQ t5r3+Heflr/uE3fMbcyuJJdmrnnOXMHjZBi9YAUQyEaEOoXQ6NoyYLsuD+RoZWXzPjC7 xGrSOwowihfRmvGCgryRQIU6DzEwWMD087Y7KCy0NZBk/gctamVBoEb4wYfh7USUMRaL YjNRlYvJeSd0mhxDcCV5jdxEmtgu7Y/DrMI5GInhCIHDYCPlnmj1yM5HSBJQWnP2RbPQ XqLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=FytBYElyGEIkDLoNOYBMDUbfYGktH+yBC5OWWqC5tQQ=; fh=y/slnYrqOPbByUK75sFPvq3cYp2SbZKM1q7UWSqjNrY=; b=P2woHmXJah/805JAxP2MGSK9O/jzQsZtfpiiTY92XGfiCVKF1lL0W83gK7JRyOoonw nK0ZGhN9vNqPZ464Xw6cQg19XbUSx6yKqI8BppVY4dYVuz+gpLzLn0t7ZQctw8o9H9tZ X78luoL9UJtUiXSlEV73rQYgx1YCnB/ZJLo5+HZDOyLwNzzNFnJo1EYJj2SM9p5ziMtK JGB2gajneKDLezyVufOabyFWesvQYVTeaKXO7xVUWkOkSmY2idpNz/wTRbipqSu0XGW3 g5jGHeFwptC4vZx3iEm3iGspB0MAf6jORynkPkStY/WJ1uCqP3zq3bFPMixoUNDR2BmE Lp+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hZ41luBM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a1709066c9700b0097d787c4afesi2833981ejr.398.2023.07.28.06.15.23; Fri, 28 Jul 2023 06:15:48 -0700 (PDT) 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=hZ41luBM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S236500AbjG1MOK (ORCPT + 99 others); Fri, 28 Jul 2023 08:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236275AbjG1MNa (ORCPT ); Fri, 28 Jul 2023 08:13:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8B173C38; Fri, 28 Jul 2023 05:13:07 -0700 (PDT) Message-ID: <20230728120930.727298737@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1690546386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=FytBYElyGEIkDLoNOYBMDUbfYGktH+yBC5OWWqC5tQQ=; b=hZ41luBM+cti3euUpMK4zrf7WtFnCgKHLtyziGAZkLcWHfkkOK1fLCTSc8+omhqrlivgwL 3xQ44xGTq6miYIs6Xd5UTTbDgV+NK/IT8fgk84D8Dl8fbIwlG8EGuOH48Kl8IQagMdDQlg kF+F7o482+zX2yF0GFjALI+UAwm55CcdfgSYjb1+rr9n0ZZfViaAZLB3XPGSYgtOs9saz+ kSsA+/X2BeExBUcJDxro5VX/BlQmukaMrVIIzcRp8MmPshfm8Znxmxg/Mcx7Ahz6m+x1vo R0wEwVHpVMRqRZgxLfraY2whEviOuMJjdnnAWi9LmBVordDd+T5s6agMaGSLWg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1690546386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=FytBYElyGEIkDLoNOYBMDUbfYGktH+yBC5OWWqC5tQQ=; b=dzTdqmDzRwOd4rwCfjlNdB7I/QXFPa+mOtg/PmnlywJ665y6b6j0aC+/R8q1fb1PfVO/rE Fjt9pzUzUtdK6vBQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , "James E.J. Bottomley" , Dick Kennedy , James Smart , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Guenter Roeck , linux-hwmon@vger.kernel.org, Jean Delvare , Huang Rui , Juergen Gross , Steve Wahl , Mike Travis , Dimitri Sivanich , Russ Anderson Subject: [patch v2 19/38] x86/cpu: Provide debug interface References: <20230728105650.565799744@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Fri, 28 Jul 2023 14:13:06 +0200 (CEST) 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,T_SCC_BODY_TEXT_LINE,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 Provide debug files which dump the topology related information of cpuinfo_x86. This is useful to validate the upcoming conversion of the topology evaluation for correctness or bug compatibility. Signed-off-by: Thomas Gleixner --- V2: Don't return ENODEV when offline and make online a field. --- arch/x86/kernel/cpu/Makefile | 2 + arch/x86/kernel/cpu/debugfs.c | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile @@ -54,6 +54,8 @@ obj-$(CONFIG_X86_LOCAL_APIC) += perfctr obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o obj-$(CONFIG_ACRN_GUEST) += acrn.o +obj-$(CONFIG_DEBUG_FS) += debugfs.o + quiet_cmd_mkcapflags = MKCAP $@ cmd_mkcapflags = $(CONFIG_SHELL) $(srctree)/$(src)/mkcapflags.sh $@ $^ --- /dev/null +++ b/arch/x86/kernel/cpu/debugfs.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include + +#include +#include + +static int cpu_debug_show(struct seq_file *m, void *p) +{ + unsigned long cpu = (unsigned long)m->private; + struct cpuinfo_x86 *c = per_cpu_ptr(&cpu_info, cpu); + + seq_printf(m, "online: %d\n", cpu_online(cpu)); + if (!c->initialized) + return 0; + + seq_printf(m, "initial_apicid: %x\n", c->topo.initial_apicid); + seq_printf(m, "apicid: %x\n", c->topo.apicid); + seq_printf(m, "pkg_id: %u\n", c->topo.pkg_id); + seq_printf(m, "die_id: %u\n", c->topo.die_id); + seq_printf(m, "cu_id: %u\n", c->topo.cu_id); + seq_printf(m, "core_id: %u\n", c->topo.core_id); + seq_printf(m, "logical_pkg_id: %u\n", c->topo.logical_pkg_id); + seq_printf(m, "logical_die_id: %u\n", c->topo.logical_die_id); + seq_printf(m, "llc_id: %u\n", c->topo.llc_id); + seq_printf(m, "l2c_id: %u\n", c->topo.l2c_id); + seq_printf(m, "max_cores: %u\n", c->x86_max_cores); + seq_printf(m, "max_die_per_pkg: %u\n", __max_die_per_package); + seq_printf(m, "smp_num_siblings: %u\n", smp_num_siblings); + return 0; +} + +static int cpu_debug_open(struct inode *inode, struct file *file) +{ + return single_open(file, cpu_debug_show, inode->i_private); +} + +static const struct file_operations dfs_cpu_ops = { + .open = cpu_debug_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static __init int cpu_init_debugfs(void) +{ + struct dentry *dir, *base = debugfs_create_dir("topo", arch_debugfs_dir); + unsigned long id; + char name [10]; + + dir = debugfs_create_dir("cpus", base); + for_each_possible_cpu(id) { + sprintf(name, "%lu", id); + debugfs_create_file(name, 0444, dir, (void *)id, &dfs_cpu_ops); + } + return 0; +} +late_initcall(cpu_init_debugfs);