Changeset 426f60c for libcfa/src/concurrency/io
- Timestamp:
- Jan 12, 2021, 12:34:08 PM (5 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
- Location:
- libcfa/src/concurrency/io
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/io/call.cfa.in
r77fde9d5 r426f60c 74 74 ; 75 75 76 extern [* struct io_uring_sqe, __u32] __submit_alloc( struct __io_data & ring, __u64 data );76 extern [* volatile struct io_uring_sqe, __u32] __submit_alloc( struct __io_data & ring, __u64 data ); 77 77 extern void __submit( struct io_context * ctx, __u32 idx ) __attribute__((nonnull (1))); 78 78 … … 221 221 222 222 __u32 idx; 223 struct io_uring_sqe * sqe;223 volatile struct io_uring_sqe * sqe; 224 224 [sqe, idx] = __submit_alloc( ring, (__u64)(uintptr_t)&future ); 225 225 … … 314 314 Call('ACCEPT', 'int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)', { 315 315 'fd': 'sockfd', 316 'ioprio': '0', 316 317 'addr': '(__u64)addr', 317 318 'addr2': '(__u64)addrlen', … … 373 374 Call('READ', 'ssize_t read(int fd, void * buf, size_t count)', { 374 375 'fd': 'fd', 376 'off': '0', 375 377 'addr': '(__u64)buf', 376 378 'len': 'count' … … 379 381 Call('WRITE', 'ssize_t write(int fd, void * buf, size_t count)', { 380 382 'fd': 'fd', 383 'off': '0', 381 384 'addr': '(__u64)buf', 382 385 'len': 'count' … … 477 480 478 481 __u32 idx; 479 struct io_uring_sqe * sqe;482 volatile struct io_uring_sqe * sqe; 480 483 [sqe, idx] = __submit_alloc( ring, (__u64)(uintptr_t)&future ); 481 484 -
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) ); -
libcfa/src/concurrency/io/types.hfa
r77fde9d5 r426f60c 65 65 66 66 // A buffer of sqes (not the actual ring) 67 struct io_uring_sqe * sqes;67 volatile struct io_uring_sqe * sqes; 68 68 69 69 // The location and size of the mmaped area … … 85 85 86 86 // the kernel ring 87 struct io_uring_cqe * cqes;87 volatile struct io_uring_cqe * cqes; 88 88 89 89 // The location and size of the mmaped area … … 97 97 __u32 ring_flags; 98 98 int fd; 99 int efd; 99 100 bool eager_submits:1; 100 101 bool poller_submits:1;
Note:
See TracChangeset
for help on using the changeset viewer.