From b46ddf5d187d603f72389ac047a99e80edb6285d Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Thu, 30 May 2013 14:34:22 +0200 Subject: Use vmalloc() to allocate Feather-Trace buffers Allocating contiguous buffers with kmalloc() is subject to severe maximum size limits. For Feather-Trace to work, we don't actually need *physically* contiguous memory; virtually contiguous memory is sufficient. By switching to vmalloc(), the code gets simpler and we can support much larger buffers. For convenience, this patch also adds a configuration option for the desired Feather-Trace buffer size and increases the default size. --- litmus/Kconfig | 18 ++++++++++++++++++ litmus/ftdev.c | 19 +++++-------------- litmus/trace.c | 6 +----- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/litmus/Kconfig b/litmus/Kconfig index 795fbe1a769e..6a4e8c08e321 100644 --- a/litmus/Kconfig +++ b/litmus/Kconfig @@ -231,6 +231,24 @@ config SCHED_OVERHEAD_TRACE Export event stream for overhead tracing. Say Yes for overhead tracing. +config SCHED_OVERHEAD_TRACE_SHIFT + int "Buffer size for Feather-Trace overhead data" + depends on SCHED_OVERHEAD_TRACE + range 15 32 + default 22 + help + + Select the buffer size for the Feather-Trace overhead tracing + infrastructure (/dev/litmus/ft_trace0 & ftcat) as a power of two. The + larger the buffer, the less likely the chance of buffer overflows if + the ftcat process is starved by real-time activity. In machines with + large memories, large buffer sizes are recommended. + + Examples: 16 => 2 MB + 24 => 512 MB + 26 => 2G MB + + config SCHED_DEBUG_TRACE bool "TRACE() debugging" default y diff --git a/litmus/ftdev.c b/litmus/ftdev.c index 99bc39ffbcef..7126c61e8b4c 100644 --- a/litmus/ftdev.c +++ b/litmus/ftdev.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -21,13 +22,9 @@ struct ft_buffer* alloc_ft_buffer(unsigned int count, size_t size) if (!buf) return NULL; - total = (total / PAGE_SIZE) + (total % PAGE_SIZE != 0); - while (pages < total) { - order++; - pages *= 2; - } - mem = (char*) __get_free_pages(GFP_KERNEL, order); + mem = vmalloc(total); + if (!mem) { kfree(buf); return NULL; @@ -36,7 +33,7 @@ struct ft_buffer* alloc_ft_buffer(unsigned int count, size_t size) if (!init_ft_buffer(buf, count, size, mem + (count * size), /* markers at the end */ mem)) { /* buffer objects */ - free_pages((unsigned long) mem, order); + vfree(mem); kfree(buf); return NULL; } @@ -49,13 +46,7 @@ void free_ft_buffer(struct ft_buffer* buf) size_t total; if (buf) { - total = (buf->slot_size + 1) * buf->slot_count; - total = (total / PAGE_SIZE) + (total % PAGE_SIZE != 0); - while (pages < total) { - order++; - pages *= 2; - } - free_pages((unsigned long) buf->buffer_mem, order); + vfree(buf->buffer_mem); kfree(buf); } } diff --git a/litmus/trace.c b/litmus/trace.c index 7dbb98e4a3cd..9286569f2523 100644 --- a/litmus/trace.c +++ b/litmus/trace.c @@ -207,11 +207,7 @@ feather_callback void save_timestamp_hide_irq(unsigned long event) /* DEVICE FILE DRIVER */ /******************************************************************************/ -/* - * should be 8M; it is the max we can ask to buddy system allocator (MAX_ORDER) - * and we might not get as much - */ -#define NO_TIMESTAMPS (2 << 16) +#define NO_TIMESTAMPS (2 << CONFIG_SCHED_OVERHEAD_TRACE_SHIFT) static int alloc_timestamp_buffer(struct ftdev* ftdev, unsigned int idx) { -- cgit v1.2.2