Changeset 18f7858 for libcfa/src/concurrency/kernel.cfa
- Timestamp:
- Mar 28, 2022, 4:00:32 PM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 37a3aa23
- Parents:
- 2377ca2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r2377ca2 r18f7858 132 132 static void __wake_one(cluster * cltr); 133 133 134 static void idle_sleep(processor * proc , io_future_t & future, iovec & iov);134 static void idle_sleep(processor * proc); 135 135 static bool mark_idle (__cluster_proc_list & idles, processor & proc); 136 136 static void mark_awake(__cluster_proc_list & idles, processor & proc); 137 137 138 138 extern bool __cfa_io_drain( processor * proc ) __attribute__((nonnull (1))); 139 extern bool __cfa_io_flush( processor * , int min_comp);140 static inline bool __maybe_io_drain( processor *);139 extern bool __cfa_io_flush( processor * ) __attribute__((nonnull (1))); 140 extern void __cfa_io_idle( processor * ) __attribute__((nonnull (1))); 141 141 142 142 #if defined(CFA_WITH_IO_URING_IDLE) … … 168 168 // mark it as already fulfilled so we know if there is a pending request or not 169 169 this->idle_wctx.ftr->self.ptr = 1p; 170 iovec idle_iovec = { this->idle_wctx.rdbuf, sizeof(eventfd_t) };171 170 172 171 __cfadbg_print_safe(runtime_core, "Kernel : core %p starting\n", this); … … 193 192 for() { 194 193 // Check if there is pending io 195 __ maybe_io_drain( this );194 __cfa_io_drain( this ); 196 195 197 196 // Try to get the next thread … … 199 198 200 199 if( !readyThread ) { 200 // there is no point in holding submissions if we are idle 201 201 __IO_STATS__(true, io.flush.idle++; ) 202 __cfa_io_flush( this, 0 ); 202 __cfa_io_flush( this ); 203 204 // drain again in case something showed up 205 __cfa_io_drain( this ); 203 206 204 207 readyThread = __next_thread( this->cltr ); … … 206 209 207 210 if( !readyThread ) for(5) { 211 readyThread = __next_thread_slow( this->cltr ); 212 213 if( readyThread ) break; 214 215 // It's unlikely we still I/O to submit, but the arbiter could 208 216 __IO_STATS__(true, io.flush.idle++; ) 209 210 readyThread = __next_thread_slow( this->cltr ); 211 212 if( readyThread ) break; 213 214 __cfa_io_flush( this, 0 ); 217 __cfa_io_flush( this ); 218 219 // drain again in case something showed up 220 __cfa_io_drain( this ); 215 221 } 216 222 … … 235 241 } 236 242 237 idle_sleep( this , *this->idle_wctx.ftr, idle_iovec);243 idle_sleep( this ); 238 244 239 245 // We were woken up, remove self from idle … … 257 263 if(__atomic_load_n(&this->io.pending, __ATOMIC_RELAXED) && !__atomic_load_n(&this->io.dirty, __ATOMIC_RELAXED)) { 258 264 __IO_STATS__(true, io.flush.dirty++; ) 259 __cfa_io_flush( this , 0);265 __cfa_io_flush( this ); 260 266 } 261 267 } … … 683 689 } 684 690 685 static void idle_sleep(processor * this , io_future_t & future, iovec & iov) {691 static void idle_sleep(processor * this) { 686 692 /* paranoid */ verify( this->idle_wctx.evfd != 1 ); 687 693 /* paranoid */ verify( this->idle_wctx.evfd != 2 ); … … 735 741 #endif 736 742 #else 737 // Do we already have a pending read 738 if(available(future)) { 739 // There is no pending read, we need to add one 740 reset(future); 741 742 __kernel_read(this, future, iov, this->idle_wctx.evfd ); 743 } 744 745 __cfa_io_flush( this, 1 ); 743 __cfa_io_idle( this ); 746 744 #endif 747 745 } … … 831 829 #endif 832 830 833 static inline bool __maybe_io_drain( processor * proc ) { 834 /* paranoid */ verify( proc ); 835 bool ret = false; 836 #if defined(CFA_HAVE_LINUX_IO_URING_H) 837 __cfadbg_print_safe(runtime_core, "Kernel : core %p checking io for ring %d\n", proc, proc->io.ctx->fd); 838 839 // Check if we should drain the queue 840 $io_context * ctx = proc->io.ctx; 841 unsigned head = *ctx->cq.head; 842 unsigned tail = *ctx->cq.tail; 843 if(head == tail) return false; 844 ready_schedule_lock(); 845 ret = __cfa_io_drain( proc ); 846 ready_schedule_unlock(); 847 #endif 848 return ret; 849 } 831 850 832 851 833 //-----------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.