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

[Xen-devel] [PATCH 1 of 4] Fix bug in logic for bytes_to_wrap in trace buffer



# HG changeset patch
# User Michael.Fetterman@xxxxxxxxxxxx
# Date 1202591468 0
# Node ID 91b4a9b2629c770bafca0d58bb106ce72a3a968f
# Parent  d05f5a5389afdbc57b35de94b26df49431369478
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>

diff -r d05f5a5389af -r 91b4a9b2629c xen/common/trace.c
--- a/xen/common/trace.c        Fri Feb 08 16:34:23 2008 +0000
+++ b/xen/common/trace.c        Sat Feb 09 21:11:08 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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