]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sparc64: optimize functions that access tick
authorPavel Tatashin <pasha.tatashin@oracle.com>
Mon, 12 Jun 2017 20:41:48 +0000 (16:41 -0400)
committerAllen Pais <allen.pais@oracle.com>
Thu, 29 Jun 2017 08:09:43 +0000 (13:39 +0530)
Replace read tick function pointers with the new hot-patched get_tick().
This optimizes the performance of functions such as: sched_clock()

Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24401250
Orabug: 25637776

(cherry picked from commit eae3fc9871111e9bbc77dad5481a3e805e02ac46)
Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
arch/sparc/kernel/time_64.c

index 2484a4a1e62a8cdd808ecfba46838cea3375715d..afd66a60f0097298b2e533f617a7e9b89348e364 100644 (file)
@@ -765,12 +765,10 @@ static unsigned long tb_ticks_per_usec __read_mostly;
 
 void __delay(unsigned long loops)
 {
-       unsigned long bclock, now;
+       unsigned long bclock = get_tick();
 
-       bclock = tick_operations.get_tick();
-       do {
-               now = tick_operations.get_tick();
-       } while ((now-bclock) < loops);
+       while ((get_tick() - bclock) < loops)
+               ;
 }
 EXPORT_SYMBOL(__delay);
 
@@ -782,7 +780,7 @@ EXPORT_SYMBOL(udelay);
 
 static cycle_t clocksource_tick_read(struct clocksource *cs)
 {
-       return tick_operations.get_tick();
+       return get_tick();
 }
 
 static void __init get_tick_patch(void)
@@ -869,13 +867,19 @@ unsigned long long sched_clock(void)
 {
        unsigned long quotient = tick_operations.ticks_per_nsec_quotient;
        unsigned long offset = tick_operations.offset;
-       unsigned long ticks = tick_operations.get_tick();
 
-       return ((ticks * quotient) >> SPARC64_NSEC_PER_CYC_SHIFT) - offset;
+       /* Use barrier so the compiler emits the loads first and overlaps load
+        * latency with reading tick, because reading %tick/%stick is a
+        * post-sync instruction that will flush and restart subsequent
+        * instructions after it commits.
+        */
+       barrier();
+
+       return ((get_tick() * quotient) >> SPARC64_NSEC_PER_CYC_SHIFT) - offset;
 }
 
 int read_current_timer(unsigned long *timer_val)
 {
-       *timer_val = tick_operations.get_tick();
+       *timer_val = get_tick();
        return 0;
 }