Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1688278rdb; Thu, 25 Jan 2024 03:17:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IESdCu21M3NcY/ZhwTIxZ16fGZhwmmHWeCiQ46dqcwMAz28tZ0OR3C7/T8gnqIS1MABbKDD X-Received: by 2002:a2e:9181:0:b0:2cc:9ec8:fc5a with SMTP id f1-20020a2e9181000000b002cc9ec8fc5amr460772ljg.39.1706181473249; Thu, 25 Jan 2024 03:17:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706181473; cv=pass; d=google.com; s=arc-20160816; b=u3sfkPX6tUUNnok1yJN38Mdvb08saOORn46AYUU+lVkUnSDZXuqt5TlvfMcaSKP5zx fU+NT8zqeZ/nGQ7QRUS/pOpaEO3GhOPWvbIUyGY8UtVRTUSGRPaa3UuqtNq7K+HoxTC3 VzAlWqWM8u8a3nOiVXqwzY4Lk0Fj1h0c0odmcbWHkokiszHyQ4+AhVYDbumvZ0poLhxq riSsZiv6KFEhD/yDCAyRsqHvuCDizboLXXJzV0f337rxwyv2Kh6lvSNWTbrO8xMUETUF OGiuf2jU+SD2cGDbyiIouahQrIEr9pU2az7/bTYULIg2lOnhS3hm5Ey3UouC2WKJW/fS pxCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=VmeQpKgoLSAfrhIrLRx2HuvrvmOJ2F9xSKWzsHptsco=; fh=V19aeQFWJ7JkUX93WTPHmC/oBrIn3OlsaQq89Hqfin0=; b=ae3aZRG9uAk4CK2SiKdW51enXHwmP+BTqJf/TH3gs35KnSyh88sLdj3G/nVWdru36l qv6Lcc7dTUd/nVV4RwqB4jt+/FWINOi6wD0M7PvNd/gI5qBFcvrXLSQLZlZzv+5RuTZx nSEj9WODIwgDIY+Qb84DrNmrIKw36rK5s79O3geuvP4JCbdUorCA34L2oW4I5EdUvXR0 9evwcCZ+T/ITE9JcDiMllEUSl5cJROfsiFVHc+CT1E9JeQQZelkYCoP/eyBgbMYcL6w5 zRJ7KQYZofUOpyOYFpqS0q4lHsirvZ8KmvEkwoDoJ+MOChaMjVn+SZeMYElqDGO4t0K6 XILA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38494-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38494-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b5-20020a50ccc5000000b0055c637f63fesi3487861edj.50.2024.01.25.03.17.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:17:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38494-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38494-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38494-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 017871F21FC6 for ; Thu, 25 Jan 2024 11:17:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3DA32DF87; Thu, 25 Jan 2024 11:15:54 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DECD28DC4; Thu, 25 Jan 2024 11:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181354; cv=none; b=tzATanpQmsuccSM/S+JRGSaVC+9/T4DHUSrwiGHalmrG5OBARKV2HdiwlvwZeSs8LPUKQ+OZWZgt5Jtq4OhYVSy8VXz9DPvgWz/DOjhSxVwSkX6pnqcjH/GQUDVc4oqBmxFEwGjcptxrACEbhrlaJ+YLKXh0X4eiT9foCA01ENU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181354; c=relaxed/simple; bh=LoZQkUCiJrTcqIGsEcCsADbEl/lrWM+ebsBNPEVB6YE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZHHM13aHvkuZEDvfxCwHoHzWj++QPQSWF4Q2T2WjeCNLV2wn1T/jqyCt1wD/0RaykUxXcg9uyzhBs5osJvgPgmKFmp6zMOcW6ROKNzsngYJUyNqmBrbWu/c5afLnCrecGHq7DURgI4VtpfHcvqyZn51c/wVb8ROAQljRX/zsuV8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 CF1841FB; Thu, 25 Jan 2024 03:16:35 -0800 (PST) Received: from bogus (unknown [10.57.78.12]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8A5E73F73F; Thu, 25 Jan 2024 03:15:47 -0800 (PST) Date: Thu, 25 Jan 2024 11:15:44 +0000 From: Sudeep Holla To: Ricardo Neri Cc: x86@kernel.org, Andreas Herrmann , Catalin Marinas , Chen Yu , Len Brown , Sudeep Holla , Radu Rendec , Pierre Gondois , Pu Wen , "Rafael J. Wysocki" , Srinivas Pandruvada , Will Deacon , Zhang Rui , Huang Ying , "Ravi V. Shankar" , stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 1/4] cacheinfo: Check for null last-level cache info Message-ID: <20240125111544.xhiomitgeazxm7cw@bogus> References: <20231212222519.12834-1-ricardo.neri-calderon@linux.intel.com> <20231212222519.12834-2-ricardo.neri-calderon@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212222519.12834-2-ricardo.neri-calderon@linux.intel.com> On Tue, Dec 12, 2023 at 02:25:16PM -0800, Ricardo Neri wrote: > Before determining the validity of the last-level cache info, ensure that > it has been allocated. Simply checking for non-zero cache_leaves() is not > sufficient, as some architectures (e.g., Intel processors) have non-zero > cache_leaves() before allocation. > > Dereferencing NULL cacheinfo can occur in update_per_cpu_data_slice_size(). > This function iterates over all online CPUs. However, a CPU may have come > online recently, but its cacheinfo may not have been allocated yet. > > Cc: Andreas Herrmann > Cc: Catalin Marinas > Cc: Chen Yu > Cc: Huang Ying > Cc: Len Brown > Cc: Radu Rendec > Cc: Pierre Gondois > Cc: Pu Wen > Cc: "Rafael J. Wysocki" > Cc: Sudeep Holla If you respin, you can address the below minor nit. I am fine as is as well. Reviewed-by: Sudeep Holla [...] > diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c > index f1e79263fe61..967c5cf3fb1d 100644 > --- a/drivers/base/cacheinfo.c > +++ b/drivers/base/cacheinfo.c > @@ -61,6 +61,9 @@ bool last_level_cache_is_valid(unsigned int cpu) > if (!cache_leaves(cpu)) > return false; > > + if (!per_cpu_cacheinfo(cpu)) > + return false; > + [nit] You can even combine this with above if condition. -- Regards, Sudeep