Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5218119rwl; Mon, 3 Apr 2023 16:38:53 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0UcotKszcyXCDplay0LCZMAimQKMoVjfRn5EsRj20wIAsFf0bWb2SwAUPw321N0jrXrjg X-Received: by 2002:a05:6402:1a46:b0:502:70e9:2c14 with SMTP id bf6-20020a0564021a4600b0050270e92c14mr703781edb.29.1680565133626; Mon, 03 Apr 2023 16:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680565133; cv=none; d=google.com; s=arc-20160816; b=Q9JlpgDFrNaPurfJdwf9WY7qly84SwADvU11/DjDFezZmbZvxxeUYrhbNnBFsTnhqH wain9iwG59+OVVjb08zlCyl94tTM5mbgY8EeYKlNpGxwfr/2u/on//wxocFmZ+KM/XmW DMCi9ESzDZyMWXWccyuAqe9a7BNDFXKy4HviYIw4B3h2etiRaUtKBzBW2FCqbzHgN/gl 8XWhA6C4HktaSgRFQ60EU5zXm3qv7Dxn4yQWxImWTlRlwslF23ldfqlnwuP6oRkM4zrJ AovK6M/9bPznpiK9n9e47ZpXwcQgYo39BeSdKcWD51q3mX8BymJ1mNqBi44HrQub+w8z Z54Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mKQAlhdwEv2W0Wg0Ync8Qe+weqVP4a18Rc/3M7do/+k=; b=OMDKzhNglO57UmUKMaEZPtJhhVHWEZ57ZO0uy59zMOsfvVyKmAgm627HU9VbgjEO+Y hxfCeJHAyVymu1jI6fwNGvAgok2qz0p5wgW3/7uR/DS4f4YFJB9GQ5uwzXcYvZYU0ocF nrAaFqMHPZ24e0ZbD+IDyKSD6cibpkt4qH/DwL554aUQtyZ9DdGQyq7wdlKlkpcEP66s VycJsx1MH2E3XdsgqlWXol4e4K1/1ZRr7PD/Gg+CxZ+GQ/wo593pEp47sDRyNnZtpu6+ xXm6qpNwUuouwShD+PJ3KeQ9L8q2vvjIoUuxE5SL9JnPGlCHbv9EqKRZaZQuX6I1KQNp 4xxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SN6I9+Lu; 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 q10-20020aa7da8a000000b00501df8f316bsi5979580eds.308.2023.04.03.16.38.29; Mon, 03 Apr 2023 16:38:53 -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=SN6I9+Lu; 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 S233855AbjDCXSz (ORCPT + 99 others); Mon, 3 Apr 2023 19:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232364AbjDCXSy (ORCPT ); Mon, 3 Apr 2023 19:18:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5960E1BC for ; Mon, 3 Apr 2023 16:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680563889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=mKQAlhdwEv2W0Wg0Ync8Qe+weqVP4a18Rc/3M7do/+k=; b=SN6I9+LudE5eQihk5D93/byvLW+eYctktIAoBjG4koQcaib/xY/gPpr7ULFoLo0CzEIGhY mvrBDS2NQeqfV9fbwHt4i+AJiDOw0SuA9IWI0ICFRzUuG1kypp9io+wUrdDdoP0tqLSvFX /fTHOKxvxtg8/DzFRA6Enyy6eo39iqs= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-281-OJdYkzPFM_-d5yAO2cz7UA-1; Mon, 03 Apr 2023 19:18:08 -0400 X-MC-Unique: OJdYkzPFM_-d5yAO2cz7UA-1 Received: by mail-qk1-f198.google.com with SMTP id 195-20020a3705cc000000b00746a3ab9426so13861487qkf.20 for ; Mon, 03 Apr 2023 16:18:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680563887; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mKQAlhdwEv2W0Wg0Ync8Qe+weqVP4a18Rc/3M7do/+k=; b=RnUv4UrCal75Brk1xo/ZOAPKXSjdAWDX+tkfIS6i4ZMhaTO1MaP7/KjhlC29hLcRbo j/kqZ05H3OuTJ44tmu8nDtZzZFdPKZt1GlAgCYPK0VOZqGp1O+63Of1+LbFo4k6eO4ob YIozmJTAOR7sZRb4auvF3rfTe6KF4t3056F4bgOivXLHms8MW+lIpWhiHWqD8QTDa8Yd /sMEzWkViULjoJNdee6YTE3F7XJV0e2d8nDGaN/XQ7wg5gmcYbLLRHStBjA4hjAQJQoR MT0yqMQLfsQrNE33wEGI21khHxvQ8OXj0DxDnuOVRHl/Vpw51RGM+sspARut7O3Zq5SH kk+g== X-Gm-Message-State: AAQBX9dLH2uIQRgK0a/YadfNCJEGyzrmU85N39GMiDfGrwDlXwGitTXR P1uBRpJix31NAZXHztgBBtLgiv42W2cqFKf7CZW90/bjGxrpfaKNe0YE639hE1NNvKd4ggbLnZD AEpK0DN3cRNBp/GS/U2cmRiGd2YMqhxtMv5+8TLk27NKrfA8aRJysxQxCru5VNrczp8WU11bf+/ wHMqa0OqIe3g== X-Received: by 2002:a05:6214:20c7:b0:5bd:74a7:e6f0 with SMTP id 7-20020a05621420c700b005bd74a7e6f0mr888128qve.20.1680563887228; Mon, 03 Apr 2023 16:18:07 -0700 (PDT) X-Received: by 2002:a05:6214:20c7:b0:5bd:74a7:e6f0 with SMTP id 7-20020a05621420c700b005bd74a7e6f0mr888095qve.20.1680563886918; Mon, 03 Apr 2023 16:18:06 -0700 (PDT) Received: from thinkpad-p1.kanata.rendec.net (cpe00fc8d79db03-cm00fc8d79db00.cpe.net.fido.ca. [72.137.118.218]) by smtp.gmail.com with ESMTPSA id v6-20020ad45346000000b005e231177992sm2670207qvs.74.2023.04.03.16.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 16:18:06 -0700 (PDT) From: Radu Rendec To: linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Pierre Gondois , Sudeep Holla , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 0/2] arch_topology: Pre-allocate cacheinfo from primary CPU Date: Mon, 3 Apr 2023 19:15:49 -0400 Message-Id: <20230403231551.1090704-1-rrendec@redhat.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Commit 5944ce092b97 ("arch_topology: Build cacheinfo from primary CPU") tries to build the cacheinfo from the primary CPU prior to secondary CPUs boot, if the DT/ACPI description contains cache information. However, if such information is not present, it still reverts to the old behavior, which allocates the cacheinfo memory on each secondary CPU. On RT kernels, this triggers a "BUG: sleeping function called from invalid context" because the allocation is done before preemption is first enabled on the secondary CPU. The solution is to add cache information to DT/ACPI, but at least on arm64 systems this can be avoided by leveraging automatic detection (through the CLIDR_EL1 register), which is already implemented but currently doesn't work on RT kernels for the reason described above. This patch series attempts to enable automatic detection for RT kernels when no DT/ACPI cache information is available, by pre-allocating cacheinfo memory on the primary CPU. The first patch adds an architecture independent infrastructure that allows architecture specific code to take an early guess at the number of cache leaves of the secodary CPUs, while it runs in preemptible context on the primary CPU. At the same time, it gives architecture specific code the opportunity to go back later, while it runs on the secondary CPU, and reallocate the cacheinfo memory if the initial guess proves to be wrong. The second patch leverages the infrastructure implemented in the first patch and enables early cache depth detection for arm64. The patch series is based on an RFC patch that was posted to the linux-arm-kernel mailing list and discussed with a smaller audience: https://lore.kernel.org/all/20230323224242.31142-1-rrendec@redhat.com/ Radu Rendec (2): cacheinfo: Add arch specific early level initializer cacheinfo: Add arm64 early level initializer implementation arch/arm64/kernel/cacheinfo.c | 32 +++++++++++++++----- drivers/base/cacheinfo.c | 57 +++++++++++++++++++++++------------ include/linux/cacheinfo.h | 2 ++ 3 files changed, 64 insertions(+), 27 deletions(-) -- 2.39.2