Skip to content

Commit 7bce1c7

Browse files
andrea-parriopsiff
authored andcommitted
locking: Introduce prepare_sync_core_cmd()
mainline inclusion from mainline-v6.9-rc1 link:deepin-community#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>
1 parent 1354e2f commit 7bce1c7

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

include/linux/sync_core.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,19 @@ static inline void sync_core_before_usermode(void)
1717
}
1818
#endif
1919

20-
#endif /* _LINUX_SYNC_CORE_H */
20+
#ifdef CONFIG_ARCH_HAS_PREPARE_SYNC_CORE_CMD
21+
#include <asm/sync_core.h>
22+
#else
23+
/*
24+
* This is a dummy prepare_sync_core_cmd() implementation that can be used on
25+
* all architectures which provide unconditional core serializing instructions
26+
* in switch_mm().
27+
* If your architecture doesn't provide such core serializing instructions in
28+
* switch_mm(), you may need to write your own functions.
29+
*/
30+
static inline void prepare_sync_core_cmd(struct mm_struct *mm)
31+
{
32+
}
33+
#endif
2134

35+
#endif /* _LINUX_SYNC_CORE_H */

init/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,9 @@ source "kernel/Kconfig.locks"
20012001
config ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
20022002
bool
20032003

2004+
config ARCH_HAS_PREPARE_SYNC_CORE_CMD
2005+
bool
2006+
20042007
config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
20052008
bool
20062009

kernel/sched/membarrier.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ static int membarrier_private_expedited(int flags, int cpu_id)
324324
MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE_READY))
325325
return -EPERM;
326326
ipi_func = ipi_sync_core;
327+
prepare_sync_core_cmd(mm);
327328
} else if (flags == MEMBARRIER_FLAG_RSEQ) {
328329
if (!IS_ENABLED(CONFIG_RSEQ))
329330
return -EINVAL;

0 commit comments

Comments
 (0)