Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1757892pxb; Wed, 30 Mar 2022 09:31:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycutyKWtARcUWJjkiizfMW6qOrbL1HCwvkJSzsY5fyBVOUYjZ9VNexNUK/J6aYElLrczbz X-Received: by 2002:a67:b60a:0:b0:325:5b49:31d2 with SMTP id d10-20020a67b60a000000b003255b4931d2mr9014vsm.51.1648657875617; Wed, 30 Mar 2022 09:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648657875; cv=none; d=google.com; s=arc-20160816; b=cTvITkq4yxcooyWQGjUE3piHo6LB/iA4Srbf0EfvEag7PZdvCdJZEK47DQsWkY7GK2 natQPglwF4MzTRuP7j+kU7Mvtt97qme/NOePPb8yIkFPxQrHf0i3fHPe5o2pXsKMIk1t kMdBe0CBb36Z+7zd+FeHyvyaknkENUyMgjSt8Uy4pmcpZj6+4cMX77DyTdQQCcJTMTBS e4zIXj0ileegky+DB6j8XxxCGsj81VWhOD3qDlBxY8U+GGZJc/YlPA8uCNsIwAz1CztM D05W2YkmVzKj7msZRhvX1HIlx/B9dFFCQ6uI6YDq3dhvDHhjRKbrbjXtLxf8yKuidGbL Ol/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OLZFkHPd84+mMxkqVvITeO3JzREE8dZrviAJPbx3+4I=; b=NF+/WNMA/Yc8Z5Js9fxPLvbgqnoXwcjWQYOUuYkKjxEBpyHMTgQZwNnmPs/nxf9Y/Z X7oGiCl5AsWMAsAO6LTRifEIH5jQeysN987qMV0044laX4/sha+xrJWE7YIozEM76ohI ukl3WR3X8GT7r5Xl05U754xM+M14QxEBLHg+phhpjzkzx7DeLC64IlE87fA7loXDfOBA fNpxVyUrhMl8buvCkvAt3RWWFm2CXsRKIPKAb3aXsZkonF68lLJSJQEEBAQfvwJgOtoV O4iX4uCd+Oryj1GSLWP82XQ7SVlXhsBaspIEQWsgih8ioNBrsl3IKwjckP8MhSRPgklb 2rJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AXq1IUaN; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020ac5c966000000b003430fb3072bsi4625616vkm.72.2022.03.30.09.30.59; Wed, 30 Mar 2022 09:31:15 -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=@redhat.com header.s=mimecast20190719 header.b=AXq1IUaN; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237421AbiC2PWC (ORCPT + 99 others); Tue, 29 Mar 2022 11:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235516AbiC2PWA (ORCPT ); Tue, 29 Mar 2022 11:22:00 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 05FC97CB02 for ; Tue, 29 Mar 2022 08:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648567215; 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=OLZFkHPd84+mMxkqVvITeO3JzREE8dZrviAJPbx3+4I=; b=AXq1IUaNJxTCUm5PrXXl/AxbxZYRPmQFblPyyvIQQIT/t+PwYuCvyfx+XNW3SWaAXyg39e 6rJzDVDDM9bQ3w0PqESPWio3/+8Kn0WayVRX2kxAaJhNrwCYQpt1hQZxe8o134JzYYdZJL a5oLBSfMT6RHJbyrYaKKwY4fG3GEw84= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-578-W1OjL56oN_2guaUe-84Avw-1; Tue, 29 Mar 2022 11:20:12 -0400 X-MC-Unique: W1OjL56oN_2guaUe-84Avw-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 78BC2296A62D; Tue, 29 Mar 2022 15:20:11 +0000 (UTC) Received: from lorien.usersys.redhat.com (unknown [10.22.8.232]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30A34400F24; Tue, 29 Mar 2022 15:20:11 +0000 (UTC) Date: Tue, 29 Mar 2022 11:20:09 -0400 From: Phil Auld To: Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , Mark Rutland , Peter Zijlstra , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] arch/arm64: Fix topology initialization for core scheduling Message-ID: References: <20220322160304.26229-1-pauld@redhat.com> <1a546197-872b-7762-68ac-d5e6bb6d19aa@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1a546197-872b-7762-68ac-d5e6bb6d19aa@arm.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 On Tue, Mar 29, 2022 at 04:02:22PM +0200 Dietmar Eggemann wrote: > On 22/03/2022 17:03, Phil Auld wrote: > > Some arm64 rely on store_cpu_topology() to setup the real topology. > > This needs to be done before the call to notify_cpu_starting() which > > tell the scheduler about the cpu otherwise the core scheduling data > > structures are setup in a way that does not match the actual topology. > > > > Without this change stress-ng (which enables core scheduling in its prctl > > tests) causes a warning and then a crash (trimmed for legibility): > > > > [ 1853.805168] ------------[ cut here ]------------ > > [ 1853.809784] task_rq(b)->core != rq->core > > [ 1853.809792] WARNING: CPU: 117 PID: 0 at kernel/sched/fair.c:11102 cfs_prio_less+0x1b4/0x1c4 > > ... > > [ 1854.015210] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 > > ... > > [ 1854.231256] Call trace: > > [ 1854.233689] pick_next_task+0x3dc/0x81c > > [ 1854.237512] __schedule+0x10c/0x4cc > > [ 1854.240988] schedule_idle+0x34/0x54 > > > > Fixes: 9edeaea1bc45 ("sched: Core-wide rq->lock") > > Signed-off-by: Phil Auld > > --- > > This is a similar issue to > > f2703def339c ("MIPS: smp: fill in sibling and core maps earlier") > > which fixed it for MIPS. > > I assume this is for a machine which relies on MPIDR-based setup > (package_id == -1)? I.e. it doesn't have proper ACPI/(DT) data for > topology setup. Yes, that's my understanding. No PPTT. > > Tried on a ThunderX2 by disabling parse_acpi_topology() but then I end > up with a machine w/o SMT, so `stress-ng --prctl N` doesn't show this issue. > > Which machine were you using? This instance is an HPE Apollo 70 set to smt-4. I believe it's ThunderX2 chips. ARM (CN9980-2200LG4077-Y21-G) Thanks, Phil > > > arch/arm64/kernel/smp.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > > index 27df5c1e6baa..3b46041f2b97 100644 > > --- a/arch/arm64/kernel/smp.c > > +++ b/arch/arm64/kernel/smp.c > > @@ -234,6 +234,7 @@ asmlinkage notrace void secondary_start_kernel(void) > > * Log the CPU info before it is marked online and might get read. > > */ > > cpuinfo_store_cpu(); > > + store_cpu_topology(cpu); > > > > /* > > * Enable GIC and timers. > > @@ -242,7 +243,6 @@ asmlinkage notrace void secondary_start_kernel(void) > > > > ipi_setup(cpu); > > > > - store_cpu_topology(cpu); > > numa_add_cpu(cpu); > > > > /* > --