diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-11-25 13:22:21 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-11-25 14:14:15 -0500 |
commit | 7ac074340480018681a0d72b324d4487543bdc0e (patch) | |
tree | c61f98cd477568d162d5fe408383f257f187508c /kernel | |
parent | 457dc928f586f3f4b930206965e6db270034e97e (diff) |
ring-buffer-benchmark: Add parameters to set produce/consumer priorities
Running the ring-buffer-benchmark's threads at the lowest priority may
work well for keeping it in the background, but it is not appropriate
for the benchmarks.
This patch adds 4 parameters to the module:
consumer_fifo
consumer_nice
producer_fifo
producer_nice
By default the consumer and producer still run at nice +19.
If the *_fifo options are set, they will override the *_nice values.
modprobe ring_buffer_benchmark consumer_nice=0 producer_fifo=10
The above will set the consumer thread to a nice value of 0, and
the producer thread to a RT SCHED_FIFO priority of 10.
Note, this patch also fixes a bug where calling set_user_nice on the
consumer thread would oops the kernel when the parameter "disable_reader"
is set.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/ring_buffer_benchmark.c | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c index 3875d49da990..b2477caf09c2 100644 --- a/kernel/trace/ring_buffer_benchmark.c +++ b/kernel/trace/ring_buffer_benchmark.c | |||
@@ -39,6 +39,24 @@ static int write_iteration = 50; | |||
39 | module_param(write_iteration, uint, 0644); | 39 | module_param(write_iteration, uint, 0644); |
40 | MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings"); | 40 | MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings"); |
41 | 41 | ||
42 | static int producer_nice = 19; | ||
43 | static int consumer_nice = 19; | ||
44 | |||
45 | static int producer_fifo = -1; | ||
46 | static int consumer_fifo = -1; | ||
47 | |||
48 | module_param(producer_nice, uint, 0644); | ||
49 | MODULE_PARM_DESC(producer_nice, "nice prio for producer"); | ||
50 | |||
51 | module_param(consumer_nice, uint, 0644); | ||
52 | MODULE_PARM_DESC(consumer_nice, "nice prio for consumer"); | ||
53 | |||
54 | module_param(producer_fifo, uint, 0644); | ||
55 | MODULE_PARM_DESC(producer_fifo, "fifo prio for producer"); | ||
56 | |||
57 | module_param(consumer_fifo, uint, 0644); | ||
58 | MODULE_PARM_DESC(consumer_fifo, "fifo prio for consumer"); | ||
59 | |||
42 | static int read_events; | 60 | static int read_events; |
43 | 61 | ||
44 | static int kill_test; | 62 | static int kill_test; |
@@ -270,6 +288,27 @@ static void ring_buffer_producer(void) | |||
270 | 288 | ||
271 | if (kill_test) | 289 | if (kill_test) |
272 | trace_printk("ERROR!\n"); | 290 | trace_printk("ERROR!\n"); |
291 | |||
292 | if (!disable_reader) { | ||
293 | if (consumer_fifo < 0) | ||
294 | trace_printk("Running Consumer at nice: %d\n", | ||
295 | consumer_nice); | ||
296 | else | ||
297 | trace_printk("Running Consumer at SCHED_FIFO %d\n", | ||
298 | consumer_fifo); | ||
299 | } | ||
300 | if (producer_fifo < 0) | ||
301 | trace_printk("Running Producer at nice: %d\n", | ||
302 | producer_nice); | ||
303 | else | ||
304 | trace_printk("Running Producer at SCHED_FIFO %d\n", | ||
305 | producer_fifo); | ||
306 | |||
307 | /* Let the user know that the test is running at low priority */ | ||
308 | if (producer_fifo < 0 && consumer_fifo < 0 && | ||
309 | producer_nice == 19 && consumer_nice == 19) | ||
310 | trace_printk("WARNING!!! This test is running at lowest priority.\n"); | ||
311 | |||
273 | trace_printk("Time: %lld (usecs)\n", time); | 312 | trace_printk("Time: %lld (usecs)\n", time); |
274 | trace_printk("Overruns: %lld\n", overruns); | 313 | trace_printk("Overruns: %lld\n", overruns); |
275 | if (disable_reader) | 314 | if (disable_reader) |
@@ -402,8 +441,23 @@ static int __init ring_buffer_benchmark_init(void) | |||
402 | /* | 441 | /* |
403 | * Run them as low-prio background tasks by default: | 442 | * Run them as low-prio background tasks by default: |
404 | */ | 443 | */ |
405 | set_user_nice(consumer, 19); | 444 | if (!disable_reader) { |
406 | set_user_nice(producer, 19); | 445 | if (consumer_fifo >= 0) { |
446 | struct sched_param param = { | ||
447 | .sched_priority = consumer_fifo | ||
448 | }; | ||
449 | sched_setscheduler(consumer, SCHED_FIFO, ¶m); | ||
450 | } else | ||
451 | set_user_nice(consumer, consumer_nice); | ||
452 | } | ||
453 | |||
454 | if (producer_fifo >= 0) { | ||
455 | struct sched_param param = { | ||
456 | .sched_priority = consumer_fifo | ||
457 | }; | ||
458 | sched_setscheduler(producer, SCHED_FIFO, ¶m); | ||
459 | } else | ||
460 | set_user_nice(producer, producer_nice); | ||
407 | 461 | ||
408 | return 0; | 462 | return 0; |
409 | 463 | ||