Skip to content

Commit

Permalink
locking: Introduce prepare_sync_core_cmd()
Browse files Browse the repository at this point in the history
mainline inclusion
from mainline-v6.9-rc1
link:#398

Introduce an architecture function that architectures can use to set
up ("prepare") SYNC_CORE commands.

The function will be used by RISC-V to update its "deferred icache-
flush" data structures (icache_stale_mask).

Architectures defining prepare_sync_core_cmd() static inline need to
select ARCH_HAS_PREPARE_SYNC_CORE_CMD.

Suggested-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/r/20240131144936.29190-4-parri.andrea@gmail.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
(cherry picked from commit 4ff4c74)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
  • Loading branch information
Andrea Parri authored and opsiff committed Sep 4, 2024
1 parent 51166f6 commit 3b0a39e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
16 changes: 15 additions & 1 deletion include/linux/sync_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,19 @@ static inline void sync_core_before_usermode(void)
}
#endif

#endif /* _LINUX_SYNC_CORE_H */
#ifdef CONFIG_ARCH_HAS_PREPARE_SYNC_CORE_CMD
#include <asm/sync_core.h>
#else
/*
* This is a dummy prepare_sync_core_cmd() implementation that can be used on
* all architectures which provide unconditional core serializing instructions
* in switch_mm().
* If your architecture doesn't provide such core serializing instructions in
* switch_mm(), you may need to write your own functions.
*/
static inline void prepare_sync_core_cmd(struct mm_struct *mm)
{
}
#endif

#endif /* _LINUX_SYNC_CORE_H */
3 changes: 3 additions & 0 deletions init/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,9 @@ source "kernel/Kconfig.locks"
config ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
bool

config ARCH_HAS_PREPARE_SYNC_CORE_CMD
bool

config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
bool

Expand Down
1 change: 1 addition & 0 deletions kernel/sched/membarrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ static int membarrier_private_expedited(int flags, int cpu_id)
MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE_READY))
return -EPERM;
ipi_func = ipi_sync_core;
prepare_sync_core_cmd(mm);
} else if (flags == MEMBARRIER_FLAG_RSEQ) {
if (!IS_ENABLED(CONFIG_RSEQ))
return -EINVAL;
Expand Down

0 comments on commit 3b0a39e

Please sign in to comment.