-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft changes to the io_uring prototype #208
Draft
Catfish-Man
wants to merge
50
commits into
main
Choose a base branch
from
david/ioring
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
15794f5
ioring pitch: first steps
oxy 6338029
stage 2: IORequest enum
oxy 996e940
initial AsyncFileDescriptor work
oxy 1f821a8
AsyncSequence draft implementation
oxy 0762f57
migrate CSystem to systemLibrary
oxy d099546
fix access control
oxy b584504
fix off-by-one in IORequest.openat
oxy b596783
implement closing
oxy 6b4084c
introduce IORing unit tests
oxy baab9b2
Starting to move to noncopyable structs, and away from swift-atomics
Catfish-Man 6029936
One more noncopyable struct
Catfish-Man 10c070a
WIP, more ~Copyable adoption
Catfish-Man 32966f9
It builds again! With some horrible hacks
Catfish-Man 822e481
Adopt isolation parameters
Catfish-Man fcb0b69
Merge branch 'main' into david/ioring
Catfish-Man 6f793cf
Merge branch 'main' into david/ioring
Catfish-Man a9f92a6
Delete stray Package.resolved changes
Catfish-Man 1a3e37d
Fix mismerge
Catfish-Man f369347
Fix mismerge
Catfish-Man ef94a37
Refactoring, and give up on resources being noncopyable structs
Catfish-Man 7ea32ae
More refactoring, and working timeout support on ManagedIORing
Catfish-Man 55fd6e7
Add support for timeout-on-wait to IORing, don't have tests yet
Catfish-Man e5fdf9e
Remove managed abstractions for now
Catfish-Man fdbceca
Eliminate internal locking and add multiple consume support
Catfish-Man 7107a57
Fix import visibility
Catfish-Man 02481e0
More import fixes
Catfish-Man bb03f0f
Redesign registered resources API
Catfish-Man a396967
More registration tweaks
Catfish-Man d4ca412
Some renaming, and implement linked requests
Catfish-Man 5bfed03
Switch to static methods for constructing requests
Catfish-Man 74366c3
Improve submit API
Catfish-Man 7f6e673
Adjust registered resources API
Catfish-Man 0c6ef16
Fix type
Catfish-Man a22e5f6
Add a version of registerBuffers that isn't varargs
Catfish-Man 6983196
Add unlinkAt support
Catfish-Man 5ba1377
Dubious approach to this, but I want to try it out a bit
Catfish-Man 0064649
Turn on single issuer as an experiment
Catfish-Man 901f4c8
Revert "Turn on single issuer as an experiment"
Catfish-Man 283e8d6
Reapply "Turn on single issuer as an experiment"
Catfish-Man d895f2a
Revert "Reapply "Turn on single issuer as an experiment""
Catfish-Man f3b8cc4
Actually consume events we waited for
Catfish-Man d338de1
Only get one completion if we asked for one completion
Catfish-Man 5e24673
Switch from unsafe pointers to FilePaths, using hacks
Catfish-Man 49dd797
Add a combined "submit and consume" operation
Catfish-Man 91155fd
Plumb error handling through completion consumers
Catfish-Man 9ad16c0
Plumb through userData
Catfish-Man 880ec90
Add a pointer convenience for getting the user data
Catfish-Man 48455a9
Fix plumbing
Catfish-Man 72c316b
Make completions noncopyable again
Catfish-Man 7fff872
Add the draft proposal so I can link to it
Catfish-Man File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,6 @@ | |
#include <pthread.h> | ||
#include <sched.h> | ||
#include <unistd.h> | ||
#include "io_uring.h" | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <unistd.h> | ||
#include <sys/syscall.h> | ||
#include <sys/uio.h> | ||
|
||
#include <signal.h> | ||
#include <linux/io_uring.h> | ||
|
||
#ifndef SWIFT_IORING_C_WRAPPER | ||
#define SWIFT_IORING_C_WRAPPER | ||
|
||
#ifdef __alpha__ | ||
/* | ||
* alpha is the only exception, all other architectures | ||
* have common numbers for new system calls. | ||
*/ | ||
# ifndef __NR_io_uring_setup | ||
# define __NR_io_uring_setup 535 | ||
# endif | ||
# ifndef __NR_io_uring_enter | ||
# define __NR_io_uring_enter 536 | ||
# endif | ||
# ifndef __NR_io_uring_register | ||
# define __NR_io_uring_register 537 | ||
# endif | ||
#else /* !__alpha__ */ | ||
# ifndef __NR_io_uring_setup | ||
# define __NR_io_uring_setup 425 | ||
# endif | ||
# ifndef __NR_io_uring_enter | ||
# define __NR_io_uring_enter 426 | ||
# endif | ||
# ifndef __NR_io_uring_register | ||
# define __NR_io_uring_register 427 | ||
# endif | ||
#endif | ||
|
||
int io_uring_register(int fd, unsigned int opcode, void *arg, | ||
unsigned int nr_args) | ||
{ | ||
return syscall(__NR_io_uring_register, fd, opcode, arg, nr_args); | ||
} | ||
|
||
int io_uring_setup(unsigned int entries, struct io_uring_params *p) | ||
{ | ||
return syscall(__NR_io_uring_setup, entries, p); | ||
} | ||
|
||
int io_uring_enter2(int fd, unsigned int to_submit, unsigned int min_complete, | ||
unsigned int flags, void *args, size_t sz) | ||
{ | ||
return syscall(__NR_io_uring_enter, fd, to_submit, min_complete, | ||
flags, args, _NSIG / 8); | ||
} | ||
|
||
int io_uring_enter(int fd, unsigned int to_submit, unsigned int min_complete, | ||
unsigned int flags, sigset_t *sig) | ||
{ | ||
return io_uring_enter2(fd, to_submit, min_complete, flags, sig, _NSIG / 8); | ||
} | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@_implementationOnly import CSystem | ||
|
||
public struct IOCompletion: ~Copyable { | ||
let rawValue: io_uring_cqe | ||
} | ||
|
||
extension IOCompletion { | ||
public struct Flags: OptionSet, Hashable, Codable { | ||
public let rawValue: UInt32 | ||
|
||
public init(rawValue: UInt32) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
public static let allocatedBuffer = Flags(rawValue: 1 << 0) | ||
public static let moreCompletions = Flags(rawValue: 1 << 1) | ||
public static let socketNotEmpty = Flags(rawValue: 1 << 2) | ||
public static let isNotificationEvent = Flags(rawValue: 1 << 3) | ||
} | ||
} | ||
|
||
extension IOCompletion { | ||
public var userData: UInt64 { //TODO: naming? | ||
get { | ||
rawValue.user_data | ||
} | ||
} | ||
|
||
public var userPointer: UnsafeRawPointer? { | ||
get { | ||
UnsafeRawPointer(bitPattern: UInt(rawValue.user_data)) | ||
} | ||
} | ||
|
||
public var result: Int32 { | ||
get { | ||
rawValue.res | ||
} | ||
} | ||
|
||
public var flags: IOCompletion.Flags { | ||
get { | ||
Flags(rawValue: rawValue.flags & 0x0000FFFF) | ||
} | ||
} | ||
|
||
public var bufferIndex: UInt16? { | ||
get { | ||
if self.flags.contains(.allocatedBuffer) { | ||
return UInt16(rawValue.flags >> 16) | ||
} else { | ||
return nil | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to have a link to e.g.
https://github.com/axboe/liburing/blob/92e858ad3f23ab2cdacbb5123ddce4c437452d9f/src/include/liburing/io_uring.h#L446
so one can see where these magic values comes from.