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:
parent
d5d5600725
commit
6c7828a280
@ -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) +
|
||||
|
@ -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) +
|
||||
|
Loading…
x
Reference in New Issue
Block a user