net: Use tsc_invariant when it is necessary; mainly in time measure
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 19 Jun 2013 08:54:41 +0000 (16:54 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 19 Jun 2013 08:56:02 +0000 (16:56 +0800)
sys/net/altq/altq_subr.c
sys/net/if_poll.c

index 9f58bd7..87558dd 100644 (file)
@@ -809,9 +809,10 @@ init_machclk(void)
 #endif
 
 #if defined(__i386__) || defined(__x86_64__)
-       /* check if TSC is available */
-       if ((cpu_feature & CPUID_TSC) == 0)
+       if (!tsc_present) {
+               /* No TSC */
                machclk_usepcc = 0;
+       }
 
        if (ncpus > 1) {
                /*
@@ -821,6 +822,9 @@ init_machclk(void)
                 * across CPUs or not.
                 */
                machclk_usepcc = 0;
+       } else if (!tsc_invariant) {
+               /* Not invariant TSC */
+               machclk_usepcc = 0;
        }
 #else
        machclk_usepcc = 0;
@@ -842,7 +846,7 @@ init_machclk(void)
         * just use it.
         */
 #ifdef _RDTSC_SUPPORTED_
-       if (cpu_feature & CPUID_TSC)
+       if (tsc_present)
                machclk_freq = (uint64_t)tsc_frequency;
 #endif
 
index bfb1b0f..ffe84b5 100644 (file)
@@ -316,7 +316,7 @@ sched_iopollmore(struct iopoll_ctx *io_ctx)
 static __inline void
 ifpoll_time_get(union ifpoll_time *t)
 {
-       if (__predict_true(tsc_present))
+       if (tsc_invariant)
                t->tsc = rdtsc();
        else
                microuptime(&t->tv);