Page MenuHomeFreeBSD

D56056.id174321.diff
No OneTemporary

D56056.id174321.diff

diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c
--- a/sys/x86/x86/cpu_machdep.c
+++ b/sys/x86/x86/cpu_machdep.c
@@ -425,6 +425,7 @@
uint64_t tsc1, tsc2;
uint64_t acnt, mcnt, perf;
register_t reg;
+ int error = 0;
if (pcpu_find(cpu_id) == NULL || rate == NULL)
return (EINVAL);
@@ -460,6 +461,11 @@
acnt = rdmsr(MSR_APERF);
tsc2 = rdtsc();
intr_restore(reg);
+ if (mcnt == 0) {
+ tsc_perf_stat = 0;
+ error = EOPNOTSUPP;
+ goto err;
+ }
perf = 1000 * acnt / mcnt;
*rate = (tsc2 - tsc1) * perf;
} else {
@@ -470,6 +476,7 @@
*rate = (tsc2 - tsc1) * 1000;
}
+err:
#ifdef SMP
if (smp_cpus > 1) {
thread_lock(curthread);
@@ -478,7 +485,7 @@
}
#endif
- return (0);
+ return (error);
}
/*

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 1, 9:29 PM (10 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30429677
Default Alt Text
D56056.id174321.diff (761 B)

Event Timeline