-
Notifications
You must be signed in to change notification settings - Fork 1
Custom syscalls and io_uring subsystem calls #52
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,13 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| use core_affinity::CoreId; | ||||||||||||||||||||||||||||||||||||||||||||||
| use serde::Deserialize; | ||||||||||||||||||||||||||||||||||||||||||||||
| use std::{fmt::Display, net::Ipv4Addr}; | ||||||||||||||||||||||||||||||||||||||||||||||
| use serde::{Deserialize, Deserializer}; | ||||||||||||||||||||||||||||||||||||||||||||||
| use std::{collections::HashMap, fmt::Display, net::Ipv4Addr}; | ||||||||||||||||||||||||||||||||||||||||||||||
| use syscalls::Sysno; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| pub mod worker; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// Main workload configuration, contains general bits for all types of | ||||||||||||||||||||||||||||||||||||||||||||||
| /// workloads plus workload specific data. | ||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Copy, Clone, Deserialize)] | ||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Clone, Deserialize)] | ||||||||||||||||||||||||||||||||||||||||||||||
| pub struct WorkloadConfig { | ||||||||||||||||||||||||||||||||||||||||||||||
| /// An amount of time for workload payload to run before restarting. | ||||||||||||||||||||||||||||||||||||||||||||||
| pub restart_interval: u64, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -55,9 +55,33 @@ fn default_syscalls_syscall_nr() -> u32 { | |||||||||||||||||||||||||||||||||||||||||||||
| Sysno::getpid as u32 | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fn default_iouring_iouring_nr() -> u8 { | ||||||||||||||||||||||||||||||||||||||||||||||
| io_uring::opcode::OpenAt::CODE | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fn deserialize_args<'de, D>( | ||||||||||||||||||||||||||||||||||||||||||||||
| deserializer: D, | ||||||||||||||||||||||||||||||||||||||||||||||
| ) -> Result<HashMap<String, String>, D::Error> | ||||||||||||||||||||||||||||||||||||||||||||||
| where | ||||||||||||||||||||||||||||||||||||||||||||||
| D: Deserializer<'de>, | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| let s = String::deserialize(deserializer)?; | ||||||||||||||||||||||||||||||||||||||||||||||
| let mut map = HashMap::new(); | ||||||||||||||||||||||||||||||||||||||||||||||
| for arg in s.split(',').filter(|x| !x.is_empty()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| let parts = arg.split_once('='); | ||||||||||||||||||||||||||||||||||||||||||||||
| let Some((key, value)) = parts else { | ||||||||||||||||||||||||||||||||||||||||||||||
| return Err(serde::de::Error::custom( | ||||||||||||||||||||||||||||||||||||||||||||||
| "invalid syscall arguments format", | ||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might want to consider adding the offending argument to this string to help debug the error. |
||||||||||||||||||||||||||||||||||||||||||||||
| )); | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
| map.insert(key.to_string(), value.to_string()); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| Ok(map) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+68
to
+79
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might make the code a bit too dense, but how about doing this all in a single functional operation?
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// Workload specific configuration, contains one enum value for each | ||||||||||||||||||||||||||||||||||||||||||||||
| /// workload type. | ||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Copy, Clone, Deserialize)] | ||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Clone, Deserialize)] | ||||||||||||||||||||||||||||||||||||||||||||||
| #[serde(rename_all = "lowercase", tag = "type")] | ||||||||||||||||||||||||||||||||||||||||||||||
| pub enum Workload { | ||||||||||||||||||||||||||||||||||||||||||||||
| /// How to listen on ports. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -92,6 +116,33 @@ pub enum Workload { | |||||||||||||||||||||||||||||||||||||||||||||
| /// Which syscall to trigger | ||||||||||||||||||||||||||||||||||||||||||||||
| #[serde(default = "default_syscalls_syscall_nr")] | ||||||||||||||||||||||||||||||||||||||||||||||
| syscall_nr: u32, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// Arguments for syscall in format "arg1=value1,arg2=value2" | ||||||||||||||||||||||||||||||||||||||||||||||
| #[serde( | ||||||||||||||||||||||||||||||||||||||||||||||
| deserialize_with = "deserialize_args", | ||||||||||||||||||||||||||||||||||||||||||||||
| default = "HashMap::new" | ||||||||||||||||||||||||||||||||||||||||||||||
| )] | ||||||||||||||||||||||||||||||||||||||||||||||
| syscall_args: HashMap<String, String>, | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// How to invoke syscalls | ||||||||||||||||||||||||||||||||||||||||||||||
| IOUring { | ||||||||||||||||||||||||||||||||||||||||||||||
| /// How often to invoke a io_uring events. | ||||||||||||||||||||||||||||||||||||||||||||||
| #[serde(default = "default_syscalls_arrival_rate")] | ||||||||||||||||||||||||||||||||||||||||||||||
| arrival_rate: f64, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// Number of io uring event to trigger | ||||||||||||||||||||||||||||||||||||||||||||||
| /// List of io_uring events can be found at https://github.com/tokio-rs/io-uring/blob/master/src/sys/sys_x86_64.rs | ||||||||||||||||||||||||||||||||||||||||||||||
| /// or at https://github.com/torvalds/linux/blob/b320789d6883cc00ac78ce83bccbfe7ed58afcf0/include/uapi/linux/io_uring.h | ||||||||||||||||||||||||||||||||||||||||||||||
| #[serde(default = "default_iouring_iouring_nr")] | ||||||||||||||||||||||||||||||||||||||||||||||
| iouring_nr: u8, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// Arguments for io_uring in format "arg1=value1,arg2=value2" | ||||||||||||||||||||||||||||||||||||||||||||||
| #[serde( | ||||||||||||||||||||||||||||||||||||||||||||||
| deserialize_with = "deserialize_args", | ||||||||||||||||||||||||||||||||||||||||||||||
| default = "HashMap::new" | ||||||||||||||||||||||||||||||||||||||||||||||
| )] | ||||||||||||||||||||||||||||||||||||||||||||||
| iouring_args: HashMap<String, String>, | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// How to open network connections | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -186,11 +237,17 @@ pub enum Distribution { | |||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug)] | ||||||||||||||||||||||||||||||||||||||||||||||
| pub enum WorkerError { | ||||||||||||||||||||||||||||||||||||||||||||||
| Internal, | ||||||||||||||||||||||||||||||||||||||||||||||
| InternalWithMessage(String), | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| impl Display for WorkerError { | ||||||||||||||||||||||||||||||||||||||||||||||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||||||||||||||||||||||||||||||||||||||||||||||
| write!(f, "worker error found") | ||||||||||||||||||||||||||||||||||||||||||||||
| match self { | ||||||||||||||||||||||||||||||||||||||||||||||
| WorkerError::Internal => write!(f, "worker error found"), | ||||||||||||||||||||||||||||||||||||||||||||||
| WorkerError::InternalWithMessage(msg) => { | ||||||||||||||||||||||||||||||||||||||||||||||
| write!(f, "worker error: {}", msg) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -356,12 +413,7 @@ mod tests { | |||||||||||||||||||||||||||||||||||||||||||||
| .. | ||||||||||||||||||||||||||||||||||||||||||||||
| } = config; | ||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(restart_interval, 10); | ||||||||||||||||||||||||||||||||||||||||||||||
| if let Workload::Syscalls { | ||||||||||||||||||||||||||||||||||||||||||||||
| arrival_rate, | ||||||||||||||||||||||||||||||||||||||||||||||
| tight_loop, | ||||||||||||||||||||||||||||||||||||||||||||||
| syscall_nr, | ||||||||||||||||||||||||||||||||||||||||||||||
| } = workload | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| if let Workload::Syscalls { arrival_rate, .. } = workload { | ||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(arrival_rate, 10.0); | ||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| panic!("wrong workload type found"); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
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.
Not a huge deal but do we need to update the edition? Is this a requirement from one of the new dependencies added?