hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/kernel/trace/ring_buffer_benchmark.c
....@@ -29,7 +29,7 @@
2929 static DECLARE_COMPLETION(read_start);
3030 static DECLARE_COMPLETION(read_done);
3131
32
-static struct ring_buffer *buffer;
32
+static struct trace_buffer *buffer;
3333 static struct task_struct *producer;
3434 static struct task_struct *consumer;
3535 static unsigned long read;
....@@ -45,8 +45,8 @@
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 @@
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
....@@ -267,12 +267,12 @@
267267 if (consumer && !(cnt % wakeup_interval))
268268 wake_up_process(consumer);
269269
270
-#ifndef CONFIG_PREEMPT
270
+#ifndef CONFIG_PREEMPTION
271271 /*
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
273273 * stop everything while it runs. Instead, we will call
274274 * cond_resched and also add any time that was lost by a
275
- * rescedule.
275
+ * reschedule.
276276 *
277277 * Do a cond resched at the same frequency we would wake up
278278 * the reader.
....@@ -303,22 +303,22 @@
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
....@@ -362,7 +362,7 @@
362362 hit--; /* make it non zero */
363363 }
364364
365
- /* Caculate the average time in nanosecs */
365
+ /* Calculate the average time in nanosecs */
366366 avg = NSEC_PER_MSEC / (hit + missed);
367367 trace_printk("%ld ns per entry\n", avg);
368368 }
....@@ -455,21 +455,19 @@
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;