From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1D0CC433FE for ; Tue, 24 May 2022 08:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=YFCVJDJ356tbjP6k1vUf9Uss7/S8/qeoOKDeRajmYXs=; b=jFtxjvojxOpc24 tUFIEqamlosGqZWaANitVuletqyzRGy0KozmyJlaEv5Niqq2p/1yvlGv9zc7sgTL+WeU0Omg/Bp5/ 5RTe554T4cYf/gZrWx17tPovgeewTybZMD4MnrYrEloSQhcaqnkA6pSHgayHN6scPA8GUFYWF+ioC aSEsJUrwr8P+6Hi9qBAy/+blgX6pBITNUWmX2skq5HEr7GKz2FN0wdaR1QBe8X/XRxN3+WnSC9IA7 DHtTLDqosWpf74LZ5W6MINExq2Y2XmbtYwPKrIlpdiXPlppOKoK7rPKbLEZ3KUAp+3ClvJB6ulnj3 oPbO09ECdDgfpjCTXH7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ntPec-007D2K-R9; Tue, 24 May 2022 08:12:34 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ntPeY-007D0t-Sp for linux-arm-kernel@lists.infradead.org; Tue, 24 May 2022 08:12:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653379948; 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: content-transfer-encoding:content-transfer-encoding; bh=vrj/sayM80RGEEGyY0KC0sGkY2iaaQz1Te5aknMB76E=; b=ZY/Hd7o/qXohBhDdtr3R/cZIqVul+g/DlV+j3jFVf+1dsudzoAfnDYoGImQcAA0wFTP0kT wHZQf4td8J9qDuJeiBucuR4dNkz/1msnhau3vVaihAK20BeQyUKlWpWBxqs+TThGDL96X1 TTUvFS1uVF0WBsEi4dSTuLT7llDSqgE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-209-Pt8V-noAO0i1TWZslY78wQ-1; Tue, 24 May 2022 04:12:24 -0400 X-MC-Unique: Pt8V-noAO0i1TWZslY78wQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE752858F00; Tue, 24 May 2022 08:12:23 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-91.pek2.redhat.com [10.72.12.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 191D2492C14; Tue, 24 May 2022 08:12:18 +0000 (UTC) From: Gavin Shan To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, rafael@kernel.org, Jonathan.Cameron@huawei.com, drjones@redhat.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH] arch_topology: Limit threads to one specific cluster Date: Tue, 24 May 2022 16:12:12 +0800 Message-Id: <20220524081212.1363105-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220524_011231_077908_6F5CF0DE X-CRM114-Status: GOOD ( 15.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The sibling information for one particular CPU is updated after ACPI PPTT table is parsed. struct cpu_topology::thread_sibling tracks the the CPUs in same core. However, cluster isn't considered when it's populated. In this case, multiple threads belonging to different clusters can be put together through the sibling information. It eventually leads to unexpected warning from sched subsystem. For example, the following warning is observed in a VM where we have 2 sockets, 4 clusters, 8 cores and 16 threads and the CPU topology is populated as below. CPU Socket-ID Cluster-ID Core-ID Thread-ID ---------------------------------------------- 0 0 0 0 0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 0 0 9 1 0 0 1 10 1 0 1 0 11 1 0 1 1 12 1 1 0 0 13 1 1 0 1 14 1 1 1 0 15 1 1 1 1 [ 0.592181] CPU: All CPU(s) started at EL1 [ 0.593766] alternatives: patching kernel code [ 0.595890] BUG: arch topology borken [ 0.597210] the SMT domain not a subset of the CLS domain [ 0.599286] child=0-1,4-5 sd=0-3 # cat /sys/devices/system/cpu/cpu0/topology/cluster_cpus_list 0-3 # cat /sys/devices/system/cpu/cpu0/topology/thread_siblings_list 0-1,4-5 This fixes the issue by limiting threads to one specific cluster. With this applied, the unexpected warning disappears in the VM. # cat /sys/devices/system/cpu/cpu0/topology/cluster_cpus_list 0-3 # cat /sys/devices/system/cpu/cpu0/topology/thread_siblings_list 0-1 Signed-off-by: Gavin Shan --- drivers/base/arch_topology.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index f73b836047cf..25a63a89ae7d 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -710,7 +710,8 @@ void update_siblings_masks(unsigned int cpuid) cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); - if (cpuid_topo->core_id != cpu_topo->core_id) + if (cpuid_topo->cluster_id != cpu_topo->cluster_id || + cpuid_topo->core_id != cpu_topo->core_id) continue; cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling); -- 2.23.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel