Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2151003rwl; Thu, 13 Apr 2023 02:17:20 -0700 (PDT) X-Google-Smtp-Source: AKy350bkC1h1iXBMV16/Hty1tNu4XCaTqEvwpOleNrMaeGB0vKHu0yYErjs/p2b6abqe8SCENsa1 X-Received: by 2002:a17:902:e887:b0:1a5:1a3a:692d with SMTP id w7-20020a170902e88700b001a51a3a692dmr2125193plg.22.1681377439669; Thu, 13 Apr 2023 02:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681377439; cv=none; d=google.com; s=arc-20160816; b=dXIF/eiLJwPnhXTA7PuNrQtNBFfeRsugh2p4UW14CNdqqRuJOZT6rv0naM+w+yytzt /CQNCnEXhu07O4BrDnqXAutEbiPBB1SfSZozSBBcWfwte5barxcEQYvqjouKGzzSXNaR 6MTPFPk71sjOR+zVME+t8BLOFrTNWSWNnC0ZXqc4n7vKw15hmOQeF3h+E+Rcoz/l8ORF dhJ16Y3pjiHWVHTier6qHuguMsmEUU20cSal74JYfkDpcxLnno2O0GuHAyETR6LsLBYg 3NUrQBSSNLyXq8/raEWXstUGQz9XIypMdFzGlkN2oiV/LpaQgjureevqX2KYmpyx8f6N HozQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TiI5qWV66DyQ6Y1AihYu0pa5BGXncmCb2peUQxVcwyU=; b=y2Gpmo/mOUr1RnKd+aZEG5G66yWM/RXKUPegq0AlTxPkTFNlDpKbW7WCJV93rOxsbt Qm52tqXMTm8Cwr7+FIZ4wCsDQwxuk6muJbcwKLQE7BXb4d/18CF7lN/XKhFkRK7XQps0 ynRZ5HlV67kBX4uprbFkT3V0GbIKDAqnGuF0SzJRo6kflqxdDGkf7hCRDf8xj9Q4xxQ/ 5x8AyGJjwihnps3iKp/Jezb1EXtcXgf7UKAg95lBTrAi7qKtkEIqqjTDFhahbCbtgPeG l9zokhhUX8tMMKTDU4UnJW8p01889xtsh3YK7elIJFu+jRZUh5Uo3UPz5fjHJBBfFcGK bxdw== 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 bv17-20020a17090af19100b00247101dd0c1si1509799pjb.15.2023.04.13.02.17.08; Thu, 13 Apr 2023 02:17:19 -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 S230194AbjDMJPL (ORCPT + 99 others); Thu, 13 Apr 2023 05:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230219AbjDMJPF (ORCPT ); Thu, 13 Apr 2023 05:15:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 890477DA5 for ; Thu, 13 Apr 2023 02:15:03 -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 B02AF13D5; Thu, 13 Apr 2023 02:15:47 -0700 (PDT) Received: from pierre123.nice.arm.com (pierre123.nice.arm.com [10.34.100.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 938C03F6C4; Thu, 13 Apr 2023 02:15:01 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Radu Rendec , Alexandre Ghiti , Conor Dooley , Will Deacon , Pierre Gondois , Sudeep Holla , Greg Kroah-Hartman , "Rafael J. Wysocki" , Palmer Dabbelt , Gavin Shan Subject: [PATCH v3 1/4] cacheinfo: Check sib_leaf in cache_leaves_are_shared() Date: Thu, 13 Apr 2023 11:14:31 +0200 Message-Id: <20230413091436.230134-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230413091436.230134-1-pierre.gondois@arm.com> References: <20230413091436.230134-1-pierre.gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 If there is no ACPI/DT information, it is assumed that L1 caches are private and L2 (and higher) caches are shared. A cache is 'shared' between two CPUs if it is accessible from these two CPUs. Each CPU owns a representation (i.e. has a dedicated cacheinfo struct) of the caches it has access to. cache_leaves_are_shared() tries to identify whether two representations are designating the same actual cache. In cache_leaves_are_shared(), if 'this_leaf' is a L2 cache (or higher) and 'sib_leaf' is a L1 cache, the caches are detected as shared as only this_leaf's cache level is checked. This is leads to setting sib_leaf as being shared with another CPU, which is incorrect as this is a L1 cache. Check 'sib_leaf->level'. Also update the comment as the function is called when populating 'shared_cpu_map'. Fixes: f16d1becf96f ("cacheinfo: Use cache identifiers to check if the caches are shared if available") Signed-off-by: Pierre Gondois --- drivers/base/cacheinfo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index f3903d002819..c5d2293ac2a6 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -38,11 +38,10 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, { /* * For non DT/ACPI systems, assume unique level 1 caches, - * system-wide shared caches for all other levels. This will be used - * only if arch specific code has not populated shared_cpu_map + * system-wide shared caches for all other levels. */ if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI))) - return !(this_leaf->level == 1); + return (this_leaf->level != 1) && (sib_leaf->level != 1); if ((sib_leaf->attributes & CACHE_ID) && (this_leaf->attributes & CACHE_ID)) -- 2.25.1