diff mbox

[v1,1/4] sparc64: interface to get random tick

Message ID 1500601861-203232-2-git-send-email-pasha.tatashin@oracle.com
State Changes Requested
Delegated to: David Miller
Headers show

Commit Message

Pavel Tatashin July 21, 2017, 1:50 a.m. UTC
Sometimes it is useful to use tick in hash calculations or backoff
randomization. get_rand_tick()  can be used for these purposes.

Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Signed-off-by: Bob Picco <bob.picco@oracle.com>
---
 arch/sparc/include/asm/timer_64.h |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/arch/sparc/include/asm/timer_64.h b/arch/sparc/include/asm/timer_64.h
index 51bc3bc..aa28bb4 100644
--- a/arch/sparc/include/asm/timer_64.h
+++ b/arch/sparc/include/asm/timer_64.h
@@ -94,4 +94,19 @@  static inline unsigned long get_tick(void)
 	return tick;
 }
 
+/* Quick way to get a tick value that can be used in hash calculations,
+ * random backoffs etc.
+ */
+static inline unsigned long get_rand_tick(void)
+{
+	unsigned long tick;
+
+	__asm__ __volatile__(
+	"	rd	%%tick, %0\n"
+	: "=r" (tick)
+	: /* No input */);
+
+	return tick;
+}
+
 #endif /* _SPARC64_TIMER_H */