2024-05-29 03:22:21

by Youling Tang

[permalink] [raw]
Subject: [PATCH 2/2] prefetch: Add ARCH_HAS_PREFETCH definition when the architecture is not defined

From: Youling Tang <[email protected]>

After commit ab483570a13b ("x86 & generic: change to __builtin_prefetch()"), the
__builtin_prefetch implementation will be used by default, so add its definition
to return to a state similar to before commit[1].

Currently prefetch_range() will be empty implemented under the x86_64 architecture,
there was a concrete implementation before "x86 & generic: change to
__builtin_prefetch()", so fix it.

No similar changes have been made to ARCH_HAS_PREFETCHW at this time.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/include/linux/prefetch.h?id=8e4f2fd31bf737abb392e694898a1496157623b5

Fixes: ab483570a13b ("x86 & generic: change to __builtin_prefetch()")
Signed-off-by: Youling Tang <[email protected]>
---
include/linux/prefetch.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/linux/prefetch.h b/include/linux/prefetch.h
index b068e2e60939..162b7105e37c 100644
--- a/include/linux/prefetch.h
+++ b/include/linux/prefetch.h
@@ -36,6 +36,7 @@ struct page;
*/

#ifndef ARCH_HAS_PREFETCH
+#define ARCH_HAS_PREFETCH
#define prefetch(x) __builtin_prefetch(x)
#endif

--
2.34.1



2024-05-30 15:30:27

by Nikolay Borisov

[permalink] [raw]
Subject: Re: [PATCH 2/2] prefetch: Add ARCH_HAS_PREFETCH definition when the architecture is not defined



On 29.05.24 г. 6:20 ч., Youling Tang wrote:
> From: Youling Tang <[email protected]>
>
> After commit ab483570a13b ("x86 & generic: change to __builtin_prefetch()"), the
> __builtin_prefetch implementation will be used by default, so add its definition
> to return to a state similar to before commit[1].

I find those references to the past state somewhat confusing and not
really adding sustenance to the explanation.

>
> Currently prefetch_range() will be empty implemented under the x86_64 architecture,
> there was a concrete implementation before "x86 & generic: change to
> __builtin_prefetch()", so fix it.

Actually prefetch_range will be empty for every architecture which
doesn't defined ARCH_HAS_PREFETCH and since we have a working generic
fallback this indeed seems backwards. So defining ARCH_HAS_PREFETCH
makes sense.

Reviewed-by: Nikolay Borisov <[email protected]>

>
> No similar changes have been made to ARCH_HAS_PREFETCHW at this time.
>
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/include/linux/prefetch.h?id=8e4f2fd31bf737abb392e694898a1496157623b5
>
> Fixes: ab483570a13b ("x86 & generic: change to __builtin_prefetch()")
> Signed-off-by: Youling Tang <[email protected]>
> ---
> include/linux/prefetch.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/include/linux/prefetch.h b/include/linux/prefetch.h
> index b068e2e60939..162b7105e37c 100644
> --- a/include/linux/prefetch.h
> +++ b/include/linux/prefetch.h
> @@ -36,6 +36,7 @@ struct page;
> */
>
> #ifndef ARCH_HAS_PREFETCH
> +#define ARCH_HAS_PREFETCH
> #define prefetch(x) __builtin_prefetch(x)
> #endif
>