Skip to content

Commit

Permalink
stress-cache: add write prefetchw option
Browse files Browse the repository at this point in the history
Add option to perform redundant write prefetch with x86 prefetchw
opcode.

Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Dec 18, 2024
1 parent d1566ac commit 1b76fcb
Show file tree
Hide file tree
Showing 7 changed files with 340 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,7 @@ cpufeatures: \
ASM_X86_PREFETCHT0 \
ASM_X86_PREFETCHT1 \
ASM_X86_PREFETCHT2 \
ASM_X86_PREFETCHW \
ASM_X86_RDMSR \
ASM_X86_RDPMC \
ASM_X86_RDRAND \
Expand Down Expand Up @@ -1503,6 +1504,9 @@ ASM_X86_PREFETCHT2:
ASM_X86_PREFETCHNTA:
$(call check,test-asm-x86-prefetchnta,HAVE_ASM_X86_PREFETCHNTA,x86 prefetchtnta instruction)

ASM_X86_PREFETCHW:
$(call check,test-asm-x86-prefetchw,HAVE_ASM_X86_PREFETCHW,x86 prefetchw instruction)

ASM_X86_RDMSR:
$(call check,test-asm-x86-rdmsr,HAVE_ASM_X86_RDMSR,x86 rdmsr instruction)

Expand Down
7 changes: 7 additions & 0 deletions core-asm-x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ static inline void ALWAYS_INLINE stress_asm_x86_prefetchnta(void *p)
}
#endif

#if defined(HAVE_ASM_X86_PREFETCHW)
static inline void ALWAYS_INLINE stress_asm_x86_prefetchw(void *p)
{
__asm__ __volatile__("prefetchw (%0)\n" : : "r"(p) : "memory");
}
#endif

#if !defined(HAVE_COMPILER_PCC) && \
defined(STRESS_ARCH_X86_64) && \
defined(STRESS_ARCH_X86_LP64)
Expand Down
1 change: 1 addition & 0 deletions core-opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const struct option stress_long_options[] = {
{ "cache-no-affinity", 0, 0, OPT_cache_no_affinity },
{ "cache-ops", 1, 0, OPT_cache_ops },
{ "cache-prefetch", 0, 0, OPT_cache_prefetch },
{ "cache-prefetchw", 0, 0, OPT_cache_prefetchw },
{ "cache-sfence", 0, 0, OPT_cache_sfence },
{ "cache-ways", 1, 0, OPT_cache_ways },
{ "cacheline", 1, 0, OPT_cacheline },
Expand Down
1 change: 1 addition & 0 deletions core-opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ typedef enum {
OPT_cache_sfence,
OPT_cache_no_affinity,
OPT_cache_prefetch,
OPT_cache_prefetchw,
OPT_cache_ways,

OPT_cacheline,
Expand Down
Loading

0 comments on commit 1b76fcb

Please sign in to comment.