Page MenuHomeFreeBSD

D17850.id50033.diff
No OneTemporary

D17850.id50033.diff

Index: sys/x86/x86/delay.c
===================================================================
--- sys/x86/x86/delay.c
+++ sys/x86/x86/delay.c
@@ -51,11 +51,19 @@
#include <machine/cpu.h>
#include <x86/init.h>
-static u_int
-get_tsc(__unused struct timecounter *tc)
+static void
+delay_tsc(int n)
{
+ uint64_t end, now;
- return (rdtsc32());
+ sched_pin();
+ now = rdtsc();
+ end = now + tsc_freq * n / 1000000;
+ do {
+ cpu_spinwait();
+ now = rdtsc();
+ } while (now < end);
+ sched_unpin();
}
static int
@@ -66,22 +74,18 @@
uint64_t end, freq, now;
u_int last, mask, u;
+ if (tsc_is_invariant && tsc_freq != 0) {
+ delay_tsc(n);
+ return (1);
+ }
tc = timecounter;
- freq = atomic_load_acq_64(&tsc_freq);
- if (tsc_is_invariant && freq != 0) {
- func = get_tsc;
- mask = ~0u;
- } else {
- if (tc->tc_quality <= 0)
- return (0);
- func = tc->tc_get_timecount;
- mask = tc->tc_counter_mask;
- freq = tc->tc_frequency;
- }
+ if (tc->tc_quality <= 0)
+ return (0);
+ func = tc->tc_get_timecount;
+ mask = tc->tc_counter_mask;
+ freq = tc->tc_frequency;
now = 0;
end = freq * n / 1000000;
- if (func == get_tsc)
- sched_pin();
last = func(tc) & mask;
do {
cpu_spinwait();
@@ -92,8 +96,6 @@
now += u - last;
last = u;
} while (now < end);
- if (func == get_tsc)
- sched_unpin();
return (1);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Oct 24, 5:30 AM (14 h, 46 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24122037
Default Alt Text
D17850.id50033.diff (1 KB)

Event Timeline