Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3355780rwb; Tue, 8 Nov 2022 03:43:26 -0800 (PST) X-Google-Smtp-Source: AMsMyM4O9NEiucazhSgTHgolcUCtope1LdZ4+amazF0PXwRd31TlYNkSsKFjDllW6oQywBcMIOmO X-Received: by 2002:a05:6402:322:b0:463:ba70:42de with SMTP id q2-20020a056402032200b00463ba7042demr39279477edw.380.1667907806704; Tue, 08 Nov 2022 03:43:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667907806; cv=none; d=google.com; s=arc-20160816; b=L52x9i3nB4Cyq1OrGmm2TaoU0udcYKyJxhm3SA29NAYIFb+OKtMDonUfs3PlaaWjfS GXdYFr7dXmXHIJG0YfAMl3LvsKuqyO0q0g0OxVfvEJoSQTtAzbPyCRonowA35PtrxPPt BauRObXoGfga0/STXYjTjcg9RUbmWp56qZ/HnwQC81zxkYSAc/SIB+PPYsDzk7NZ3THc 3MtQUsbe9maBWrbwki2mJsvcmHLg4WhHgKqLuS90HGLNh16Z7TotLrpDfQGs65v/8eB1 88neLKoqIFq4GNdpyeHrAP+RyT/P0MQkcDw9/03bCKGDCPV8tZ9huQdPDJarVbhO0l3R Eg/Q== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=kigthx8X/rtzq1/blNiByeuL0sNsHFR4E2GokYE3LOs=; b=QRYgRZqUjtODdU6EHqKwBxRrTEpSg6MJdWizV1Cky6m7kcKctrIeUl5QFfjuxokOty nrgYaeYvkeM1wx5zGisRFALM3TKXk+0hm9Gx8ueS/soZd9CQGPNBWS9lOXA4ZGTbZdDA IposPg9B8SvSjw1FmZbRse3280iNl3nldlW2meYPrOwZXTiV2WSh8KzYe0vCHyZGJ3ZA +GXfE85GKUbYyDvanr+wx8sne9/D+Wh/kRVL6JGXbk85w2aoLk0vzW7xDJllpOQC4U4h 42yl112Bqo+RV80/fbaZTdmcSDyL/ulZPl0VYOxKaeZwA+NNP2AkCwDZF95Ve3AHw0pU LKDw== 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 dt16-20020a170907729000b007acf3aed468si13873108ejc.786.2022.11.08.03.43.05; Tue, 08 Nov 2022 03:43:26 -0800 (PST) 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 S233999AbiKHLMD (ORCPT + 89 others); Tue, 8 Nov 2022 06:12:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233976AbiKHLL5 (ORCPT ); Tue, 8 Nov 2022 06:11:57 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D09631007; Tue, 8 Nov 2022 03:11:56 -0800 (PST) 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 B2C1F1424; Tue, 8 Nov 2022 03:12:02 -0800 (PST) Received: from [192.168.1.12] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6D56C3F534; Tue, 8 Nov 2022 03:11:53 -0800 (PST) Message-ID: <554c4bf5-8981-3d0e-6cd4-68fc854bcb09@arm.com> Date: Tue, 8 Nov 2022 12:11:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 0/5] arch_topology: Build cacheinfo from primary CPU To: linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J. Wysocki" , Len Brown , Sudeep Holla , Greg Kroah-Hartman , Gavin Shan , SeongJae Park , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, Jeremy Linton , Rob Herring References: <20221108110424.166896-1-pierre.gondois@arm.com> Content-Language: en-US From: Pierre Gondois In-Reply-To: <20221108110424.166896-1-pierre.gondois@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 + Rob Herring + Jeremy Linton On 11/8/22 12:04, Pierre Gondois wrote: > [1] and [2] build the CPU topology from the cacheinfo information for > both DT/ACPI based systems and remove (struct cpu_topology).llc_id > which was used by ACPI only. > > Creating the cacheinfo for secondary CPUs is done during early boot. > Preemption and interrupts are disabled at this stage. On PREEMPT_RT > kernels, allocating memory (and parsing the PPTT table for ACPI based > systems) triggers a: > 'BUG: sleeping function called from invalid context' [4] > > To prevent this bug, allocate the cacheinfo from the primary CPU when > preemption and interrupts are enabled and before booting secondary > CPUs. The cache levels/leaves are computed from DT/ACPI PPTT information > only, without relying on the arm64 CLIDR_EL1 register. > If no cache information is found in the DT/ACPI PPTT, then fallback > to the current state, triggering [4] on PREEMPT_RT kernels. > > Patches to update the arm64 device trees that have incomplete cacheinfo > (mostly for missing the 'cache-level' or 'cache-unified' property) > have been sent at [3]. > > Tested platforms: > - ACPI + PPTT: Ampere Altra, Ampere eMAG, Cavium ThunderX2, > Kunpeng 920, Juno-r2 > - DT: rb5, db845c, Juno-r2 > > [1] https://lore.kernel.org/all/20220704101605.1318280-1-sudeep.holla@arm.com/ > [2] https://lore.kernel.org/all/20220720-arch_topo_fixes-v3-0-43d696288e84@arm.com/ > [3] https://lore.kernel.org/all/20221107155825.1644604-1-pierre.gondois@arm.com/ > [4] On an Ampere Altra, with PREEMPT_RT kernel based on v6.0.0-rc4: > > > [ 7.560791] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46 > [ 7.560794] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/111 > [ 7.560796] preempt_count: 1, expected: 0 > [ 7.560797] RCU nest depth: 1, expected: 1 > [ 7.560799] 3 locks held by swapper/111/0: > [ 7.560800] #0: ffff403e406cae98 (&pcp->lock){+.+.}-{3:3}, at: get_page_from_freelist+0x218/0x12c8 > [ 7.560811] #1: ffffc5f8ed09f8e8 (rcu_read_lock){....}-{1:3}, at: rt_spin_trylock+0x48/0xf0 > [ 7.560820] #2: ffff403f400b4fd8 (&zone->lock){+.+.}-{3:3}, at: rmqueue_bulk+0x64/0xa80 > [ 7.560824] irq event stamp: 0 > [ 7.560825] hardirqs last enabled at (0): [<0000000000000000>] 0x0 > [ 7.560827] hardirqs last disabled at (0): [] copy_process+0x5dc/0x1ab8 > [ 7.560830] softirqs last enabled at (0): [] copy_process+0x5dc/0x1ab8 > [ 7.560833] softirqs last disabled at (0): [<0000000000000000>] 0x0 > [ 7.560834] Preemption disabled at: > [ 7.560835] [] migrate_enable+0x30/0x130 > [ 7.560838] CPU: 111 PID: 0 Comm: swapper/111 Tainted: G W 6.0.0-rc4-[...] > [ 7.560841] Call trace: > [...] > [ 7.560870] __kmalloc+0xbc/0x1e8 > [ 7.560873] detect_cache_attributes+0x2d4/0x5f0 > [ 7.560876] update_siblings_masks+0x30/0x368 > [ 7.560880] store_cpu_topology+0x78/0xb8 > [ 7.560883] secondary_start_kernel+0xd0/0x198 > [ 7.560885] __secondary_switched+0xb0/0xb4 > > Pierre Gondois (5): > cacheinfo: Use riscv's init_cache_level() as generic OF implem > cacheinfo: Return error code in init_of_cache_level() > ACPI: PPTT: Remove acpi_find_cache_levels() > ACPI: PPTT: Update acpi_find_last_cache_level() to > acpi_get_cache_info() > arch_topology: Build cacheinfo from primary CPU > > arch/arm64/kernel/cacheinfo.c | 9 ++- > arch/riscv/kernel/cacheinfo.c | 39 +------------ > drivers/acpi/pptt.c | 86 +++++++++++++++++------------ > drivers/base/arch_topology.c | 10 +++- > drivers/base/cacheinfo.c | 101 ++++++++++++++++++++++++++++++---- > include/linux/cacheinfo.h | 10 +++- > 6 files changed, 164 insertions(+), 91 deletions(-) >