Changeset 426f60c for libcfa/src/concurrency/io/setup.cfa
- Timestamp:
- Jan 12, 2021, 12:34:08 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 58f99b3
- Parents:
- 77fde9d5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/io/setup.cfa
r77fde9d5 r426f60c 52 52 #include <pthread.h> 53 53 #include <sys/epoll.h> 54 #include <sys/eventfd.h> 54 55 #include <sys/mman.h> 55 56 #include <sys/syscall.h> … … 185 186 $io_ctx_thread * io_ctx = ($io_ctx_thread *)(uintptr_t)events[i].data.u64; 186 187 /* paranoid */ verify( io_ctx ); 187 __cfadbg_print_safe(io_core, "Kernel I/O - epoll : Unparking io poller % p\n", io_ctx);188 __cfadbg_print_safe(io_core, "Kernel I/O - epoll : Unparking io poller %d (%p)\n", io_ctx->ring->fd, io_ctx); 188 189 #if !defined( __CFA_NO_STATISTICS__ ) 189 190 __cfaabi_tls.this_stats = io_ctx->self.curr_cluster->stats; … … 309 310 } 310 311 312 extern void signal_unblock( int sig ); 313 extern void signal_block ( int sig ); 314 311 315 static void __io_create( __io_data & this, const io_context_params & params_in ) { 312 316 // Step 1 : call to setup … … 377 381 abort("KERNEL ERROR: IO_URING MMAP3 - %s\n", strerror(errno)); 378 382 } 379 383 memset(sq.sqes, 0xde, size); 384 385 verify( 0 != (params.features & IORING_FEAT_NODROP) ); 386 387 // Step 3 : Initialize the data structure 380 388 // Get the pointers from the kernel to fill the structure 381 389 // submit queue … … 392 400 const __u32 num = *sq.num; 393 401 for( i; num ) { 394 sq.sqes[i].user_data = 0ul64; 402 sq.sqes[i].opcode = IORING_OP_LAST; 403 sq.sqes[i].user_data = 3ul64; 395 404 } 396 405 } … … 422 431 cq.cqes = (struct io_uring_cqe *)(((intptr_t)cq.ring_ptr) + params.cq_off.cqes); 423 432 433 signal_block( SIGUSR1 ); 434 435 // Step 4 : eventfd 436 int efd = eventfd(0, 0); 437 if (efd < 0) { 438 abort("KERNEL ERROR: IO_URING EVENTFD - %s\n", strerror(errno)); 439 } 440 441 int ret = syscall( __NR_io_uring_register, fd, IORING_REGISTER_EVENTFD, &efd, 1); 442 if (ret < 0) { 443 abort("KERNEL ERROR: IO_URING EVENTFD REGISTER - %s\n", strerror(errno)); 444 } 445 446 signal_unblock( SIGUSR1 ); 447 424 448 // some paranoid checks 425 449 /* paranoid */ verifyf( (*cq.mask) == ((*cq.num) - 1ul32), "IO_URING Expected mask to be %u (%u entries), was %u", (*cq.num) - 1ul32, *cq.num, *cq.mask ); … … 436 460 this.ring_flags = params.flags; 437 461 this.fd = fd; 462 this.efd = efd; 438 463 this.eager_submits = params_in.eager_submits; 439 464 this.poller_submits = params_in.poller_submits; … … 458 483 // close the file descriptor 459 484 close(this.fd); 485 close(this.efd); 460 486 461 487 free( this.submit_q.ready ); // Maybe null, doesn't matter … … 467 493 468 494 void __ioctx_register($io_ctx_thread & ctx, struct epoll_event & ev) { 469 ev.events = EPOLLIN | EPOLL ONESHOT;495 ev.events = EPOLLIN | EPOLLET | EPOLLONESHOT; 470 496 ev.data.u64 = (__u64)&ctx; 471 int ret = epoll_ctl(iopoll.epollfd, EPOLL_CTL_ADD, ctx.ring-> fd, &ev);497 int ret = epoll_ctl(iopoll.epollfd, EPOLL_CTL_ADD, ctx.ring->efd, &ev); 472 498 if (ret < 0) { 473 499 abort( "KERNEL ERROR: EPOLL ADD - (%d) %s\n", (int)errno, strerror(errno) ); … … 476 502 477 503 void __ioctx_prepare_block($io_ctx_thread & ctx, struct epoll_event & ev) { 478 __cfadbg_print_safe(io_core, "Kernel I/O - epoll : Re-arming io poller % p\n", &ctx);479 int ret = epoll_ctl(iopoll.epollfd, EPOLL_CTL_MOD, ctx.ring-> fd, &ev);504 __cfadbg_print_safe(io_core, "Kernel I/O - epoll : Re-arming io poller %d (%p)\n", ctx.ring->fd, &ctx); 505 int ret = epoll_ctl(iopoll.epollfd, EPOLL_CTL_MOD, ctx.ring->efd, &ev); 480 506 if (ret < 0) { 481 507 abort( "KERNEL ERROR: EPOLL REARM - (%d) %s\n", (int)errno, strerror(errno) );
Note: See TracChangeset
for help on using the changeset viewer.