source: libcfa/src/concurrency/io/types.hfa @ 2fafe7e

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 2fafe7e was 2fafe7e, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Changed eager submit to use a leader-lock rather than a regular spinlock to avoid unnecessary spinnig

  • Property mode set to 100644
File size: 3.4 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 --
8//
9// Author           : Thierry Delisle
10// Created On       : Fri Jul 31 16:22:47 2020
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16#pragma once
17
18#if defined(CFA_HAVE_LINUX_IO_URING_H)
19        extern "C" {
20                #include <linux/types.h>
21        }
22
23      #include "bits/locks.hfa"
24
25        #define LEADER_LOCK
26        struct __leaderlock_t {
27                struct $thread * volatile value;        // ($thread) next_leader | (bool:1) is_locked
28        };
29
30        static inline void ?{}( __leaderlock_t & this ) { this.value = 0p; }
31
32        //-----------------------------------------------------------------------
33        // Ring Data structure
34      struct __submition_data {
35                // Head and tail of the ring (associated with array)
36                volatile __u32 * head;
37                volatile __u32 * tail;
38                volatile __u32 prev_head;
39
40                // The actual kernel ring which uses head/tail
41                // indexes into the sqes arrays
42                __u32 * array;
43
44                // number of entries and mask to go with it
45                const __u32 * num;
46                const __u32 * mask;
47
48                // Submission flags (Not sure what for)
49                __u32 * flags;
50
51                // number of sqes not submitted (whatever that means)
52                __u32 * dropped;
53
54                // Like head/tail but not seen by the kernel
55                volatile __u32 * ready;
56                __u32 ready_cnt;
57
58                #if defined(LEADER_LOCK)
59                        __leaderlock_t submit_lock;
60                #else
61                        __spinlock_t submit_lock;
62                #endif
63                __spinlock_t  release_lock;
64
65                // A buffer of sqes (not the actual ring)
66                struct io_uring_sqe * sqes;
67
68                // The location and size of the mmaped area
69                void * ring_ptr;
70                size_t ring_sz;
71        };
72
73        struct __completion_data {
74                // Head and tail of the ring
75                volatile __u32 * head;
76                volatile __u32 * tail;
77
78                // number of entries and mask to go with it
79                const __u32 * mask;
80                const __u32 * num;
81
82                // number of cqes not submitted (whatever that means)
83                __u32 * overflow;
84
85                // the kernel ring
86                struct io_uring_cqe * cqes;
87
88                // The location and size of the mmaped area
89                void * ring_ptr;
90                size_t ring_sz;
91        };
92
93        struct __io_data {
94                struct __submition_data submit_q;
95                struct __completion_data completion_q;
96                __u32 ring_flags;
97                int fd;
98                bool eager_submits:1;
99                bool poller_submits:1;
100        };
101
102
103        //-----------------------------------------------------------------------
104        // IO user data
105        struct __io_user_data_t {
106                __s32 result;
107                oneshot sem;
108        };
109
110        //-----------------------------------------------------------------------
111        // Misc
112        // Weirdly, some systems that do support io_uring don't actually define these
113        #ifdef __alpha__
114                /*
115                * alpha is the only exception, all other architectures
116                * have common numbers for new system calls.
117                */
118                #ifndef __NR_io_uring_setup
119                        #define __NR_io_uring_setup           535
120                #endif
121                #ifndef __NR_io_uring_enter
122                        #define __NR_io_uring_enter           536
123                #endif
124                #ifndef __NR_io_uring_register
125                        #define __NR_io_uring_register        537
126                #endif
127        #else /* !__alpha__ */
128                #ifndef __NR_io_uring_setup
129                        #define __NR_io_uring_setup           425
130                #endif
131                #ifndef __NR_io_uring_enter
132                        #define __NR_io_uring_enter           426
133                #endif
134                #ifndef __NR_io_uring_register
135                        #define __NR_io_uring_register        427
136                #endif
137        #endif
138
139        struct epoll_event;
140        struct $io_ctx_thread;
141        void __ioctx_register($io_ctx_thread & ctx, struct epoll_event & ev);
142        void __ioctx_prepare_block($io_ctx_thread & ctx, struct epoll_event & ev);
143#endif
Note: See TracBrowser for help on using the repository browser.