ac6e56e6d7
23900-xzalloc.patch 24144-cpufreq-turbo-crash.patch 24148-shadow-pgt-dying-op-performance.patch 24155-x86-ioapic-EOI-after-migration.patch 24156-x86-ioapic-shared-vectors.patch 24157-x86-xstate-init.patch 24168-x86-vioapic-clear-remote_irr.patch - submit fixes for bnc#649209 and bnc#711892 xl-create-pv-with-qcow2-img.patch update suspend_evtchn_lock.patch - Update trace.c, merge patches from upstream 23050-xentrace_dynamic_tracebuffer_allocation.patch 23091-xentrace_fix_t_info_pages_calculation..patch 23092-xentrace_print_calculated_numbers_in_calculate_tbuf_size.patch 23093-xentrace_remove_gdprintk_usage_since_they_are_not_in_guest_context.patch 23094-xentrace_update_comments.patch 23095-xentrace_use_consistent_printk_prefix.patch 23128-xentrace_correct_formula_to_calculate_t_info_pages.patch 23129-xentrace_remove_unneeded_debug_printk.patch 23173-xentrace_Move_register_cpu_notifier_call_into_boot-time_init..patch 23239-xentrace_correct_overflow_check_for_number_of_per-cpu_trace_pages.patch 23308-xentrace_Move_the_global_variable_t_info_first_offset_into_calculate_tbuf_size.patch 23309-xentrace_Mark_data_size___read_mostly_because_its_only_written_once.patch 23310-xentrace_Remove_unneeded_cast_when_assigning_pointer_value_to_dst.patch 23404-xentrace_reduce_trace_buffer_size_to_something_mfn_offset_can_reach.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=160
156 lines
5.1 KiB
Diff
156 lines
5.1 KiB
Diff
changeset: 23407:b19898ac3e32
|
|
user: Olaf Hering <olaf@aepfle.de>
|
|
date: Thu May 26 12:36:27 2011 +0100
|
|
files: xen/common/trace.c
|
|
description:
|
|
xentrace: allocate non-contiguous per-cpu trace buffers
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
|
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
|
|
|
|
|
|
---
|
|
xen/common/trace.c | 92 ++++++++++++++++++++++++++++-------------------------
|
|
1 file changed, 50 insertions(+), 42 deletions(-)
|
|
|
|
Index: xen-4.1.2-testing/xen/common/trace.c
|
|
===================================================================
|
|
--- xen-4.1.2-testing.orig/xen/common/trace.c
|
|
+++ xen-4.1.2-testing/xen/common/trace.c
|
|
@@ -166,7 +166,7 @@ static int calculate_tbuf_size(unsigned
|
|
*/
|
|
static int alloc_trace_bufs(unsigned int pages)
|
|
{
|
|
- int i, cpu, order;
|
|
+ int i, cpu;
|
|
/* Start after a fixed-size array of NR_CPUS */
|
|
uint32_t *t_info_mfn_list;
|
|
uint16_t t_info_first_offset;
|
|
@@ -182,34 +182,11 @@ static int alloc_trace_bufs(unsigned int
|
|
t_info_first_offset = calc_tinfo_first_offset();
|
|
|
|
pages = calculate_tbuf_size(pages, t_info_first_offset);
|
|
- order = get_order_from_pages(pages);
|
|
|
|
t_info = alloc_xenheap_pages(get_order_from_pages(t_info_pages), 0);
|
|
if ( t_info == NULL )
|
|
- goto out_dealloc;
|
|
+ goto out_dealloc_t_info;
|
|
|
|
- /*
|
|
- * First, allocate buffers for all of the cpus. If any
|
|
- * fails, deallocate what you have so far and exit.
|
|
- */
|
|
- for_each_online_cpu(cpu)
|
|
- {
|
|
- void *rawbuf;
|
|
- struct t_buf *buf;
|
|
-
|
|
- if ( (rawbuf = alloc_xenheap_pages(
|
|
- order, MEMF_bits(32 + PAGE_SHIFT))) == NULL )
|
|
- {
|
|
- printk(XENLOG_INFO "xentrace: memory allocation failed "
|
|
- "on cpu %d\n", cpu);
|
|
- goto out_dealloc;
|
|
- }
|
|
-
|
|
- per_cpu(t_bufs, cpu) = buf = rawbuf;
|
|
- buf->cons = buf->prod = 0;
|
|
- }
|
|
-
|
|
- offset = t_info_first_offset;
|
|
t_info_mfn_list = (uint32_t *)t_info;
|
|
|
|
for(i = 0; i < t_info_pages; i++)
|
|
@@ -219,27 +196,53 @@ static int alloc_trace_bufs(unsigned int
|
|
t_info->tbuf_size = pages;
|
|
|
|
/*
|
|
- * Now share the pages so xentrace can map them, and write them in
|
|
- * the global t_info structure.
|
|
+ * Allocate buffers for all of the cpus.
|
|
+ * If any fails, deallocate what you have so far and exit.
|
|
*/
|
|
for_each_online_cpu(cpu)
|
|
{
|
|
- void *rawbuf = per_cpu(t_bufs, cpu);
|
|
- struct page_info *p = virt_to_page(rawbuf);
|
|
- uint32_t mfn = virt_to_mfn(rawbuf);
|
|
+ offset = t_info_first_offset + (cpu * pages);
|
|
+ t_info->mfn_offset[cpu] = offset;
|
|
|
|
for ( i = 0; i < pages; i++ )
|
|
{
|
|
- share_xen_page_with_privileged_guests(p + i, XENSHARE_writable);
|
|
-
|
|
- t_info_mfn_list[offset + i]=mfn + i;
|
|
+ void *p = alloc_xenheap_pages(0, MEMF_bits(32 + PAGE_SHIFT));
|
|
+ if ( !p )
|
|
+ {
|
|
+ printk(XENLOG_INFO "xentrace: memory allocation failed "
|
|
+ "on cpu %d after %d pages\n", cpu, i);
|
|
+ t_info_mfn_list[offset + i] = 0;
|
|
+ goto out_dealloc;
|
|
+ }
|
|
+ t_info_mfn_list[offset + i] = virt_to_mfn(p);
|
|
}
|
|
- t_info->mfn_offset[cpu]=offset;
|
|
- printk(XENLOG_INFO "xentrace: p%d mfn %"PRIx32" offset %d\n",
|
|
- cpu, mfn, offset);
|
|
- offset+=i;
|
|
+ }
|
|
+
|
|
+ /*
|
|
+ * Initialize buffers for all of the cpus.
|
|
+ */
|
|
+ for_each_online_cpu(cpu)
|
|
+ {
|
|
+ struct t_buf *buf;
|
|
+ struct page_info *pg;
|
|
|
|
spin_lock_init(&per_cpu(t_lock, cpu));
|
|
+
|
|
+ offset = t_info->mfn_offset[cpu];
|
|
+
|
|
+ /* Initialize the buffer metadata */
|
|
+ per_cpu(t_bufs, cpu) = buf = mfn_to_virt(t_info_mfn_list[offset]);
|
|
+ buf->cons = buf->prod = 0;
|
|
+
|
|
+ printk(XENLOG_INFO "xentrace: p%d mfn %x offset %u\n",
|
|
+ cpu, t_info_mfn_list[offset], offset);
|
|
+
|
|
+ /* Now share the trace pages */
|
|
+ for ( i = 0; i < pages; i++ )
|
|
+ {
|
|
+ pg = mfn_to_page(t_info_mfn_list[offset + i]);
|
|
+ share_xen_page_with_privileged_guests(pg, XENSHARE_writable);
|
|
+ }
|
|
}
|
|
|
|
data_size = (pages * PAGE_SIZE - sizeof(struct t_buf));
|
|
@@ -255,14 +258,19 @@ static int alloc_trace_bufs(unsigned int
|
|
out_dealloc:
|
|
for_each_online_cpu(cpu)
|
|
{
|
|
- void *rawbuf = per_cpu(t_bufs, cpu);
|
|
- per_cpu(t_bufs, cpu) = NULL;
|
|
- if ( rawbuf )
|
|
+ offset = t_info->mfn_offset[cpu];
|
|
+ if ( !offset )
|
|
+ continue;
|
|
+ for ( i = 0; i < pages; i++ )
|
|
{
|
|
- ASSERT(!(virt_to_page(rawbuf)->count_info & PGC_allocated));
|
|
- free_xenheap_pages(rawbuf, order);
|
|
+ uint32_t mfn = t_info_mfn_list[offset + i];
|
|
+ if ( !mfn )
|
|
+ break;
|
|
+ ASSERT(!(mfn_to_page(mfn)->count_info & PGC_allocated));
|
|
+ free_xenheap_pages(mfn_to_virt(mfn), 0);
|
|
}
|
|
}
|
|
+out_dealloc_t_info:
|
|
free_xenheap_pages(t_info, get_order_from_pages(t_info_pages));
|
|
t_info = NULL;
|
|
printk(XENLOG_WARNING "xentrace: allocation failed! Tracing disabled.\n");
|