Skip to content

Commit 4fd5750

Browse files
author
Peter Zijlstra
committed
sched,tracing: Convert to sched_set_fifo()
One module user of sched_setscheduler() was overlooked and is obviously causing build failures. Convert ring_buffer_benchmark to use sched_set_fifo_low() when fifo==1 and sched_set_fifo() when fifo==2. This is a bit of an abuse, but it makes the thing 'work' again. Specifically, it enables all combinations that were previously possible: producer higher than consumer consumer higher than producer Fixes: 616d91b ("sched: Remove sched_setscheduler*() EXPORTs") Reported-by: kernel test robot <[email protected]> Reported-by: Stephen Rothwell <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Steven Rostedt (VMware) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 8b70098 commit 4fd5750

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

kernel/trace/ring_buffer_benchmark.c

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings");
4545
static int producer_nice = MAX_NICE;
4646
static int consumer_nice = MAX_NICE;
4747

48-
static int producer_fifo = -1;
49-
static int consumer_fifo = -1;
48+
static int producer_fifo;
49+
static int consumer_fifo;
5050

5151
module_param(producer_nice, int, 0644);
5252
MODULE_PARM_DESC(producer_nice, "nice prio for producer");
@@ -55,10 +55,10 @@ module_param(consumer_nice, int, 0644);
5555
MODULE_PARM_DESC(consumer_nice, "nice prio for consumer");
5656

5757
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");
5959

6060
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");
6262

6363
static int read_events;
6464

@@ -303,22 +303,22 @@ static void ring_buffer_producer(void)
303303
trace_printk("ERROR!\n");
304304

305305
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
307310
trace_printk("Running Consumer at nice: %d\n",
308311
consumer_nice);
309-
else
310-
trace_printk("Running Consumer at SCHED_FIFO %d\n",
311-
consumer_fifo);
312312
}
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
314317
trace_printk("Running Producer at nice: %d\n",
315318
producer_nice);
316-
else
317-
trace_printk("Running Producer at SCHED_FIFO %d\n",
318-
producer_fifo);
319319

320320
/* 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 &&
322322
producer_nice == MAX_NICE && consumer_nice == MAX_NICE)
323323
trace_printk("WARNING!!! This test is running at lowest priority.\n");
324324

@@ -455,21 +455,19 @@ static int __init ring_buffer_benchmark_init(void)
455455
* Run them as low-prio background tasks by default:
456456
*/
457457
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, &param);
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
464463
set_user_nice(consumer, consumer_nice);
465464
}
466465

467-
if (producer_fifo >= 0) {
468-
struct sched_param param = {
469-
.sched_priority = producer_fifo
470-
};
471-
sched_setscheduler(producer, SCHED_FIFO, &param);
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
473471
set_user_nice(producer, producer_nice);
474472

475473
return 0;

0 commit comments

Comments
 (0)