From: Heiko Carstens Date: Fri, 8 May 2026 15:02:48 +0000 (+0200) Subject: s390/processor: Implement cpu_relax() with cpu serialization X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=44e5edace5a0d79afa75db09b64746345d26d435;p=thirdparty%2Flinux.git s390/processor: Implement cpu_relax() with cpu serialization There are many loops in the form of while (READ_ONCE(*somelocation)) cpu_relax(); Strictly speaking the architecture requires serialization instead of only a compiler barrier in the loop so the READ_ONCE() will see an updated value. However real hardware does not require this (see IBM z Systems Processor Optimization Primer - FAQ [1]), but it is still recommended to add serialization. Given that cpu_relax() is doing nothing useful, it does not hurt to add the single and fast instruction which makes sure that serialization happens, and such loops may be left a bit faster. [1] https://community.ibm.com/community/user/viewdocument/microprocessor-optimization-primer Reviewed-by: Alexander Gordeev Signed-off-by: Heiko Carstens Signed-off-by: Alexander Gordeev --- diff --git a/arch/s390/include/asm/vdso/processor.h b/arch/s390/include/asm/vdso/processor.h index cfcc3e117c4c9..6775621e5a5a3 100644 --- a/arch/s390/include/asm/vdso/processor.h +++ b/arch/s390/include/asm/vdso/processor.h @@ -2,6 +2,8 @@ #ifndef __ASM_VDSO_PROCESSOR_H #define __ASM_VDSO_PROCESSOR_H -#define cpu_relax() barrier() +#include + +#define cpu_relax() bcr_serialize() #endif /* __ASM_VDSO_PROCESSOR_H */