aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/include/profile.h
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>2018-06-02 05:48:44 +0000
committerBruce Evans <bde@FreeBSD.org>2018-06-02 05:48:44 +0000
commit49c871278a2004345c7abbdc1ef0a560121b6c06 (patch)
treec53b45dc19dc1ed4929108ba644c12c44cfa8640 /sys/amd64/include/profile.h
parent66b3f031f02dcdca304d920930322c20659d30a5 (diff)
downloadsrc-49c871278a2004345c7abbdc1ef0a560121b6c06.tar.gz
src-49c871278a2004345c7abbdc1ef0a560121b6c06.zip
Fix high resolution kernel profiling just enough to not crash at boot
time, especially for SMP. If configured, it turns itself on at boot time for calibration, so is fragile even if never otherwise used. Both types of kernel profiling were supposed to use a global spinlock in the SMP case. If hi-res profiling is configured (but not necessarily used), this was supposed to be optimized by only using it when necessary, and slightly more efficiently, in asm. But it was not done at all for mcount entry where it is necessary. This caused crashes in the SMP case when either type of profiling was enabled. For mcount exit, it only caused wrong times. The times were wrongest with an i8254 timer since using that requires exclusive access to the hardware. The i8254 timer was too slow to use here 20 years ago and is much less usable now, but it is the default for the SMP case since TSCs weren't invariant when SMP was new. Do the locking in all hi-res SMP cases for simplicity. Calibration uses special asms, and the clobber lists in these were sort of inverted. They contained the arg and return registers which are not clobbered, but on amd64 they didn't contain the residue of the call-used registers which may be clobbered (%r10 and %r11). This usually caused hangs at boot time. This usually affected even the UP case.
Notes
Notes: svn path=/head/; revision=334522
Diffstat (limited to 'sys/amd64/include/profile.h')
-rw-r--r--sys/amd64/include/profile.h4
1 files changed, 2 insertions, 2 deletions
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