mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] asm-generic: flush icache only when vma->vm_flags has VM_EXEC set
@ 2024-01-09 14:45 Yangyu Chen
  2024-01-09 16:43 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Yangyu Chen @ 2024-01-09 14:45 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Christoph Hellwig, Alexander Potapenko, Mike Frysinger,
	linux-arch, linux-kernel, Yangyu Chen

For some ISAs like RISC-V, which may not support bus broadcast-based
icache flushing instructions, it's necessary to send IPIs to all of the
CPUs in the system to flush the icache. This process can be expensive for
these ISAs and introduce disturbances during performance profiling.
Limiting the icache flush to occur only when the vma->vm_flags has VM_EXEC
can help minimize the frequency of these operations.

Signed-off-by: Yangyu Chen <cyy@cyyself.name>
---
 include/asm-generic/cacheflush.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/asm-generic/cacheflush.h b/include/asm-generic/cacheflush.h
index 84ec53ccc450..729d51536575 100644
--- a/include/asm-generic/cacheflush.h
+++ b/include/asm-generic/cacheflush.h
@@ -102,7 +102,8 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
 	do { \
 		instrument_copy_to_user((void __user *)dst, src, len); \
 		memcpy(dst, src, len); \
-		flush_icache_user_page(vma, page, vaddr, len); \
+		if (vma->vm_flags & VM_EXEC) \
+			flush_icache_user_page(vma, page, vaddr, len); \
 	} while (0)
 #endif
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-09 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09 14:45 [PATCH] asm-generic: flush icache only when vma->vm_flags has VM_EXEC set Yangyu Chen
2024-01-09 16:43 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®