@@ -71,6 +71,14 @@ int threads_per_disk = 1;
7171int delete_disks = 0 ;
7272int max_size = 0 ;
7373int use_lseek = 0 ;
74+ int num_processors = 0 ;
75+ #if AIO_MODE == AIO_MODE_IO_URING
76+ int io_uring_queue_entries = 32 ;
77+ int io_uring_sq_poll_ms = 0 ;
78+ int io_uring_attach_wq = 0 ;
79+ int io_uring_wq_bounded = 0 ;
80+ int io_uring_wq_unbounded = 0 ;
81+ #endif
7482
7583int chains = 1 ;
7684double seq_read_percent = 0.0 ;
@@ -210,6 +218,14 @@ dump_summary()
210218 printf (" %0.2f total mbytes/sec\n " , sr + sw + rr);
211219 printf (" ----------------------------------------------------------\n " );
212220
221+ #if AIO_MODE == AIO_MODE_IO_URING
222+ printf (" -----------------\n " );
223+ printf (" IO_URING results\n " );
224+ printf (" -----------------\n " );
225+ printf (" submissions: %lu\n " , io_uring_submissions.load ());
226+ printf (" completions: %lu\n " , io_uring_completions.load ());
227+ #endif
228+
213229 if (delete_disks) {
214230 for (int i = 0 ; i < n_disk_path; i++) {
215231 unlink (disk_path[i]);
@@ -375,6 +391,14 @@ read_config(const char *config_filename)
375391 PARAM (chains)
376392 PARAM (threads_per_disk)
377393 PARAM (delete_disks)
394+ PARAM (num_processors)
395+ #if AIO_MODE == AIO_MODE_IO_URING
396+ PARAM (io_uring_queue_entries)
397+ PARAM (io_uring_sq_poll_ms)
398+ PARAM (io_uring_attach_wq)
399+ PARAM (io_uring_wq_bounded)
400+ PARAM (io_uring_wq_unbounded)
401+ #endif
378402 else if (strcmp (field_name, " disk_path" ) == 0 )
379403 {
380404 assert (n_disk_path < MAX_DISK_THREADS);
@@ -405,16 +429,64 @@ read_config(const char *config_filename)
405429 return (1 );
406430}
407431
432+ #if AIO_MODE == AIO_MODE_IO_URING
433+
434+ class IOUringLoopTailHandler : public EThread ::LoopTailHandler
435+ {
436+ public:
437+ int
438+ waitForActivity (ink_hrtime timeout) override
439+ {
440+ IOUringContext::local_context ()->submit_and_wait (timeout);
441+
442+ return 0 ;
443+ }
444+ /* * Unblock.
445+
446+ This is required to unblock (wake up) the block created by calling @a cb.
447+ */
448+ void
449+ signalActivity () override
450+ {
451+ }
452+
453+ ~IOUringLoopTailHandler () override {}
454+ } uring_handler;
455+
456+ #endif
457+
408458int
409459main (int /* argc ATS_UNUSED */ , char *argv[])
410460{
411461 int i;
462+ printf (" input file %s\n " , argv[1 ]);
463+ if (!read_config (argv[1 ])) {
464+ exit (1 );
465+ }
466+ if (num_processors == 0 ) {
467+ num_processors = ink_number_of_processors ();
468+ }
469+ printf (" Using %d processor threads\n " , num_processors);
470+
471+ #if AIO_MODE == AIO_MODE_IO_URING
472+ {
473+ IOUringConfig cfg;
474+
475+ cfg.queue_entries = io_uring_queue_entries;
476+ cfg.sq_poll_ms = io_uring_sq_poll_ms;
477+ cfg.attach_wq = io_uring_attach_wq;
478+ cfg.wq_bounded = io_uring_wq_bounded;
479+ cfg.wq_unbounded = io_uring_wq_unbounded;
480+
481+ IOUringContext::set_config (cfg);
482+ };
483+ #endif
412484
413485 Layout::create ();
414486 init_diags (" " , nullptr );
415487 RecProcessInit ();
416488 ink_event_system_init (EVENT_SYSTEM_MODULE_PUBLIC_VERSION);
417- eventProcessor.start (ink_number_of_processors () );
489+ eventProcessor.start (num_processors );
418490
419491 Thread *main_thread = new EThread;
420492 main_thread->set_specific ();
@@ -425,14 +497,15 @@ main(int /* argc ATS_UNUSED */, char *argv[])
425497 et->schedule_imm (et->diskHandler );
426498 }
427499#endif
500+ #if AIO_MODE == AIO_MODE_IO_URING
501+ for (EThread *et : eventProcessor.active_group_threads (ET_NET)) {
502+ et->set_tail_handler (&uring_handler);
503+ }
504+ #endif
428505
429506 RecProcessStart ();
430507 ink_aio_init (AIO_MODULE_PUBLIC_VERSION);
431508 ts::Random::seed (time (nullptr ));
432- printf (" input file %s\n " , argv[1 ]);
433- if (!read_config (argv[1 ])) {
434- exit (1 );
435- }
436509
437510 max_size = seq_read_size;
438511 if (seq_write_size > max_size) {
@@ -466,7 +539,12 @@ main(int /* argc ATS_UNUSED */, char *argv[])
466539 }
467540
468541 while (!TSSystemState::is_event_system_shut_down ()) {
542+ #if AIO_MODE == AIO_MODE_IO_URING
543+ IOUringContext::local_context ()->submit_and_wait (1 * HRTIME_SECOND);
544+ #else
469545 sleep (1 );
546+ #endif
470547 }
548+
471549 delete main_thread;
472550}
0 commit comments