Skip to content
Commit 77eae2d2 authored by Huacai Chen's avatar Huacai Chen Committed by Greg Kroah-Hartman
Browse files

LoongArch: Change __my_cpu_offset definition to avoid mis-optimization



[ Upstream commit c87e12e0 ]

From GCC commit 3f13154553f8546a ("df-scan: remove ad-hoc handling of
global regs in asms"), global registers will no longer be forced to add
to the def-use chain. Then current_thread_info(), current_stack_pointer
and __my_cpu_offset may be lifted out of the loop because they are no
longer treated as "volatile variables".

This optimization is still correct for the current_thread_info() and
current_stack_pointer usages because they are associated to a thread.
However it is wrong for __my_cpu_offset because it is associated to a
CPU rather than a thread: if the thread migrates to a different CPU in
the loop, __my_cpu_offset should be changed.

Change __my_cpu_offset definition to treat it as a "volatile variable",
in order to avoid such a mis-optimization.

Cc: stable@vger.kernel.org
Reported-by: default avatarXiaotian Wu <wuxiaotian@loongson.cn>
Reported-by: default avatarMiao Wang <shankerwangmiao@gmail.com>
Signed-off-by: default avatarXing Li <lixing@loongson.cn>
Signed-off-by: default avatarHongchen Zhang <zhanghongchen@loongson.cn>
Signed-off-by: default avatarRui Wang <wangrui@loongson.cn>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 0e21852b
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment