WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] x86, time: Fix scale_reciprocal().

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86, time: Fix scale_reciprocal().
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 06 Dec 2008 04:20:42 -0800
Delivery-date: Sat, 06 Dec 2008 04:24:30 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1228488398 0
# Node ID c520af4bde59d5756d6c58014d5ae0b9011840bc
# Parent  4ffd935c08a3e88fa67328efc4f7bbdbce4a162b
x86, time: Fix scale_reciprocal().
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/time.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff -r 4ffd935c08a3 -r c520af4bde59 xen/arch/x86/time.c
--- a/xen/arch/x86/time.c       Fri Dec 05 13:06:57 2008 +0000
+++ b/xen/arch/x86/time.c       Fri Dec 05 14:46:38 2008 +0000
@@ -152,14 +152,23 @@ static inline u64 scale_delta(u64 delta,
 /* Compute the reciprocal of the given time_scale. */
 static inline struct time_scale scale_reciprocal(struct time_scale scale)
 {
-    u32 q, r;
+    struct time_scale reciprocal;
+    u32 dividend;
+
+    dividend = 0x80000000u;
+    reciprocal.shift = 1 - scale.shift;
+    while ( unlikely(dividend >= scale.mul_frac) )
+    {
+        dividend >>= 1;
+        reciprocal.shift++;
+    }
 
     asm (
         "divl %4"
-        : "=a" (q), "=d" (r)
-        : "0" (1), "1" (0), "r" (scale.mul_frac) );
-
-    return (struct time_scale) { .shift = -scale.shift, .mul_frac = q };
+        : "=a" (reciprocal.mul_frac), "=d" (dividend)
+        : "0" (0), "1" (dividend), "r" (scale.mul_frac) );
+
+    return reciprocal;
 }
 
 /*

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86, time: Fix scale_reciprocal()., Xen patchbot-unstable <=