Changeset d3605f8
- Timestamp:
- Nov 29, 2021, 4:58:54 PM (18 months ago)
- Branches:
- ADT, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 03cdad6
- Parents:
- 3bb4f85
- Location:
- libcfa/src/concurrency
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/io.cfa
r3bb4f85 rd3605f8 33 33 #include <sys/syscall.h> 34 34 #include <sys/eventfd.h> 35 #include <sys/uio.h> 35 36 36 37 #include <linux/io_uring.h> … … 502 503 } 503 504 504 #if defined( IO_URING_IDLE)505 bool __kernel_read(processor * proc, io_future_t & future, char buf[], int fd) {505 #if defined(CFA_WITH_IO_URING_IDLE) 506 bool __kernel_read(processor * proc, io_future_t & future, iovec & iov, int fd) { 506 507 $io_context * ctx = proc->io.ctx; 507 508 /* paranoid */ verify( ! __preemption_enabled() ); … … 518 519 __fill( &sqe, 1, &idx, ctx ); 519 520 520 sqe->opcode = IORING_OP_READ;521 521 sqe->user_data = (uintptr_t)&future; 522 522 sqe->flags = 0; 523 sqe->ioprio = 0;524 523 sqe->fd = fd; 525 524 sqe->off = 0; 525 sqe->ioprio = 0; 526 526 sqe->fsync_flags = 0; 527 527 sqe->__pad2[0] = 0; 528 528 sqe->__pad2[1] = 0; 529 529 sqe->__pad2[2] = 0; 530 sqe->addr = (uintptr_t)buf; 531 sqe->len = sizeof(uint64_t); 530 531 #if defined(CFA_HAVE_IORING_OP_READ) 532 sqe->opcode = IORING_OP_READ; 533 sqe->addr = (uint64_t)iov.iov_base; 534 sqe->len = iov.iov_len; 535 #elif defined(CFA_HAVE_READV) && defined(CFA_HAVE_IORING_OP_READV) 536 sqe->opcode = IORING_OP_READV; 537 sqe->addr = (uintptr_t)&iov; 538 sqe->len = 1; 539 #else 540 #error CFA_WITH_IO_URING_IDLE but none of CFA_HAVE_READV, CFA_HAVE_IORING_OP_READV or CFA_HAVE_IORING_OP_READ defined 541 #endif 532 542 533 543 asm volatile("": : :"memory"); -
libcfa/src/concurrency/io/setup.cfa
r3bb4f85 rd3605f8 220 220 cq.cqes = (struct io_uring_cqe *)(((intptr_t)cq.ring_ptr) + params.cq_off.cqes); 221 221 222 #if !defined( IO_URING_IDLE)222 #if !defined(CFA_WITH_IO_URING_IDLE) 223 223 // Step 4 : eventfd 224 224 // io_uring_register is so f*cking slow on some machine that it -
libcfa/src/concurrency/kernel.cfa
r3bb4f85 rd3605f8 27 27 extern "C" { 28 28 #include <sys/eventfd.h> 29 #include <sys/uio.h> 29 30 } 30 31 … … 125 126 static void __wake_one(cluster * cltr); 126 127 127 static void idle_sleep(processor * proc, io_future_t & future, eventfd_t & val);128 static void idle_sleep(processor * proc, io_future_t & future, iovec & iov); 128 129 static bool mark_idle (__cluster_proc_list & idles, processor & proc); 129 130 static void mark_awake(__cluster_proc_list & idles, processor & proc); … … 135 136 static inline bool __maybe_io_drain( processor * ); 136 137 137 #if defined( IO_URING_IDLE) && defined(CFA_HAVE_LINUX_IO_URING_H)138 extern bool __kernel_read(processor * proc, io_future_t & future, char buf[], int fd);138 #if defined(CFA_WITH_IO_URING_IDLE) 139 extern bool __kernel_read(processor * proc, io_future_t & future, iovec &, int fd); 139 140 #endif 140 141 … … 172 173 future.self.ptr = 1p; // mark it as already fulfilled so we know if there is a pending request or not 173 174 eventfd_t idle_val; 175 iovec idle_iovec = { &idle_val, sizeof(idle_val) }; 174 176 175 177 __cfa_io_start( this ); … … 237 239 } 238 240 239 idle_sleep( this, future, idle_ val);241 idle_sleep( this, future, idle_iovec ); 240 242 241 243 // We were woken up, remove self from idle … … 784 786 } 785 787 786 static void idle_sleep(processor * this, io_future_t & future, eventfd_t & val) {787 #if !defined( IO_URING_IDLE) || !defined(CFA_HAVE_LINUX_IO_URING_H)788 static void idle_sleep(processor * this, io_future_t & future, iovec & iov) { 789 #if !defined(CFA_WITH_IO_URING_IDLE) 788 790 #if !defined(__CFA_NO_STATISTICS__) 789 791 if(this->print_halts) { … … 818 820 #endif 819 821 #else 820 #if !defined(CFA_HAVE_IORING_OP_READ)821 #error this is only implemented if the read is present822 #endif823 822 // Do we already have a pending read 824 823 if(available(future)) { … … 826 825 reset(future); 827 826 828 __kernel_read(this, future, (char *)&val, this->idle_fd );827 __kernel_read(this, future, iov, this->idle_fd ); 829 828 } 830 829 -
libcfa/src/concurrency/kernel_private.hfa
r3bb4f85 rd3605f8 39 39 } 40 40 41 // #define IO_URING_IDLE 41 // Defines whether or not we *want* to use io_uring_enter as the idle_sleep blocking call 42 #define CFA_WANT_IO_URING_IDLE 43 44 // Defines whether or not we *can* use io_uring_enter as the idle_sleep blocking call 45 #if defined(CFA_WANT_IO_URING_IDLE) && defined(CFA_HAVE_LINUX_IO_URING_H) 46 #if defined(CFA_HAVE_IORING_OP_READ) || (defined(CFA_HAVE_READV) && defined(CFA_HAVE_IORING_OP_READV)) 47 #define CFA_WITH_IO_URING_IDLE 48 #endif 49 #endif 42 50 43 51 //-----------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.