| .. | .. |
|---|
| 29 | 29 | static DECLARE_COMPLETION(read_start); |
|---|
| 30 | 30 | static DECLARE_COMPLETION(read_done); |
|---|
| 31 | 31 | |
|---|
| 32 | | -static struct ring_buffer *buffer; |
|---|
| 32 | +static struct trace_buffer *buffer; |
|---|
| 33 | 33 | static struct task_struct *producer; |
|---|
| 34 | 34 | static struct task_struct *consumer; |
|---|
| 35 | 35 | static unsigned long read; |
|---|
| .. | .. |
|---|
| 45 | 45 | static int producer_nice = MAX_NICE; |
|---|
| 46 | 46 | static int consumer_nice = MAX_NICE; |
|---|
| 47 | 47 | |
|---|
| 48 | | -static int producer_fifo = -1; |
|---|
| 49 | | -static int consumer_fifo = -1; |
|---|
| 48 | +static int producer_fifo; |
|---|
| 49 | +static int consumer_fifo; |
|---|
| 50 | 50 | |
|---|
| 51 | 51 | module_param(producer_nice, int, 0644); |
|---|
| 52 | 52 | MODULE_PARM_DESC(producer_nice, "nice prio for producer"); |
|---|
| .. | .. |
|---|
| 55 | 55 | MODULE_PARM_DESC(consumer_nice, "nice prio for consumer"); |
|---|
| 56 | 56 | |
|---|
| 57 | 57 | module_param(producer_fifo, int, 0644); |
|---|
| 58 | | -MODULE_PARM_DESC(producer_fifo, "fifo prio for producer"); |
|---|
| 58 | +MODULE_PARM_DESC(producer_fifo, "use fifo for producer: 0 - disabled, 1 - low prio, 2 - fifo"); |
|---|
| 59 | 59 | |
|---|
| 60 | 60 | module_param(consumer_fifo, int, 0644); |
|---|
| 61 | | -MODULE_PARM_DESC(consumer_fifo, "fifo prio for consumer"); |
|---|
| 61 | +MODULE_PARM_DESC(consumer_fifo, "use fifo for consumer: 0 - disabled, 1 - low prio, 2 - fifo"); |
|---|
| 62 | 62 | |
|---|
| 63 | 63 | static int read_events; |
|---|
| 64 | 64 | |
|---|
| .. | .. |
|---|
| 267 | 267 | if (consumer && !(cnt % wakeup_interval)) |
|---|
| 268 | 268 | wake_up_process(consumer); |
|---|
| 269 | 269 | |
|---|
| 270 | | -#ifndef CONFIG_PREEMPT |
|---|
| 270 | +#ifndef CONFIG_PREEMPTION |
|---|
| 271 | 271 | /* |
|---|
| 272 | | - * If we are a non preempt kernel, the 10 second run will |
|---|
| 272 | + * If we are a non preempt kernel, the 10 seconds run will |
|---|
| 273 | 273 | * stop everything while it runs. Instead, we will call |
|---|
| 274 | 274 | * cond_resched and also add any time that was lost by a |
|---|
| 275 | | - * rescedule. |
|---|
| 275 | + * reschedule. |
|---|
| 276 | 276 | * |
|---|
| 277 | 277 | * Do a cond resched at the same frequency we would wake up |
|---|
| 278 | 278 | * the reader. |
|---|
| .. | .. |
|---|
| 303 | 303 | trace_printk("ERROR!\n"); |
|---|
| 304 | 304 | |
|---|
| 305 | 305 | if (!disable_reader) { |
|---|
| 306 | | - if (consumer_fifo < 0) |
|---|
| 306 | + if (consumer_fifo) |
|---|
| 307 | + trace_printk("Running Consumer at SCHED_FIFO %s\n", |
|---|
| 308 | + consumer_fifo == 1 ? "low" : "high"); |
|---|
| 309 | + else |
|---|
| 307 | 310 | trace_printk("Running Consumer at nice: %d\n", |
|---|
| 308 | 311 | consumer_nice); |
|---|
| 309 | | - else |
|---|
| 310 | | - trace_printk("Running Consumer at SCHED_FIFO %d\n", |
|---|
| 311 | | - consumer_fifo); |
|---|
| 312 | 312 | } |
|---|
| 313 | | - if (producer_fifo < 0) |
|---|
| 313 | + if (producer_fifo) |
|---|
| 314 | + trace_printk("Running Producer at SCHED_FIFO %s\n", |
|---|
| 315 | + producer_fifo == 1 ? "low" : "high"); |
|---|
| 316 | + else |
|---|
| 314 | 317 | trace_printk("Running Producer at nice: %d\n", |
|---|
| 315 | 318 | producer_nice); |
|---|
| 316 | | - else |
|---|
| 317 | | - trace_printk("Running Producer at SCHED_FIFO %d\n", |
|---|
| 318 | | - producer_fifo); |
|---|
| 319 | 319 | |
|---|
| 320 | 320 | /* Let the user know that the test is running at low priority */ |
|---|
| 321 | | - if (producer_fifo < 0 && consumer_fifo < 0 && |
|---|
| 321 | + if (!producer_fifo && !consumer_fifo && |
|---|
| 322 | 322 | producer_nice == MAX_NICE && consumer_nice == MAX_NICE) |
|---|
| 323 | 323 | trace_printk("WARNING!!! This test is running at lowest priority.\n"); |
|---|
| 324 | 324 | |
|---|
| .. | .. |
|---|
| 362 | 362 | hit--; /* make it non zero */ |
|---|
| 363 | 363 | } |
|---|
| 364 | 364 | |
|---|
| 365 | | - /* Caculate the average time in nanosecs */ |
|---|
| 365 | + /* Calculate the average time in nanosecs */ |
|---|
| 366 | 366 | avg = NSEC_PER_MSEC / (hit + missed); |
|---|
| 367 | 367 | trace_printk("%ld ns per entry\n", avg); |
|---|
| 368 | 368 | } |
|---|
| .. | .. |
|---|
| 455 | 455 | * Run them as low-prio background tasks by default: |
|---|
| 456 | 456 | */ |
|---|
| 457 | 457 | if (!disable_reader) { |
|---|
| 458 | | - if (consumer_fifo >= 0) { |
|---|
| 459 | | - struct sched_param param = { |
|---|
| 460 | | - .sched_priority = consumer_fifo |
|---|
| 461 | | - }; |
|---|
| 462 | | - sched_setscheduler(consumer, SCHED_FIFO, ¶m); |
|---|
| 463 | | - } else |
|---|
| 458 | + if (consumer_fifo >= 2) |
|---|
| 459 | + sched_set_fifo(consumer); |
|---|
| 460 | + else if (consumer_fifo == 1) |
|---|
| 461 | + sched_set_fifo_low(consumer); |
|---|
| 462 | + else |
|---|
| 464 | 463 | set_user_nice(consumer, consumer_nice); |
|---|
| 465 | 464 | } |
|---|
| 466 | 465 | |
|---|
| 467 | | - if (producer_fifo >= 0) { |
|---|
| 468 | | - struct sched_param param = { |
|---|
| 469 | | - .sched_priority = producer_fifo |
|---|
| 470 | | - }; |
|---|
| 471 | | - sched_setscheduler(producer, SCHED_FIFO, ¶m); |
|---|
| 472 | | - } else |
|---|
| 466 | + if (producer_fifo >= 2) |
|---|
| 467 | + sched_set_fifo(producer); |
|---|
| 468 | + else if (producer_fifo == 1) |
|---|
| 469 | + sched_set_fifo_low(producer); |
|---|
| 470 | + else |
|---|
| 473 | 471 | set_user_nice(producer, producer_nice); |
|---|
| 474 | 472 | |
|---|
| 475 | 473 | return 0; |
|---|