All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <srostedt@redhat.com>
To: xen-devel <xen-devel@lists.xensource.com>
Cc: rostedt@goodmis.org
Subject: [PATCH] binary or instead of logical in timer sync
Date: Wed, 02 Aug 2006 23:17:47 -0400	[thread overview]
Message-ID: <44D16ADB.90005@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1792 bytes --]

Hi, I found this little bug and here's a patch.

The reading of a timer is determined if 1. the hypervisor is not 
currently updating it (where it sets the LSB of the version) or 2. the 
kernel didn't finish reading it before the hypervisor updated it (the 
kernel version doesn't match the hypervisor version).

But the current code doesn't test the above case. Instead, by using a 
binary or instead of a logical one, it would only repeat if the 
hypervisor was updating  __and__ we read the version before it started 
updating (or we read it before we started updating, but the hypervisor 
finished updating between the first part of the or and the second check).


I'm not use to thunderbird so I'm sending both an attachment and an 
inline cut and paste.

-- Steve

Signed-off-by: Steven Rostedt <srostedt@redhat.com>

diff -r 9632ececc8f4 linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Wed Aug 02 10:13:30 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Wed Aug 02 22:54:09 2006 -0400
@@ -292,7 +292,7 @@ static void update_wallclock(void)
 		shadow_tv.tv_sec  = s->wc_sec;
 		shadow_tv.tv_nsec = s->wc_nsec;
 		rmb();
-	} while ((s->wc_version & 1) | (shadow_tv_version ^ s->wc_version));
+	} while ((s->wc_version & 1) || (shadow_tv_version ^ s->wc_version));
 
 	if (!independent_wallclock)
 		__update_wallclock(shadow_tv.tv_sec, shadow_tv.tv_nsec);
@@ -319,7 +319,7 @@ static void get_time_values_from_xen(voi
 		dst->tsc_to_nsec_mul   = src->tsc_to_system_mul;
 		dst->tsc_shift         = src->tsc_shift;
 		rmb();
-	} while ((src->version & 1) | (dst->version ^ src->version));
+	} while ((src->version & 1) || (dst->version ^ src->version));
 
 	dst->tsc_to_usec_mul = dst->tsc_to_nsec_mul / 1000;
 }



[-- Attachment #2: timer-bug.patch --]
[-- Type: text/x-patch, Size: 966 bytes --]

diff -r 9632ececc8f4 linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Wed Aug 02 10:13:30 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Wed Aug 02 22:54:09 2006 -0400
@@ -292,7 +292,7 @@ static void update_wallclock(void)
 		shadow_tv.tv_sec  = s->wc_sec;
 		shadow_tv.tv_nsec = s->wc_nsec;
 		rmb();
-	} while ((s->wc_version & 1) | (shadow_tv_version ^ s->wc_version));
+	} while ((s->wc_version & 1) || (shadow_tv_version ^ s->wc_version));
 
 	if (!independent_wallclock)
 		__update_wallclock(shadow_tv.tv_sec, shadow_tv.tv_nsec);
@@ -319,7 +319,7 @@ static void get_time_values_from_xen(voi
 		dst->tsc_to_nsec_mul   = src->tsc_to_system_mul;
 		dst->tsc_shift         = src->tsc_shift;
 		rmb();
-	} while ((src->version & 1) | (dst->version ^ src->version));
+	} while ((src->version & 1) || (dst->version ^ src->version));
 
 	dst->tsc_to_usec_mul = dst->tsc_to_nsec_mul / 1000;
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2006-08-03  3:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-03  3:17 Steven Rostedt [this message]
2006-08-03 12:15 ` [PATCH] binary or instead of logical in timer sync Keir Fraser
2006-08-03 13:09   ` Steven Rostedt
2006-08-04  4:27   ` Markus Armbruster

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=44D16ADB.90005@redhat.com \
    --to=srostedt@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.