From d922f5eb1c375ab0445240110656c1d793eaad04 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Tue, 16 Nov 2010 11:13:10 -0500 Subject: Make TRACE() buffer size configurable Let the user choose an appropriate buffer size (instead of scaling with NR_CPUS). The kfifo api requires the buffer to be a power of two, so enforce this constraint in the configuration. This fixes a previously-existing compile-time error for values of NR_CPU that are not a power of two. Based on a patch by Mac Mollison . --- litmus/Kconfig | 20 ++++++++++++++++++++ litmus/sched_trace.c | 8 ++++---- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'litmus') diff --git a/litmus/Kconfig b/litmus/Kconfig index f1de6fabfc17..a3341021f05c 100644 --- a/litmus/Kconfig +++ b/litmus/Kconfig @@ -149,6 +149,26 @@ config SCHED_DEBUG_TRACE Say Yes for debugging. Say No for overhead tracing. +config SCHED_DEBUG_TRACE_SHIFT + int "Buffer size for TRACE() buffer" + depends on SCHED_DEBUG_TRACE + range 14 22 + default 18 + help + + Select the amount of memory needed per CPU for the TRACE() buffer, as a + power of two. The TRACE() buffer is global and statically allocated. If + the buffer is too small, there will be holes in the TRACE() log if the + buffer-flushing task is starved. + + The default should be sufficient for most systems. Increase the buffer + size if the log contains holes. Reduce the buffer size when running on + a memory-constrained system. + + Examples: 14 => 16KB + 18 => 256KB + 20 => 1MB + endmenu endmenu diff --git a/litmus/sched_trace.c b/litmus/sched_trace.c index 9b03e0cfe82b..f4171fddbbb1 100644 --- a/litmus/sched_trace.c +++ b/litmus/sched_trace.c @@ -18,14 +18,14 @@ #define SCHED_TRACE_NAME "litmus/log" -/* Allocate a buffer of about 32k per CPU */ -#define LITMUS_TRACE_BUF_PAGES 64 -#define LITMUS_TRACE_BUF_SIZE (PAGE_SIZE * LITMUS_TRACE_BUF_PAGES * NR_CPUS) +/* Compute size of TRACE() buffer */ +#define LITMUS_TRACE_BUF_SIZE (1 << CONFIG_SCHED_DEBUG_TRACE_SHIFT) /* Max length of one read from the buffer */ #define MAX_READ_LEN (64 * 1024) -/* Max length for one write --- from kernel --- to the buffer */ +/* Max length for one write --- by TRACE() --- to the buffer. This is used to + * allocate a per-cpu buffer for printf() formatting. */ #define MSG_SIZE 255 -- cgit v1.2.2