mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Linus Torvalds <torvalds@osdl.org>,
	Andrew Morton <akpm@digeo.com>, john stultz <johnstul@us.ibm.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] monotonic seqlock for cyclone timer
Date: Wed, 8 Oct 2003 11:58:19 -0700	[thread overview]
Message-ID: <20031008115819.2404cd2a.shemminger@osdl.org> (raw)

Replace read/write lock used for cyclone timer monotonic_lock with seqlock.
Similar to locking used on xtime and monotonic_lock in timers/timer_tsc.c

It builds and runs, but I don't have hardware with cyclone support to test.
Not a big deal (yet) since only hangcheck timer uses monotonic clock so far.

diff -urN -X dontdiff linux-2.5/arch/i386/kernel/timers/timer_cyclone.c linux-2.5-net/arch/i386/kernel/timers/timer_cyclone.c
--- linux-2.5/arch/i386/kernel/timers/timer_cyclone.c	2003-09-30 13:53:48.000000000 -0700
+++ linux-2.5-net/arch/i386/kernel/timers/timer_cyclone.c	2003-09-16 12:54:05.000000000 -0700
@@ -35,7 +35,7 @@
 static u32 last_cyclone_low;
 static u32 last_cyclone_high;
 static unsigned long long monotonic_base;
-static rwlock_t monotonic_lock = RW_LOCK_UNLOCKED;
+static seqlock_t monotonic_lock = SEQLOCK_UNLOCKED;
 
 /* helper macro to atomically read both cyclone counter registers */
 #define read_cyclone_counter(low,high) \
@@ -51,7 +51,7 @@
 	int count;
 	unsigned long long this_offset, last_offset;
 
-	write_lock(&monotonic_lock);
+	write_seqlock(&monotonic_lock);
 	last_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low;
 	
 	spin_lock(&i8253_lock);
@@ -76,7 +76,7 @@
 	/* update the monotonic base value */
 	this_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low;
 	monotonic_base += (this_offset - last_offset) & CYCLONE_TIMER_MASK;
-	write_unlock(&monotonic_lock);
+	write_sequnlock(&monotonic_lock);
 
 	/* calculate delay_at_last_interrupt */
 	count = ((LATCH-1) - count) * TICK_SIZE;
@@ -117,12 +117,15 @@
 	u32 now_low, now_high;
 	unsigned long long last_offset, this_offset, base;
 	unsigned long long ret;
+	unsigned seq;
 
 	/* atomically read monotonic base & last_offset */
-	read_lock_irq(&monotonic_lock);
-	last_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low;
-	base = monotonic_base;
-	read_unlock_irq(&monotonic_lock);
+	do {
+		seq = read_seqbegin(&monotonic_lock);
+		last_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low;
+		base = monotonic_base;
+	} while (read_seqretry(&monotonic_lock, seq));
+
 
 	/* Read the cyclone counter */
 	read_cyclone_counter(now_low,now_high);

             reply	other threads:[~2003-10-08 18:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-08 18:58 Stephen Hemminger [this message]
2003-10-08 20:20 ` john stultz

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=20031008115819.2404cd2a.shemminger@osdl.org \
    --to=shemminger@osdl.org \
    --cc=akpm@digeo.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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®