diff options
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/prof_machdep.c | 26 | ||||
-rw-r--r-- | sys/amd64/include/profile.h | 4 |
2 files changed, 24 insertions, 6 deletions
diff --git a/sys/amd64/amd64/prof_machdep.c b/sys/amd64/amd64/prof_machdep.c index 895d1950b076..5b3e83977ead 100644 --- a/sys/amd64/amd64/prof_machdep.c +++ b/sys/amd64/amd64/prof_machdep.c @@ -56,6 +56,20 @@ static int cputime_prof_active; #endif /* GUPROF */ #ifdef __GNUCLIKE_ASM +#if defined(SMP) && defined(GUPROF) +#define MPLOCK " \n\ + movl $1,%edx \n\ +9: \n\ + xorl %eax,%eax \n\ + lock \n\ + cmpxchgl %edx,mcount_lock \n\ + jne 9b \n" +#define MPUNLOCK "movl $0,mcount_lock \n" +#else /* !(SMP && GUPROF) */ +#define MPLOCK +#define MPUNLOCK +#endif /* SMP && GUPROF */ + __asm(" \n\ GM_STATE = 0 \n\ GMON_PROF_OFF = 3 \n\ @@ -111,8 +125,10 @@ __mcount: \n\ movq 7*8(%rsp),%rsi \n\ \n\ pushfq \n\ - cli \n\ - call mcount \n\ + cli \n" + MPLOCK " \n\ + call mcount \n" + MPUNLOCK " \n\ popfq \n\ popq %r9 \n\ popq %r8 \n\ @@ -163,8 +179,10 @@ GMON_PROF_HIRES = 4 \n\ pushq %r9 \n\ movq 7*8(%rsp),%rdi \n\ pushfq \n\ - cli \n\ - call mexitcount \n\ + cli \n" + MPLOCK " \n\ + call mexitcount \n" + MPUNLOCK " \n\ popfq \n\ popq %r9 \n\ popq %r8 \n\ diff --git a/sys/amd64/include/profile.h b/sys/amd64/include/profile.h index 97af17d5e662..2e19918cfb76 100644 --- a/sys/amd64/include/profile.h +++ b/sys/amd64/include/profile.h @@ -64,11 +64,11 @@ __asm __volatile("pushq %0; call __mcount; popq %%rcx" \ : \ : "i" (label) \ - : "ax", "dx", "cx", "di", "si", "r8", "r9", "memory") + : "cx", "r10", "r11", "memory") #define MEXITCOUNT_OVERHEAD() \ __asm __volatile("call .mexitcount; 1:" \ : : \ - : "ax", "dx", "cx", "di", "si", "r8", "r9", "memory") + : "r10", "r11", "memory") #define MEXITCOUNT_OVERHEAD_GETLABEL(labelp) \ __asm __volatile("movq $1b,%0" : "=rm" (labelp)) #else |