[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xentrace: Fix bug in logic for bytes_to_wrap in trace buffer.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1202723136 0
# Node ID 7d03c0b0750482ec96ec9fcf93c2b585f7740af5
# Parent  1b750b9cf4319c076bb831d26dcdcffbd5cfb913
xentrace: Fix bug in logic for bytes_to_wrap in trace buffer.
Admittedly, the bug could only be manifest with much larger trace
records than are currently allowed (or equivalently, much smaller
trace buffers), but the old code was harder to read, and thus hid the
logic bug well, too.

Signed-off-by: Michael A Fetterman <Michael.Fetterman@xxxxxxxxxxxx>
---
 xen/common/trace.c |   29 ++++++++++-------------------
 1 files changed, 10 insertions(+), 19 deletions(-)

diff -r 1b750b9cf431 -r 7d03c0b07504 xen/common/trace.c
--- a/xen/common/trace.c        Thu Feb 07 19:30:36 2008 +0000
+++ b/xen/common/trace.c        Mon Feb 11 09:45:36 2008 +0000
@@ -425,25 +425,18 @@ void __trace_var(u32 event, int cycles, 
             total_size += bytes_to_wrap;
             bytes_to_wrap = data_size;
         } 
-        else
-        {
-            bytes_to_wrap -= LOST_REC_SIZE;
-            if ( bytes_to_wrap == 0 )
-                bytes_to_wrap = data_size;
-        }
         total_size += LOST_REC_SIZE;
+        bytes_to_wrap -= LOST_REC_SIZE;
+
+        /* LOST_REC might line up perfectly with the buffer wrap */
+        if ( bytes_to_wrap == 0 )
+            bytes_to_wrap = data_size;
     }
 
     if ( rec_size > bytes_to_wrap )
     {
         total_size += bytes_to_wrap;
-        bytes_to_wrap = data_size;
     } 
-    else
-    {
-        bytes_to_wrap -= rec_size;
-    }
-
     total_size += rec_size;
 
     /* Do we have enough space for everything? */
@@ -466,14 +459,12 @@ void __trace_var(u32 event, int cycles, 
             insert_wrap_record(buf, LOST_REC_SIZE);
             bytes_to_wrap = data_size;
         } 
-        else
-        {
-            bytes_to_wrap -= LOST_REC_SIZE;
-            /* LOST_REC might line up perfectly with the buffer wrap */
-            if ( bytes_to_wrap == 0 )
-                bytes_to_wrap = data_size;
-        }
         insert_lost_records(buf);
+        bytes_to_wrap -= LOST_REC_SIZE;
+
+        /* LOST_REC might line up perfectly with the buffer wrap */
+        if ( bytes_to_wrap == 0 )
+            bytes_to_wrap = data_size;
     }
 
     if ( rec_size > bytes_to_wrap )

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.