[PATCH] fast reader/writer lock for gettimeofday 2.5.30 - ia64

From: Stephen Hemminger (shemminger@osdl.org)
Date: Tue Aug 13 2002 - 11:46:03 EST


The following is an example of how to use frlock with other
architectures. Don't have a ia64 machine handy to test it

diff -urN -X dontdiff linux-2.5/arch/ia64/kernel/time.c linux-2.5.exp/arch/ia64/kernel/time.c
--- linux-2.5/arch/ia64/kernel/time.c Mon Aug 12 10:18:00 2002
+++ linux-2.5.exp/arch/ia64/kernel/time.c Mon Aug 12 17:35:26 2002
@@ -23,7 +23,7 @@
 #include <asm/sal.h>
 #include <asm/system.h>
 
-extern rwlock_t xtime_lock;
+extern frlock_t xtime_lock;
 extern unsigned long wall_jiffies;
 extern unsigned long last_time_offset;
 
@@ -87,7 +87,7 @@
 void
 do_settimeofday (struct timeval *tv)
 {
- write_lock_irq(&xtime_lock);
+ fr_write_lock_irq(&xtime_lock);
         {
                 /*
                  * This is revolting. We need to set "xtime" correctly. However, the value
@@ -109,16 +109,16 @@
                 time_maxerror = NTP_PHASE_LIMIT;
                 time_esterror = NTP_PHASE_LIMIT;
         }
- write_unlock_irq(&xtime_lock);
+ fr_write_unlock_irq(&xtime_lock);
 }
 
 void
 do_gettimeofday (struct timeval *tv)
 {
- unsigned long flags, usec, sec, old;
+ unsigned long seq, usec, sec, old;
 
- read_lock_irqsave(&xtime_lock, flags);
- {
+ do {
+ seq = fr_read_begin(&xtime_lock);
                 usec = gettimeoffset();
 
                 /*
@@ -135,8 +135,7 @@
 
                 sec = xtime.tv_sec;
                 usec += xtime.tv_usec;
- }
- read_unlock_irqrestore(&xtime_lock, flags);
+ } while (seq != fr_read_end(&xtime_lock));
 
         while (usec >= 1000000) {
                 usec -= 1000000;
@@ -179,10 +178,10 @@
                          * another CPU. We need to avoid to SMP race by acquiring the
                          * xtime_lock.
                          */
- write_lock(&xtime_lock);
+ fr_write_lock(&xtime_lock);
                         do_timer(regs);
                         local_cpu_data->itm_next = new_itm;
- write_unlock(&xtime_lock);
+ fr_write_unlock(&xtime_lock);
                 } else
                         local_cpu_data->itm_next = new_itm;
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 15 2002 - 22:00:32 EST