Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp174648pxb; Thu, 31 Mar 2022 02:35:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy20bthfGU3IodJVDLo+RyFwI1hgusU0q4Z7LVMbMTIo+rqId3ZT1miNh3z246lB3REVlxa X-Received: by 2002:a63:d442:0:b0:382:6f4e:d49f with SMTP id i2-20020a63d442000000b003826f4ed49fmr10000705pgj.7.1648719317369; Thu, 31 Mar 2022 02:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648719317; cv=none; d=google.com; s=arc-20160816; b=pGAxG4jbc3OjqUSmz7ncaWLQziilq6bTxy7ym5aVapW7tPbLn39VNcNvOI3PzujsyZ hc/oOlFiYJFDzHp4SkdnBGqp9WpGEyNFDyx5Zhbxi6rB7MnN85ecnmWjINh94CAhwl4q tFSIqsn61GtAbclZjoLoPLHchZU3CSz8Pp7TK/neC4GVYqP7YBjtd4Rrn4y+6Qn2MfEC 0ivVjFablKTDiRitswFsvwFQxNcft3HMzogabnw9VX2CveESFRWJ2j14L/nxJkepIAGR 0UKEEocK9gSTXbMrBY/qjo/+936hGkOZgGXRRMqs0EOCCjyiWlkeCjHDZdrRorVkfrsq dTxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=N+UlQkZkjwlak3k6tS28dlqa4H8fudY9oObuMyfSA0Y=; b=BuAbbt0yg5j7MzsQl6mXEiixKmfKCq2jPj4l9ZvwZX7Ui3v4F60RkGhp9l3NAnS48I nI01BXSxUqEHrSLC9A2gqA0VQer6m9RRNWll4ruRtGWIO71toNZzcjgOL8UFWVT6Q7Pg 1UNytyk0ItEfvVhZ/JxIHusCqpQJt7nLaGP+r01E4lAT0Hep5RbGwkL5EnvjmkjHyJoF 0RlEUB8q3bEd54AzJJdEZY97xqcnGQr1iyxelF9OJRfASM90nZKN7UB1rXlxuO1qWiQY 2bjpKm/MWIx3+HIRhHyFB9kjqIXbuPEenOopTVftPWNjWl9WrbpUNP+vWJInNfUvqkiK N8Pw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w23-20020a170902d71700b0015498a2b02bsi21734875ply.316.2022.03.31.02.35.05; Thu, 31 Mar 2022 02:35:17 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233482AbiCaJGW (ORCPT + 99 others); Thu, 31 Mar 2022 05:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232196AbiCaJGV (ORCPT ); Thu, 31 Mar 2022 05:06:21 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 76F74C1E for ; Thu, 31 Mar 2022 02:04:34 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0517723A; Thu, 31 Mar 2022 02:04:34 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8DA283F718; Thu, 31 Mar 2022 02:04:32 -0700 (PDT) Message-ID: <66f29bee-e26c-b40e-c3af-79d5297565d8@arm.com> Date: Thu, 31 Mar 2022 11:04:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2] arch/arm64: Fix topology initialization for core scheduling Content-Language: en-US To: Phil Auld , linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , Peter Zijlstra , linux-arm-kernel@lists.infradead.org References: <20220330155611.30216-1-pauld@redhat.com> From: Dietmar Eggemann In-Reply-To: <20220330155611.30216-1-pauld@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,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 30/03/2022 17:56, Phil Auld wrote: > Arm64 systems rely on store_cpu_topology() to call update_siblings_masks() > to transfer the toplogy to the various cpu masks. This needs to be done > before the call to notify_cpu_starting() which tells the scheduler about > each cpu found, 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. > > v2: Fixed the commit message. No code change. Ah, the reason is that smt_mask is not correctly setup, so we bail on `cpumask_weight(smt_mask) == 1` for !leaders in: notify_cpu_starting() cpuhp_invoke_callback_range() sched_cpu_starting() sched_core_cpu_starting() which leads to rq->core not being correctly set for !leader-rq's. LGTM. Tested on: HPE Apollo 70 X1 Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann [...]