From nobody Sat Dec 31 22:10:38 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NkxCL3mnTz2nXFh; Sat, 31 Dec 2022 22:10:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NkxCL2yBhz41YT; Sat, 31 Dec 2022 22:10:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672524638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mEeKUccvI50FuyXn9UwTko+GF2zMbqxFLwDGdCmdKAw=; b=dTN+2A/K0sKMvJN+Vujnh/AUeZwBgoQjzPn/Shk96J8ctsEuR9pgCo17h/cXFsBX1YqWXR 1A5TCX0ATMrS3VUlGivjSQvdV2kbnoRlJdk6a+oe5Nja188YR7D9cwlwVCnFRGBV7d5mDj 6Gp+KnLaOXwz1Zp3xzAkk0iCc6EoXAip+Byy6Dl8DSKygvshtJuRUp624w/0yBmBJkXLhH xineRYJ355mw50fykWQ0//hnldXK4GPcnUE3wjeB7eHoMSkDga0QXbpxaPI0yWqnBDUxPx LjhRizRDeXH34lqcNBXZihEM0uZQNBlHWKehC3vEpT465ylUUkp1hnlRMLinGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672524638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mEeKUccvI50FuyXn9UwTko+GF2zMbqxFLwDGdCmdKAw=; b=f7MFwRKfEIJ8iSOcUNFZbLpE4eu+sJhqam9jUQ3obJXNwzbcTnR1EklktgQqfOksCBUaPL nPeXIPR/3nK0WuFsvRIiLB6YtHFMvmtENTmQnk+WTk4xoOptn80vBG5BvFWAMcfQ5Tz0mX fVQynzaw8ZO7KkksNXZqECWzSVUHeEZbFYT+mGogsJDRBFEgnYMe2u9ni8rlbtYIjciu96 3iMohlRJJrbfAmQlQEmbkaGvQCbZhdz1nDJInvNUMSThDaq3TH+aqp3Al0C2mYWkFENYqt 693vQtLlHx2F+dwfLI7Qwx6IpL21M4k4JuEfSlALS4KASEGfu/ZAK7Bu29CMSw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672524638; a=rsa-sha256; cv=none; b=r0C2D1FuPyfNnNc4Jqqaeup66nfIVATRnFU85ovcf8nmkgQ6CcFXWmKV8X1rFj2Z0ax8F4 S1+THoKHoTgS3EaIXTNTup9nhepTW+ewvbXCpnuEIrvmzdQRESwKGG2UA6TNOViby/H/YB htYse9086fpQLP1nLzs9+kafZXjugLMNlj+yAJGWnQlce5BcSf6TGrMGzwrETni9RkVKsR e0eY7yN1ctqlrP3uQfZBnqzj21lHg6uVpJ0Piya1boUWlotxoRkoWJC/2J65jXI/txAWiw ajgEqPCjSu0w3j9Qi2V1RIghynrMe7IVYe86tjV1sGCUf8HiSMdSezDhlb8UPw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NkxCL20h5z140k; Sat, 31 Dec 2022 22:10:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BVMAc26010610; Sat, 31 Dec 2022 22:10:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BVMAcWb010609; Sat, 31 Dec 2022 22:10:38 GMT (envelope-from git) Date: Sat, 31 Dec 2022 22:10:38 GMT Message-Id: <202212312210.2BVMAcWb010609@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 45ac7755a7c5 - main - amd64: identify small cores List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 45ac7755a7c5d8508176b3d015bb27ff58485c80 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=45ac7755a7c5d8508176b3d015bb27ff58485c80 commit 45ac7755a7c5d8508176b3d015bb27ff58485c80 Author: Konstantin Belousov AuthorDate: 2022-12-21 11:04:14 +0000 Commit: Konstantin Belousov CommitDate: 2022-12-31 22:09:45 +0000 amd64: identify small cores Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37770 --- sys/amd64/amd64/initcpu.c | 9 +++++++++ sys/amd64/include/pcpu.h | 3 ++- sys/x86/include/specialreg.h | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 1a251208cfd6..1b731821889e 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -255,6 +255,7 @@ initializecpu(void) { uint64_t msr; uint32_t cr4; + u_int r[4]; cr4 = rcr4(); if ((cpu_feature & CPUID_XMM) && (cpu_feature & CPUID_FXSR)) { @@ -317,6 +318,14 @@ initializecpu(void) if ((amd_feature & AMDID_RDTSCP) != 0 || (cpu_stdext_feature2 & CPUID_STDEXT2_RDPID) != 0) wrmsr(MSR_TSC_AUX, cpu_auxmsr()); + + if (cpu_high >= 0x1a) { + cpuid_count(0x1a, 0, r); + if ((r[0] & CPUID_HYBRID_CORE_MASK) == + CPUID_HYBRID_SMALL_CORE) { + PCPU_SET(small_core, 1); + } + } } void diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h index 8dcf51cc71c6..70f008fe835a 100644 --- a/sys/amd64/include/pcpu.h +++ b/sys/amd64/include/pcpu.h @@ -99,7 +99,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); uint32_t pc_smp_tlb_gen; \ u_int pc_smp_tlb_op; \ uint64_t pc_ucr3_load_mask; \ - char __pad[2916] /* pad to UMA_PCPU_ALLOC_SIZE */ + u_int pc_small_core; \ + char __pad[2912] /* pad to UMA_PCPU_ALLOC_SIZE */ #define PC_DBREG_CMD_NONE 0 #define PC_DBREG_CMD_LOAD 1 diff --git a/sys/x86/include/specialreg.h b/sys/x86/include/specialreg.h index 0185317dbd38..395338b4a4b4 100644 --- a/sys/x86/include/specialreg.h +++ b/sys/x86/include/specialreg.h @@ -490,6 +490,11 @@ #define CPUID_STDEXT3_CORE_CAP 0x40000000 #define CPUID_STDEXT3_SSBD 0x80000000 +/* CPUID_HYBRID_ID leaf 0x1a */ +#define CPUID_HYBRID_CORE_MASK 0xff000000 +#define CPUID_HYBRID_SMALL_CORE 0x20000000 +#define CPUID_HYBRID_LARGE_CORE 0x40000000 + /* MSR IA32_ARCH_CAP(ABILITIES) bits */ #define IA32_ARCH_CAP_RDCL_NO 0x00000001 #define IA32_ARCH_CAP_IBRS_ALL 0x00000002