Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4952456rdb; Tue, 12 Dec 2023 14:23:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtJYcjdeR9tlxaji/N+dTztfz1mZgiqyBa8GVNu3qfO/T6DWIFFqXs20k3U/FT/DRDjUvI X-Received: by 2002:a05:6a20:72a2:b0:18b:acc8:a5ed with SMTP id o34-20020a056a2072a200b0018bacc8a5edmr9974875pzk.8.1702419834170; Tue, 12 Dec 2023 14:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702419834; cv=none; d=google.com; s=arc-20160816; b=rbiQIQC2HusqvjvXuW37VeNlbW8KELxDnCCMAj0et08QXOHjf7JW4RHtZf2kRxeXC4 ewjzbiylPqFnH2tXm5TwWnAFiMGwJdXcTBr/xFTBrJmvZqdyHiptToy2A5gmedGc+cuU 9EUE5lBbCYpVIwY/gTiuW3lJO8yqVgPeu7X2JOrmX8l14sT6EmxwYcWHRvvHGnCEV+Sm zu/CheqEKe58Bssta1SCp3A9oG1uJFwVi9dSFhyKpxvgCxQALu+Me9jVHNlfmYrnn6CK e0o0PrH42XXickjh7Pmkr7Z8/V4QzFH9GiygiGrdEGttZxnGQVIuTtw/cCEzyP5BS+Jd 3uuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=F6QDt9QFMk43j8iGFrzL5Xz6691gZkKUbpKm+xyZx7o=; fh=Gut/J0NXkZgJfYdQtFIDispGG3aQPTNOt2YyyrQa9Is=; b=P/VnBGuHF+r2+RR9gd9Muhgb2zB5kMaayGthJep5FLiqZGd1SXn5l3/SXCRSVgskPG Jfj5BBNqeHVdOc11AhkZhlV9cPKDcCKAQqVqtYUH0tLBRiI82DwhC06VZCJvskAF4VQ+ WjysrRGrngkLPq+VN6D50f9B+e1H12UrlozYbC3QCUUjx8VcCMJWVU56OvZsuVm4ipfx m6d9v5crQ++hQc5eL9WqVsyBS/wgeoWsLECIMyXiQSn4rizpBzdTX8/OiEIhECIR8Vip TVZ6LTNYeMY4Muwf8P7+lFLBDCeswyCrmrtxnduYBXZbEcSxMR00C9u+iqD4Q1JC2ewY xbkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nLOX+AKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k24-20020a63ba18000000b005c6eb4bc772si6793069pgf.844.2023.12.12.14.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 14:23:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nLOX+AKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 718C980ADEEA; Tue, 12 Dec 2023 14:23:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377806AbjLLWXb (ORCPT + 99 others); Tue, 12 Dec 2023 17:23:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377782AbjLLWXa (ORCPT ); Tue, 12 Dec 2023 17:23:30 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 465DBCF; Tue, 12 Dec 2023 14:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702419816; x=1733955816; h=from:to:cc:subject:date:message-id; bh=bs2Pt5v1W0sFAFjRahx11+5bS/VM2UK4YvQBDFDNmSA=; b=nLOX+AKsZ9ddRAP3cZ+wrq8Sta8VL4MLnZt/uGqi5zGkL5VgaRSJiXhy VdZ37btXCMJIbn43K1nIjEnDpcnJ63I60K0VhuGu2g2YsFCF1xqxPzKhh z7fWt/hQPIkccfrQr9R24EPPCHPTLc/cRHfcDwZ078pXzcr5IHbBnTXUI QXGZttfamn6c0wlpMD7eLRj4UzowL4cBrbeZVU7AoTqGFi/3khrxbM5an mFLxeJM0JE5VSdjo0nJNeFMwSd3SjKNfldQTdXkhB1Th5iTZZMcX04qrP El23mOcUumrxwmbNsFQNbyxFOkVxdm6NoMcWmItfSr//yrEu2NxszsEi3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="2049297" X-IronPort-AV: E=Sophos;i="6.04,271,1695711600"; d="scan'208";a="2049297" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 14:23:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="802631179" X-IronPort-AV: E=Sophos;i="6.04,271,1695711600"; d="scan'208";a="802631179" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga008.jf.intel.com with ESMTP; 12 Dec 2023 14:23:35 -0800 From: Ricardo Neri To: x86@kernel.org Cc: Andreas Herrmann , Catalin Marinas , Chen Yu , Len Brown , Radu Rendec , Pierre Gondois , Pu Wen , "Rafael J. Wysocki" , Sudeep Holla , Srinivas Pandruvada , Will Deacon , Zhang Rui , Huang Ying , "Ravi V. Shankar" , stable@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri Subject: [PATCH v4 0/4] x86/cacheinfo: Set the number of leaves per CPU Date: Tue, 12 Dec 2023 14:25:15 -0800 Message-Id: <20231212222519.12834-1-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 14:23:48 -0800 (PST) Hi, The interface /sys/devices/system/cpu/cpuX/cache is broken (not populated) if CPUs have different numbers of subleaves in CPUID 4. This is the case of Intel Meteor Lake. This is v4 of a patchset to fix the cache sysfs interface by setting the number of cache leaves independently for each CPU. v1, v2, and v3 can be found here[1], here[2], and here[3]. All the tests described in [4] passed. Changes since v3: * Fixed another NULL-pointer dereference when checking the validity of the last-level cache info. * Added the Reviewed-by tags from Radu and Sudeep. Thanks! * Rebased on v6.7-rc5. Changes since v2: * This version uncovered a NULL-pointer dereference in recent changes to cacheinfo[5]. This dereference is observed when the system does not configure cacheinfo early during boot nor makes corrections later during CPU hotplug; as is the case in x86. Patch 1 fixes this issue. Changes since v1: * Dave Hansen suggested to use the existing per-CPU ci_cpu_cacheinfo variable. Now the global variable num_cache_leaves became useless. * While here, I noticed that init_cache_level() also became useless: x86 does not need ci_cpu_cacheinfo::num_levels. Thanks and BR, Ricardo [1]. https://lore.kernel.org/lkml/20230314231658.30169-1-ricardo.neri-calderon@linux.intel.com/ [2]. https://lore.kernel.org/all/20230424001956.21434-1-ricardo.neri-calderon@linux.intel.com/ [3]. https://lore.kernel.org/lkml/20230805012421.7002-1-ricardo.neri-calderon@linux.intel.com/ [4]. https://lore.kernel.org/lkml/20230912032350.GA17008@ranerica-svr.sc.intel.com/ [5]. https://lore.kernel.org/all/20230412185759.755408-1-rrendec@redhat.com/ Ricardo Neri (4): cacheinfo: Check for null last-level cache info cacheinfo: Allocate memory for memory if not done from the primary CPU x86/cacheinfo: Delete global num_cache_leaves x86/cacheinfo: Clean out init_cache_level() arch/x86/kernel/cpu/cacheinfo.c | 49 +++++++++++++++++---------------- drivers/base/cacheinfo.c | 9 +++++- 2 files changed, 34 insertions(+), 24 deletions(-) -- 2.25.1