- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/io/types.hfa
r26544f9 ra55472cc 37 37 //----------------------------------------------------------------------- 38 38 // Ring Data structure 39 // represent the io_uring submission ring which contains operations that will be sent to io_uring for processing 40 struct __sub_ring_t { 41 // lock needed because remote processors might need to flush the instance 42 __spinlock_t lock; 43 39 struct __sub_ring_t { 44 40 struct { 45 41 // Head and tail of the ring (associated with array) … … 62 58 63 59 // number of sqes to submit on next system call. 64 volatile__u32 to_submit;60 __u32 to_submit; 65 61 66 62 // number of entries and mask to go with it … … 81 77 void * ring_ptr; 82 78 size_t ring_sz; 83 84 // for debug purposes, whether or not the last flush was due to a arbiter flush85 bool last_external;86 79 }; 87 80 88 // represent the io_uring completion ring which contains operations that have completed89 81 struct __cmp_ring_t { 90 // needed because remote processors can help drain the buffer 91 volatile bool try_lock; 82 volatile bool lock; 92 83 93 // id of the ring, used for the helping/topology algorithms94 84 unsigned id; 95 85 96 // timestamp from last time it was drained97 86 unsigned long long ts; 98 87 … … 116 105 }; 117 106 118 // struct representing an io operation that still needs processing119 // actual operations are expected to inherit from this120 107 struct __outstanding_io { 121 // intrusive link fields122 108 inline Colable; 123 124 // primitive on which to block until the io is processed125 109 oneshot waitctx; 126 110 }; 127 111 static inline __outstanding_io *& Next( __outstanding_io * n ) { return (__outstanding_io *)Next( (Colable *)n ); } 128 112 129 // queue of operations that are outstanding130 113 struct __outstanding_io_queue { 131 // spinlock for protection132 // TODO: changing to a lock that blocks, I haven't examined whether it should be a kernel or user lock133 114 __spinlock_t lock; 134 135 // the actual queue136 115 Queue(__outstanding_io) queue; 137 138 // volatile used to avoid the need for taking the lock if it's empty139 116 volatile bool empty; 140 117 }; 141 118 142 // struct representing an operation that was submitted143 119 struct __external_io { 144 // inherits from outstanding io145 120 inline __outstanding_io; 146 147 // pointer and count to an array of ids to be submitted148 121 __u32 * idxs; 149 122 __u32 have; 150 151 // whether or not these can be accumulated before flushing the buffer152 123 bool lazy; 153 124 }; 154 125 155 // complete io_context, contains all the data for io submission and completion 126 156 127 struct __attribute__((aligned(64))) io_context$ { 157 // arbiter, used in cases where threads for migrated at unfortunate moments158 128 io_arbiter$ * arbiter; 159 160 // which prcessor the context is tied to161 129 struct processor * proc; 162 130 163 // queue of io submissions that haven't beeen processed.164 131 __outstanding_io_queue ext_sq; 165 132 166 // io_uring ring data structures167 133 struct __sub_ring_t sq; 168 134 struct __cmp_ring_t cq; 169 170 // flag the io_uring rings where created with171 135 __u32 ring_flags; 172 173 // file descriptor that identifies the io_uring instance174 136 int fd; 175 137 }; 176 138 177 // short hand to check when the io_context was last processed (io drained)178 139 static inline unsigned long long ts(io_context$ *& this) { 179 140 const __u32 head = *this->cq.head; 180 141 const __u32 tail = *this->cq.tail; 181 142 182 // if there is no pending completions, just pretend it's infinetely recent183 143 if(head == tail) return ULLONG_MAX; 184 144 … … 186 146 } 187 147 188 // structure represeting allocations that couldn't succeed locally189 148 struct __pending_alloc { 190 // inherit from outstanding io191 149 inline __outstanding_io; 192 193 // array and size of the desired allocation194 150 __u32 * idxs; 195 151 __u32 want; 196 197 // output param, the context the io was allocated from198 152 io_context$ * ctx; 199 153 }; 200 154 201 // arbiter that handles cases where the context tied to the local processor is unable to satisfy the io202 155 monitor __attribute__((aligned(64))) io_arbiter$ { 203 // contains a queue of io for pending allocations204 156 __outstanding_io_queue pending; 205 157 };
Note: See TracChangeset
for help on using the changeset viewer.