From a8497fb692ca9e9ac1717ebeb05f73508d9d6ca3 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Fri, 22 Mar 2019 12:34:37 +0800 Subject: [PATCH] Fix syscall clobber for x86_64, improve iperf performance --- rust/Cargo.lock | 36 +++++++++++++++++++++++++++++++++++- rust/src/bin/iperf.rs | 2 +- rust/src/syscall.rs | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 8bd2545..9812c0e 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -13,6 +13,11 @@ dependencies = [ "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "byteorder" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cfg-if" version = "0.1.7" @@ -21,7 +26,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "isomorphic_drivers" version = "0.1.0" -source = "git+https://github.com/rcore-os/isomorphic_drivers#6716a5df04455ff58d90e296ec4fcd7f40f878e9" +source = "git+https://github.com/rcore-os/isomorphic_drivers#a564ac855887a823dac80529ec4138194583905d" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -29,6 +34,14 @@ dependencies = [ "volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "log" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.4.6" @@ -37,12 +50,29 @@ dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "managed" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rcore-user" version = "0.1.0" dependencies = [ "buddy_system_allocator 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "isomorphic_drivers 0.1.0 (git+https://github.com/rcore-os/isomorphic_drivers)", + "smoltcp 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "smoltcp" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "managed 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -58,8 +88,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum buddy_system_allocator 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2ed828f1e227d6e32b998d6375b67fd63ac5389d50b23f258ce151d22b6cc595" +"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum isomorphic_drivers 0.1.0 (git+https://github.com/rcore-os/isomorphic_drivers)" = "" +"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum managed 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fdcec5e97041c7f0f1c5b7d93f12e57293c831c646f4cc7a5db59460c7ea8de6" +"checksum smoltcp 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fef582369edb298c6c41319a544ca9c4e83622f226055ccfcb35974fbb55ed34" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6af0edf5b4faacc31fc51159244d78d65ec580f021afcef7bd53c04aeabc7f29" diff --git a/rust/src/bin/iperf.rs b/rust/src/bin/iperf.rs index b66577a..f210885 100644 --- a/rust/src/bin/iperf.rs +++ b/rust/src/bin/iperf.rs @@ -189,7 +189,7 @@ pub fn main() { let data = [0u8; 204800]; loop { tick += 1; - iface.poll(&mut sockets, Instant::from_millis(tick / 1000)); + iface.poll(&mut sockets, Instant::from_millis(tick * 1000_000)); { let mut socket = sockets.get::(tcp_handle); if let State::BEGIN = state { diff --git a/rust/src/syscall.rs b/rust/src/syscall.rs index acb2973..2ad2ef1 100644 --- a/rust/src/syscall.rs +++ b/rust/src/syscall.rs @@ -20,7 +20,7 @@ fn sys_call(syscall_id: SyscallId, arg0: usize, arg1: usize, arg2: usize, arg3: asm!("syscall" : "={rax}" (ret) : "{rax}" (id), "{rdi}" (arg0), "{rsi}" (arg1), "{rdx}" (arg2), "{r10}" (arg3), "{r8}" (arg4), "{r9}" (arg5) - : "memory" + : "rcx" "r11" "memory" : "intel" "volatile"); #[cfg(target_arch = "aarch64")] asm!("svc 0"