Skip to content

Commit

Permalink
General cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
h33p committed Nov 4, 2023
1 parent 777a524 commit 8bf06bf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 34 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: true
DEFAULT_MIRI_FLAGS: -Zmiri-ignore-leaks -Zmiri-symbolic-alignment-check -Zmiri-retag-fields=all -Zmiri-symbolic-alignment-check -Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-tree-borrows -Zmiri-track-raw-pointers

jobs:
miri:
runs-on: ubuntu-latest
env:
RUSTFLAGS: ${{ matrix.rustflags }}
RUSTFLAGS: --cfg tokio_unstable
strategy:
matrix:
toolchain: ["nightly-2023-09-01"]
seed: [1, 2, 3, 4, 5, 6, 7, 8]
rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -25,4 +25,23 @@ jobs:
- run: rustup component add miri
- name: Run miri
run: |
MIRIFLAGS="-Zmiri-seed=${{ matrix.seed }} -Zmiri-ignore-leaks -Zmiri-symbolic-alignment-check -Zmiri-retag-fields=all -Zmiri-symbolic-alignment-check -Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-tree-borrows" cargo miri test
MIRIFLAGS="-Zmiri-seed=${{matrix.seed}} ${{env.DEFAULT_MIRI_FLAGS}}" cargo miri test
miri-linear-types:
runs-on: ubuntu-latest
env:
RUSTFLAGS: --cfg mfio_assume_linear_types --cfg tokio_unstable
strategy:
matrix:
toolchain: ["nightly-2023-09-01"]
seed: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
- run: rustup component add miri
- name: Run miri
run: |
MIRIFLAGS="-Zmiri-seed=${{matrix.seed}} ${{env.DEFAULT_MIRI_FLAGS}} -Zmiri-track-raw-pointers" cargo miri test
18 changes: 0 additions & 18 deletions mfio-rt/src/native/impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,3 @@ pub mod iocp;

#[cfg(all(not(miri), unix, feature = "mio"))]
pub mod mio;

cfg_if::cfg_if! {
if #[cfg(miri)] {
// Force use thread impl if on miri
pub use thread::*;
} else if #[cfg(all(target_os = "linux", feature = "io-uring"))] {
// io-uring provides true completion I/O, however, it's Linux-only.
pub use self::io_uring::*;
} else if #[cfg(all(unix, feature = "mio"))] {
// mio allows for true async io
// however, we are relying on file descriptors here, so we can't expose it on non-unix
// platforms.
pub use self::mio::*;
} else {
// Fallback to thread on any unmatched cases
pub use thread::*;
}
}
4 changes: 0 additions & 4 deletions mfio-rt/src/native/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,6 @@ impl NativeRt {
self.block_on(func(self))
}

fn register_file(&self, file: std::fs::File) -> NativeFile {
self.cwd.instance.register_file(file)
}

/// Registers a non-seekable I/O stream
pub fn register_stream(&self, stream: TcpStream) -> NativeTcpStream {
self.cwd.instance.register_stream(stream)
Expand Down
4 changes: 2 additions & 2 deletions mfio/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl<'a, T: PacketIo<Perms, Param>, Perms: PacketPerms, Param, Pkt: PacketStore<
type Output = Pkt::StackReq<'a>;

fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
let state: &Self = unsafe { core::mem::transmute(self) };
let state = self.into_ref().get_ref();

loop {
match unsafe { (*state.initial_state.get()).take() } {
Expand Down Expand Up @@ -244,7 +244,7 @@ impl<
> IoToFut<'a, T, Perms, Param, Pkt, Out>
{
pub fn submit(self: Pin<&mut Self>) -> &Out::StackReq<'a> {
let state: &Self = unsafe { core::mem::transmute(self) };
let state = unsafe { self.get_unchecked_mut() };

if let Some((io, param)) = unsafe { (*state.initial_state.get()).take() } {
// SAFETY: this packet's existence is tied to 'a lifetime, meaning it will be valid
Expand Down
7 changes: 0 additions & 7 deletions mfio/src/io/packet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ impl RcAndWaker {
}

pub fn wait_finalize(&self) {
// FIXME: in theory, wait_finalize should only wait for the FINALIZED_BIT, but not deal
// with the locking and the waker. However, something is making us have to take the waker,
// to make these atomic ops sound (however, even then I doubt this is fully sound, but is
// merely moving probability of desync lower).
// Either way, we should be able to have this waker mechanism be way more optimized,
// without atomic locks.
self.take();
while (self.rc_and_flags.load(Ordering::Acquire) & FINALIZED_BIT) == 0 {
core::hint::spin_loop();
}
Expand Down

0 comments on commit 8bf06bf

Please sign in to comment.