Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1728828pxk; Fri, 2 Oct 2020 18:18:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxji685agoC3tEz+aJd/qXwfMe9TDPwipHwdb5NuxyGGhZz3Gfkr4qCUHK+Eq9QFug6nae X-Received: by 2002:a17:906:7088:: with SMTP id b8mr4934733ejk.541.1601687889328; Fri, 02 Oct 2020 18:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601687889; cv=none; d=google.com; s=arc-20160816; b=TZp6L8VOueeY+tWYSG/I9Oau5r2JQOb6gIIo70qjDwKJBNTta6c110hiUV/pVRV3bk yyWZ9gV6UIgJ7IkUpxha7z03KEc4RVCQYzwZFZ818zRSGXlxthpc19l6kHlPfNrups72 HrjUv5r+5xCfRankVYz53JWxzZ8c+zUtV3U3tG0lte/E5fukhr1o3FKr1c2uL7y4NixS YNAiWqz7lkS73kxGfvVr04RzxcJpOBmgkRR1FRbjs/wKgGkfirZxNQBIhx8CWcvGHsjM 3rtvbtsmPg7IqF1D7/JF6IAI92rJQs53jdAMVWX09c8palPAex7LUAOvMKr81hwNLw31 1UGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=Wl14dyq2o9KiXWJLDFG//GiyrEZvdeX5ZjaW2Oa19Eo=; b=d6DFbMBbyj4tHA8fJa3YjU3N+glz1qu4gLAac51q/mQu34L6IvNr4tNPxUkFZ3PPVY qFIKhzn1e2hSA3lPo/kdYmta3V7CWd9Bs5p7XI/KFHvXsBUjt2MVbHqd4XmuSvsg3/VM iTByAdZNTVvxu7zRmfTmHr45urbTFBRMjpDirPj2xPUgchp5ehSaLmuwISK7rCouFcZC B34+PfyP1tKQ9jPa5I2G1xyv+hO5X1aDUeoqLc7ep/H7cpGNj8W4SUc7GdGLEw97vMDP V6GGvqd1QitEmOnZ36gUVIaTk5qz/9YmH0EXlwS//PZR03+Iroyg3Z2IVt2iG0y0w7yu y+7w== 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 g19si2622442ejf.746.2020.10.02.18.17.47; Fri, 02 Oct 2020 18:18:09 -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 S1725826AbgJCBQA (ORCPT + 99 others); Fri, 2 Oct 2020 21:16:00 -0400 Received: from mga11.intel.com ([192.55.52.93]:53472 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbgJCBPt (ORCPT ); Fri, 2 Oct 2020 21:15:49 -0400 IronPort-SDR: P5Sec4b6tpXvdfP4uVCDR/OxngOcqmC7uGDfGbuW6UAayz15pZ/HKpUgu4evionzUomIAktk/h M5HiQLXeSD/A== X-IronPort-AV: E=McAfee;i="6000,8403,9762"; a="160436330" X-IronPort-AV: E=Sophos;i="5.77,329,1596524400"; d="scan'208";a="160436330" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2020 18:15:48 -0700 IronPort-SDR: lAxzQVGKuMxkID9g+fJASlns2DwBBYh6sTVMtg7mjJZD7y67rzpMUlLE33yKcDG08mtNcScJ2q V19o/bq9FttA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,329,1596524400"; d="scan'208";a="325996798" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga002.jf.intel.com with ESMTP; 02 Oct 2020 18:15:48 -0700 From: Ricardo Neri To: Greg Kroah-Hartman , x86@kernel.org, Borislav Petkov , Ingo Molnar , Thomas Gleixner , "Rafael J. Wysocki" Cc: Tony Luck , Len Brown , "Ravi V. Shankar" , linux-kernel@vger.kernel.org, Ricardo Neri , Andi Kleen , Dave Hansen , Kan Liang , Srinivas Pandruvada Subject: [PATCH 4/4] x86/cpu/topology: Implement the CPU type sysfs interface Date: Fri, 2 Oct 2020 18:17:45 -0700 Message-Id: <20201003011745.7768-5-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201003011745.7768-1-ricardo.neri-calderon@linux.intel.com> References: <20201003011745.7768-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Recent Intel processors combine CPUs with different types of micro- architecture in the same package. There may be applications interested in knowing the type topology of the system. For instance, it can be used to to determine which subsets of CPUs share a common feature. Implement cpu_type sysfs interfaces for Intel processors. For example, in a system with four Intel Atom CPUs and one Intel Core CPU, these entries look as below. In this example, the native model IDs for both types of CPUs are 0: user@host:~$: ls /sys/devices/system/cpu/types intel_atom_0 intel_core_0 user@host:~$ ls /sys/devices/system/cpu/types/intel_atom_0 cpulist cpumap user@host:~$ ls /sys/devices/system/cpu/types/intel_core_0 cpulist cpumap user@host:~$ cat /sys/devices/system/cpu/types/intel_atom/cpumap 0f user@host:~$ cat /sys/devices/system/cpu/types/intel_atom/cpulist 0-3 user@nost:~$ cat /sys/devices/system/cpu/types/intel_core/cpumap 10 user@host:~$ cat /sys/devices/system/cpu/types/intel_core/cpulist 4 Cc: Andi Kleen Cc: Dave Hansen Cc: Kan Liang Cc: "Rafael J. Wysocki" Cc: "Ravi V. Shankar" Cc: Srinivas Pandruvada Cc: linux-kernel@vger.kernel.org Reviewed-by: Tony Luck Suggested-by: Len Brown # Necessity of the interface Suggested-by: Dave Hansen # Details of the interface Signed-off-by: Ricardo Neri --- arch/x86/include/asm/topology.h | 2 ++ arch/x86/kernel/cpu/topology.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index f4234575f3fd..d4a3e1ce8338 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -218,4 +218,6 @@ static inline void arch_set_max_freq_ratio(bool turbo_disabled) } #endif +#define CPUTYPES_MAX_NR 2 + #endif /* _ASM_X86_TOPOLOGY_H */ diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c index d3a0791bc052..709fc473f905 100644 --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -153,3 +153,26 @@ int detect_extended_topology(struct cpuinfo_x86 *c) #endif return 0; } + +u32 arch_get_cpu_type(int cpu) +{ + struct cpuinfo_x86 *c = &cpu_data(cpu); + + if (cpu < 0 || cpu >= nr_cpu_ids) + return 0; + + return c->x86_cpu_type; +} + +bool arch_has_cpu_type(void) +{ + return boot_cpu_has(X86_FEATURE_HYBRID_CPU); +} + +const char *arch_get_cpu_type_name(u32 cpu_type) +{ + if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) + return intel_get_hybrid_cpu_type_name(cpu_type); + + return NULL; +} -- 2.17.1