Re: [PATCH v4 1/4] cacheinfo: Check for null last-level cache info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <aherrmann@xxxxxxxx>
> Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
> Cc: Chen Yu <yu.c.chen@xxxxxxxxx>
> Cc: Huang Ying <ying.huang@xxxxxxxxx>
> Cc: Len Brown <len.brown@xxxxxxxxx>
> Cc: Radu Rendec <rrendec@xxxxxxxxxx>
> Cc: Pierre Gondois <Pierre.Gondois@xxxxxxx>
> Cc: Pu Wen <puwen@xxxxxxxx>
> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
> Cc: Sudeep Holla <sudeep.holla@xxxxxxx>

If you respin, you can address the below minor nit. I am fine as is as
well.

Reviewed-by: Sudeep Holla <sudeep.holla@xxxxxxx>

[...]

> 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




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux