Avoid CPU migration in dtrace_gethrtime() on x86.

dtrace_gethrtime() may be called outside of probe context, and in
particular, from the DTRACEIOC_BUFSNAP handler.

Disable interrupts rather than using sched_pin() to help ensure that
we don't call any external functions when in probe context.

PR:		218452
MFC after:	1 week
This commit is contained in:
Mark Johnston 2017-12-18 17:26:24 +00:00
parent d5d5600725
commit 6c7828a280
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326935
2 changed files with 12 additions and 6 deletions

View File

@ -353,11 +353,11 @@ SYSINIT(dtrace_gethrtime_init, SI_SUB_SMP, SI_ORDER_ANY, dtrace_gethrtime_init,
* Returns nanoseconds since boot.
*/
uint64_t
dtrace_gethrtime()
dtrace_gethrtime(void)
{
uint64_t tsc;
uint32_t lo;
uint32_t hi;
uint32_t lo, hi;
register_t rflags;
/*
* We split TSC value into lower and higher 32-bit halves and separately
@ -365,7 +365,10 @@ dtrace_gethrtime()
* (see nsec_scale calculations) taking into account 32-bit shift of
* the higher half and finally add.
*/
rflags = intr_disable();
tsc = rdtsc() - tsc_skew[curcpu];
intr_restore(rflags);
lo = tsc;
hi = tsc >> 32;
return (((lo * nsec_scale) >> SCALE_SHIFT) +

View File

@ -355,11 +355,11 @@ SYSINIT(dtrace_gethrtime_init, SI_SUB_SMP, SI_ORDER_ANY, dtrace_gethrtime_init,
* Returns nanoseconds since boot.
*/
uint64_t
dtrace_gethrtime()
dtrace_gethrtime(void)
{
uint64_t tsc;
uint32_t lo;
uint32_t hi;
uint32_t lo, hi;
register_t eflags;
/*
* We split TSC value into lower and higher 32-bit halves and separately
@ -367,7 +367,10 @@ dtrace_gethrtime()
* (see nsec_scale calculations) taking into account 32-bit shift of
* the higher half and finally add.
*/
eflags = intr_disable();
tsc = rdtsc() - tsc_skew[curcpu];
intr_restore(eflags);
lo = tsc;
hi = tsc >> 32;
return (((lo * nsec_scale) >> SCALE_SHIFT) +