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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EEECC433EF for ; Tue, 29 Mar 2022 15:20:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238416AbiC2PWD (ORCPT ); Tue, 29 Mar 2022 11:22:03 -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 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); > > > > /* > -- 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 8EFE2C433EF for ; Tue, 29 Mar 2022 15:21:37 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=S8g9S6p4FPTyVLKxBdDA3gq9MBzNPaThhKA09SFM48Y=; b=YofCvwWu62YgFR EZsRfDgZbKRGyBN5mXf/6z5FGGLOwzqQLKKy0BKIk5sssSHJN7ODs3O0f43yhvf2ms0Gc24Sv7NTX +bjUreHMxfXi4faNSFMUFFAIfk26iqtaQLOajXT8s1gO14fk+2LYw5l5vVpmGr1sng8PRyDGm+PnT mO28cE5DhC6VzNTbGcVouQZTJNhZazsbS2h5YjSq4Fa2gc0gFcoUy2rS32d4+JlUmtXJmYIE6FPm8 cIpeKzFoS2SLjHWwMM1ybKzLP1sw2fTM4DqOfJYgm3q9H2IyCA8pxUH8K9ylHq/h58sOoBqg9BC5T UG1Sh4WHrxnv5AJNeyRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZDdw-00CdUS-Q9; Tue, 29 Mar 2022 15:20:24 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZDds-00CdTL-0e for linux-arm-kernel@lists.infradead.org; Tue, 29 Mar 2022 15:20:23 +0000 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-Disposition: inline In-Reply-To: <1a546197-872b-7762-68ac-d5e6bb6d19aa@arm.com> 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-20220329_082022_210533_9973BBEE X-CRM114-Status: GOOD ( 30.91 ) 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 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); > > > > /* > -- _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel