Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp726616lqo; Wed, 8 May 2024 12:54:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVzKrVBOTWciedEoV1dlKRwUJYfAfI+MDUG2RvU+2UBd1S8nKrtjTZo5+1QTWunXHPiRkv85xqPuymetKoejE0EJjJZSPvuvwg/mYzwSg== X-Google-Smtp-Source: AGHT+IGlEV41k/SViE7WigftQR6CeKLIETknRn7nsMHYbOoH4352jdULaMWyQOHDrnM74maZofZa X-Received: by 2002:a50:a41e:0:b0:570:1de9:4cd7 with SMTP id 4fb4d7f45d1cf-5731d9d3a84mr2746766a12.15.1715198040091; Wed, 08 May 2024 12:54:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715198040; cv=pass; d=google.com; s=arc-20160816; b=ycf0c2husppFW3kf7bVI7cKdjaJrLX67Ew2HqraYvfek3PimXiuAYdr2kYJsSEG+ck HsmLDwNg3tDL/nifOGMiOxG/M4fAWpFEJ3+keRTXK/SfRT7duGB0WI653CbJsm0/v7SU AArqv/hUmF+eMPFwP5EC2jGaXFgsMmBqfIWPZP7rXajX/oPkS1q5icbAGpH4PBf/AP15 J9JK2y4+3yOeKjqBm+/yecXsYpx++WKS1BbkL/NY1KpfAosw9v5UClyRpNxGnBAJqgxC /DZE3t255bu80iK9NH+KGoyBo0DQkj4Xfbd+HhMgojEf3kCRhrWLjX6QtVGMJn1geHE+ tBkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=PHZAXCOEXcGPwR1zHInsLpn+NjYZkvzjn9mg8CTfNIU=; fh=Tv+7TOnqXP7UltlftaGMoztRyvaVpkaYZjq1tIdGhR0=; b=spzb4EM70azmvYiniE+ZIHcYZhee0EIUfDtn/W7LNg03i1rK4R1csXgliEXSiIXBZE QqqJhaN/lb0xQThjRu6VYNkbSRzdDm6rl29qFcYRuhFNjweR0WF+UEm3xXGFpXsDZ+TC 1rmHiWYw4HMvUxPZ3i4HOrHq0wJdOX5R3hdVCX4ndhFbzO8QI9NHrovF8gM6zECKSvah VUDCX7Oh5cPvtt07TLE6s2Wj7j9IMkzhdcJIDWWOYhpirT+HQejTBqTujUFzLimueqtU heQxB2qFUsEJb+Ju6Rpml9MvGZwGK62t8ZV5pQP4FMW0U1m0+e5xQk3PTLDBK01QBBrC Fnew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=N4GX6Zhc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-173781-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173781-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z9-20020a056402274900b00572ab8ed69esi4257311edd.541.2024.05.08.12.54.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 12:54:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173781-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=N4GX6Zhc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-173781-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173781-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CD9351F229C1 for ; Wed, 8 May 2024 19:53:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F30E130AC2; Wed, 8 May 2024 19:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="N4GX6Zhc"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="innIsTEy" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8D7A38DF2 for ; Wed, 8 May 2024 19:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715198031; cv=none; b=fTLVxzLrN488LEsBE92MhXHzLFG241aPJxiEQT0FXmRDKBgE5+WByu5tGyg5rd1wOj/yZR9cWWHYFb1y4zXJnY25WIgYZWuy1Rqo7XNCaFCC0u12sYrnUoBmoXOSz6tn3IKpEKf9VuUCRq6icF7EIt/dvjJrQFmLwcjpGOzu6v8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715198031; c=relaxed/simple; bh=QxOpoHTxeKxkvLy0yYHQBmZAY8o/hWqfG0stvAHRgOo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=BAa5j9opZbEuw88q7nuG+NVFaDme9+y/vzZ2leqm73TKXUAIDhyHV1mmoH+nkJ2MVxme/m3pW72nJlz1CCRwFuk31LKgt5kS0sgnVxUrfo6LS5BWhPp3LTE/pEGn3oeMCIc9ucaEc2TDuDoGLfIEyzP4AxesqxNeN1vd6Nb8U94= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=N4GX6Zhc; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=innIsTEy; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1715198027; 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: in-reply-to:in-reply-to:references:references; bh=PHZAXCOEXcGPwR1zHInsLpn+NjYZkvzjn9mg8CTfNIU=; b=N4GX6ZhcQRgGoU+/6m3duXoFIz+//57RJYUB04l8qLsYlTcoQHgrfpLpiwZ1FvxEe63z7u pXnZfL6UYNvNjn+Rg0LPFlXv0amOW5Oj4JhVFzBmsY9J/fWD8PYFzOCDpoGNwZeHKBzeBl sECWqxuMFntYGlT5CQfU7FUR3QFVO9xgRR7dCOH+KFuWOnGOFptIMNERHfWlKbTH8taZlI ToAcYUUtNH7aw4H82DDVC59CVCgzwqqilnouWClUZ1crvGFu7VajJc3TYb3PjWn8isw6EZ XeXTbmRN4/o2dbadhiDv2TFa08TWUdJwjTw1QXra02vGKw5Re70l8pYizIo6TQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1715198027; 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: in-reply-to:in-reply-to:references:references; bh=PHZAXCOEXcGPwR1zHInsLpn+NjYZkvzjn9mg8CTfNIU=; b=innIsTEyOqyEN84jSzkZJjPaL8XoClSasWkHhFQ2P84HgGB3a+GdJCSimPZBBk74JmeMp5 kbk30OriXFxzKNAA== To: "Yuezhang.Mo@sony.com" Cc: "andrew.cooper3@citrix.com" , "andy@infradead.org" , "arjan@linux.intel.com" , "dimitri.sivanich@hpe.com" , "feng.tang@intel.com" , "jgross@suse.com" , "kan.liang@linux.intel.com" , "kprateek.nayak@amd.com" , "linux-kernel@vger.kernel.org" , "mhklinux@outlook.com" , "paulmck@kernel.org" , "peterz@infradead.org" , "ray.huang@amd.com" , "rui.zhang@intel.com" , "sohil.mehta@intel.com" , "thomas.lendacky@amd.com" , "wendy.wang@intel.com" , "x86@kernel.org" Subject: [patch] x86/topology/amd: Ensure that LLC ID is initialized In-Reply-To: References: Date: Wed, 08 May 2024 21:53:47 +0200 Message-ID: <87msp0nkqc.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain The original topology evaluation code initialized cpu_data::topo::llc_id with the die ID initialy and then eventually overwrite it with information gathered from a CPUID leaf. The conversion analysis failed to spot that particular detail and omitted this initial assignment under the assumption that each topology evaluation path will set it up. That assumption is mostly correct, but turns out to be wrong in case that the CPUID leaf 0x80000006 does not provide a LLC ID. In that case LLC ID is invalid and as a consequence the setup of the scheduling domain CPU masks is incorrect which subsequently causes the scheduler core to complain about it during CPU hotplug: BUG: arch topology borken the CLS domain not a subset of the MC domain Cure it by reusing legacy_set_llc() and assigning the die ID if the LLC ID is invalid after all possible parsers have been tried. Fixes: f7fb3b2dd92c ("x86/cpu: Provide an AMD/HYGON specific topology parser") Reported-by: Yuezhang Mo Signed-off-by: Thomas Gleixner --- Thanks to Yuezhang for providing the debug information! --- arch/x86/kernel/cpu/topology_amd.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/cpu/topology_amd.c +++ b/arch/x86/kernel/cpu/topology_amd.c @@ -119,7 +119,7 @@ static bool parse_8000_001e(struct topo_ return true; } -static bool parse_fam10h_node_id(struct topo_scan *tscan) +static void parse_fam10h_node_id(struct topo_scan *tscan) { union { struct { @@ -131,20 +131,20 @@ static bool parse_fam10h_node_id(struct } nid; if (!boot_cpu_has(X86_FEATURE_NODEID_MSR)) - return false; + return; rdmsrl(MSR_FAM10H_NODE_ID, nid.msr); store_node(tscan, nid.nodes_per_pkg + 1, nid.node_id); tscan->c->topo.llc_id = nid.node_id; - return true; } static void legacy_set_llc(struct topo_scan *tscan) { unsigned int apicid = tscan->c->topo.initial_apicid; - /* parse_8000_0008() set everything up except llc_id */ - tscan->c->topo.llc_id = apicid >> tscan->dom_shifts[TOPO_CORE_DOMAIN]; + /* If none of the parsers set LLC ID then use the die ID for it. */ + if (tscan->c->topo.llc_id == BAD_APICID) + tscan->c->topo.llc_id = apicid >> tscan->dom_shifts[TOPO_CORE_DOMAIN]; } static void topoext_fixup(struct topo_scan *tscan) @@ -187,10 +187,7 @@ static void parse_topology_amd(struct to return; /* Try the NODEID MSR */ - if (parse_fam10h_node_id(tscan)) - return; - - legacy_set_llc(tscan); + parse_fam10h_node_id(tscan); } void cpu_parse_topology_amd(struct topo_scan *tscan) @@ -198,6 +195,7 @@ void cpu_parse_topology_amd(struct topo_ tscan->amd_nodes_per_pkg = 1; topoext_fixup(tscan); parse_topology_amd(tscan); + legacy_set_llc(tscan); if (tscan->amd_nodes_per_pkg > 1) set_cpu_cap(tscan->c, X86_FEATURE_AMD_DCM);