Skip to contentSkip to conversation

Fix Trace Buffer Allocation Error

PATCH New Atsushi SAKAI 1 participant 1 message May 23, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix Trace Buffer Allocation Error

Hi, All.

This is a Patch for Trace Buffer allocation Error.
Currently, Trace Buffer Management uses two variables (opt_tbuf_size & tb_init_done)

Variable "opt_tbuf_size" is setting a tbuf_size and keeps the tbuf_size. Variable "tb_init_done" is a flag to do trace buffer process.
This flag is set by tb_control() DOM0_TBUF_ENABLE with the condition of opt_tbuf_size > 0.

The trace buffer(tbuf_size) is allocated by is alloc_trace_bufs().
This function used by two functions(tb_set_size() and init_trace_bufs())
In tb_set_size(), the alloc_trace_bufs() failure is cared collectly by setting opt_tbuf_size=0. But in init_trace_bufs(), the alloc_trace_bufs() failure is not cared collectry (KEEP opt_tbuf_size = n ).
(init_trace_bufs() calls at x86/setup.c & ia64/xensetup.c)

This problem occured in following steps.
1)tbuf_size = n in xen boot option
2)tbuf_size is too large and memory allocation fails.
3)tbctl 1(TraceBuffer Enable tb_init_done set to 1.)
(because opt_tbuf_size keeps n)
(tbctl calls tb_control DOM0_TBUF_ENABLE)
Current xen-unstable(CS10068), tbctl function is moved to get_tbuf(in xentrace & xenbaked) So 3) and 4) are occured at once.
But Current xen-ia64-unstable(CS10029) still remain tbctl.

4)tracebuffer collection process start working
(But trace buffer is not allocated)
5)tracebuffer collection process halted
because no trace buffers,

To avoid this problem I changed the location of error collection code opt_tbuf_size = 0;
from tb_set_size() to alloc_trace_bufs().
Because 1)allocation error is occured in alloc_trace_bufs()
and 2)init_trace_bufs() mis-allocation is also cared.

xen/common/trace.c +1 -1
diff -r 2e5d4e459c1c xen/common/trace.c
@@ -91,6 +91,7 @@ static int alloc_trace_bufs(void)
     if ( (rawbuf = alloc_xenheap_pages(order)) == NULL )
     {
         printk("Xen trace buffers: memory allocation failed\n");
+        opt_tbuf_size = 0;
         return -EINVAL;
     }
 
@@ -136,7 +137,6 @@ static int tb_set_size(int size)
     opt_tbuf_size = size;
     if ( alloc_trace_bufs() != 0 )
     {
-        opt_tbuf_size = 0;
         return -EINVAL;
     }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel