Skip to content

Commit a37d56f

Browse files
atishp04palmer-dabbelt
authored andcommitted
RISC-V: Use WRITE_ONCE instead of direct access
The secondary harts spin on couple of per cpu variables until both of these are non-zero so it's not necessary to have any ordering here. However, WRITE_ONCE should be used to avoid tearing. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
1 parent 46373cb commit a37d56f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/riscv/kernel/smpboot.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
8181
* the spinning harts that they can continue the boot process.
8282
*/
8383
smp_mb();
84-
__cpu_up_stack_pointer[cpu] = task_stack_page(tidle) + THREAD_SIZE;
85-
__cpu_up_task_pointer[cpu] = tidle;
84+
WRITE_ONCE(__cpu_up_stack_pointer[cpu],
85+
task_stack_page(tidle) + THREAD_SIZE);
86+
WRITE_ONCE(__cpu_up_task_pointer[cpu], tidle);
8687

8788
while (!cpu_online(cpu))
8889
cpu_relax();

0 commit comments

Comments
 (0)