parlib/linux: cache the value of the TSC frequency

Instead of computing it every time.  Note: we probably should get this
from an MSR, if possible.  Computing takes about a second, and is
usually close enough.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/user/parlib/include/parlib/tsc-compat.h b/user/parlib/include/parlib/tsc-compat.h
index a124de9..66195c7 100644
--- a/user/parlib/include/parlib/tsc-compat.h
+++ b/user/parlib/include/parlib/tsc-compat.h
@@ -91,9 +91,16 @@
 
 static inline uint64_t get_tsc_freq(void)
 {
+	static uint64_t freq;
+
 	struct timeval prev;
 	struct timeval curr;
-	uint64_t beg = read_tsc_serialized();
+	uint64_t beg, end;
+
+	if (freq)
+		return freq;
+
+	beg = read_tsc_serialized();
 
 	gettimeofday(&prev, 0);
 	while (1) {
@@ -103,9 +110,10 @@
 			 prev.tv_usec))
 			break;
 	}
-	uint64_t end = read_tsc_serialized();
+	end = read_tsc_serialized();
 
-	return end - beg;
+	freq = end - beg;
+	return freq;
 }
 
 /* Don't have a good way to get the overhead on Linux in userspace. */