source: libcfa/src/concurrency/io/types.hfa@ 4ecc35a

ADT ast-experimental enum pthread-emulation qualifiedEnum stuck-waitfor-destruct
Last change on this file since 4ecc35a was 4ecc35a, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Added spin lock to io drain.
last step before completion fairness

  • Property mode set to 100644
File size: 4.0 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// io/types.hfa -- PRIVATE
8// Types used by the I/O subsystem
9//
10// Author : Thierry Delisle
11// Created On : Fri Jul 31 16:22:47 2020
12// Last Modified By :
13// Last Modified On :
14// Update Count :
15//
16
17#pragma once
18
19extern "C" {
20 #include <linux/types.h>
21}
22
23#include "bits/locks.hfa"
24#include "bits/queue.hfa"
25#include "iofwd.hfa"
26#include "kernel/fwd.hfa"
27
28#if defined(CFA_HAVE_LINUX_IO_URING_H)
29 #include "bits/sequence.hfa"
30 #include "monitor.hfa"
31
32 struct processor;
33 monitor $io_arbiter;
34
35 //-----------------------------------------------------------------------
36 // Ring Data structure
37 struct __sub_ring_t {
38 struct {
39 // Head and tail of the ring (associated with array)
40 volatile __u32 * head; // one passed last index consumed by the kernel
41 volatile __u32 * tail; // one passed last index visible to the kernel
42 volatile __u32 released; // one passed last index released back to the free list
43
44 // The actual kernel ring which uses head/tail
45 // indexes into the sqes arrays
46 __u32 * array;
47 } kring;
48
49 struct {
50 volatile __u32 head;
51 volatile __u32 tail;
52 // The ring which contains free allocations
53 // indexes into the sqes arrays
54 __u32 * array;
55 } free_ring;
56
57 // number of sqes to submit on next system call.
58 __u32 to_submit;
59
60 // number of entries and mask to go with it
61 const __u32 * num;
62 const __u32 * mask;
63
64 // Submission flags, currently only IORING_SETUP_SQPOLL
65 __u32 * flags;
66
67 // number of sqes not submitted
68 // From documentation : [dropped] is incremented for each invalid submission queue entry encountered in the ring buffer.
69 __u32 * dropped;
70
71 // A buffer of sqes (not the actual ring)
72 struct io_uring_sqe * sqes;
73
74 // The location and size of the mmaped area
75 void * ring_ptr;
76 size_t ring_sz;
77 };
78
79 struct __cmp_ring_t {
80 volatile bool lock;
81
82 // Head and tail of the ring
83 volatile __u32 * head;
84 volatile __u32 * tail;
85
86 // number of entries and mask to go with it
87 const __u32 * mask;
88 const __u32 * num;
89
90 // I don't know what this value is for
91 __u32 * overflow;
92
93 // the kernel ring
94 volatile struct io_uring_cqe * cqes;
95
96 // The location and size of the mmaped area
97 void * ring_ptr;
98 size_t ring_sz;
99 };
100
101 struct __outstanding_io {
102 inline Colable;
103 single_sem sem;
104 };
105 static inline __outstanding_io *& Next( __outstanding_io * n ) { return (__outstanding_io *)Next( (Colable *)n ); }
106
107 struct __outstanding_io_queue {
108 __spinlock_t lock;
109 Queue(__outstanding_io) queue;
110 volatile bool empty;
111 };
112
113 struct __external_io {
114 inline __outstanding_io;
115 __u32 * idxs;
116 __u32 have;
117 bool lazy;
118 };
119
120
121 struct __attribute__((aligned(128))) $io_context {
122 $io_arbiter * arbiter;
123 processor * proc;
124
125 __outstanding_io_queue ext_sq;
126
127 struct __sub_ring_t sq;
128 struct __cmp_ring_t cq;
129 __u32 ring_flags;
130 int fd;
131 };
132
133 struct __pending_alloc {
134 inline __outstanding_io;
135 __u32 * idxs;
136 __u32 want;
137 $io_context * ctx;
138 };
139
140 struct __attribute__((aligned(128))) $io_arbiter {
141 __outstanding_io_queue pending;
142 };
143
144 //-----------------------------------------------------------------------
145 // Misc
146 // Weirdly, some systems that do support io_uring don't actually define these
147 #ifdef __alpha__
148 /*
149 * alpha is the only exception, all other architectures
150 * have common numbers for new system calls.
151 */
152 #ifndef __NR_io_uring_setup
153 #define __NR_io_uring_setup 535
154 #endif
155 #ifndef __NR_io_uring_enter
156 #define __NR_io_uring_enter 536
157 #endif
158 #ifndef __NR_io_uring_register
159 #define __NR_io_uring_register 537
160 #endif
161 #else /* !__alpha__ */
162 #ifndef __NR_io_uring_setup
163 #define __NR_io_uring_setup 425
164 #endif
165 #ifndef __NR_io_uring_enter
166 #define __NR_io_uring_enter 426
167 #endif
168 #ifndef __NR_io_uring_register
169 #define __NR_io_uring_register 427
170 #endif
171 #endif
172
173 // void __ioctx_prepare_block($io_context & ctx);
174#endif
Note: See TracBrowser for help on using the repository browser.