Now if don't set the option -S for buffer size, idlestat will init ftrace buffer with below formula:
percpu_buffer_size = ((2 * TRACE_IDLE_LENGTH * TRACE_IDLE_NRHITS_PER_SEC) + (TRACE_CPUFREQ_LENGTH * TRACE_CPUFREQ_NRHITS_PER_SEC)) * duration;
According to current macros' definition, if want to run the test case for 40s, then idlestat will need the trace buffer for one CPU is: (2*196*10000 + 196*100) Bytes/second x 40 seconds = 157584000 Bytes; So need allocate 150MB for one CPU, if system have 8 CPUs, then totally need allocate 150MB * 8 = 1.2GB; finally it reports the failure in kernel if the system cannot allocate so much buffer size:
[ 42.562531] idlestat: page allocation failure: order:0, mode:0x10d0 [ 42.568817] CPU: 2 PID: 819 Comm: idlestat Not tainted 4.2.0-rc4+ #106 [ 42.575372] Hardware name: HiKey Development Board (DT) [ 42.580610] Call trace: [ 42.583067] [<ffffffc00008a624>] dump_backtrace+0x0/0x164 [ 42.588465] [<ffffffc00008a7a4>] show_stack+0x1c/0x28 [ 42.593535] [<ffffffc0006d3b4c>] dump_stack+0x80/0xc4 [ 42.598589] [<ffffffc00018a064>] warn_alloc_failed+0xe4/0x13c [ 42.604355] [<ffffffc00018dac0>] __alloc_pages_nodemask+0x6a8/0x814 [ 42.610636] [<ffffffc000152774>] __rb_allocate_pages.isra.55+0x60/0x164 [ 42.617251] [<ffffffc000154718>] ring_buffer_resize+0x250/0x428 [ 42.623192] [<ffffffc000158808>] __tracing_resize_ring_buffer+0x54/0x17c [ 42.629905] [<ffffffc0001589d8>] tracing_entries_write+0xa8/0x158 [ 42.636000] [<ffffffc0001f2fec>] __vfs_write+0x44/0x130 [ 42.641240] [<ffffffc0001f3a50>] vfs_write+0x98/0x1a0 [ 42.646291] [<ffffffc0001f4630>] SyS_write+0x50/0xb0
After review the macro definition, TRACE_IDLE_NRHITS_PER_SEC is 10000; usually the CPU will enter/exit idle states much less than 1000 times per second, so reduce it to 1000 which will be enough for profiling.
Signed-off-by: Leo Yan leo.yan@linaro.org --- trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/trace.h b/trace.h index a2f5867..863c248 100644 --- a/trace.h +++ b/trace.h @@ -34,7 +34,7 @@ #define TRACE_FREE TRACE_PATH "/free_buffer" #define TRACE_FILE TRACE_PATH "/trace" #define TRACE_STAT_FILE TRACE_PATH "/per_cpu/cpu0/stats" -#define TRACE_IDLE_NRHITS_PER_SEC 10000 +#define TRACE_IDLE_NRHITS_PER_SEC 1000 #define TRACE_IDLE_LENGTH 196 #define TRACE_CPUFREQ_NRHITS_PER_SEC 100 #define TRACE_CPUFREQ_LENGTH 196