mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@transmeta.com>
Subject: [PATCH] fast reader/writer lock for gettimeofday 2.5.30 - ia64
Date: 13 Aug 2002 09:46:03 -0700	[thread overview]
Message-ID: <1029257163.6480.9.camel@dell_ss3.pdx.osdl.net> (raw)
In-Reply-To: <1029195577.1978.22.camel@dell_ss3.pdx.osdl.net>

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;
 


      parent reply	other threads:[~2002-08-13 16:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-12 23:39 [PATCH] fast reader/writer lock for gettimeofday 2.5.30 Stephen Hemminger
2002-08-13 16:43 ` [PATCH] fast reader/writer lock for gettimeofday 2.5.30 - addendum apm.c Stephen Hemminger
2002-08-13 16:46 ` Stephen Hemminger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1029257163.6480.9.camel@dell_ss3.pdx.osdl.net \
    --to=shemminger@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®