Re: [RFC PATCH v2 2/4] percpu: Assorted fixes found by strict percpu address space checks
From: Nadav Amit
Date: Mon Aug 12 2024 - 15:09:27 EST
> On 12 Aug 2024, at 14:57, Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
> Assorted fixes to prevent defconfig build failures when
> strict percpu address space checks will be enabled.
>
> These show effeciveness of strict percpu address space checks.
[snip]
> --- a/drivers/base/devres.c
> +++ b/drivers/base/devres.c
> @@ -1231,6 +1231,6 @@ void devm_free_percpu(struct device *dev, void __percpu *pdata)
> * devm_free_pages() does.
> */
> WARN_ON(devres_release(dev, devm_percpu_release, devm_percpu_match,
> - (__force void *)pdata));
> + (__force void *)(uintptr_t)pdata));
>
Since this pattern of casting appears multiple times (sometimes slightly
different), I think it would be best to give a name for this operation
and put it behind a macro.
This would allow both to audit the cases developers move data between
address-spaces, and also make them think whether what they do makes
sense.