Skip to content

Commit

Permalink
epoll: add busy polling parameters
Browse files Browse the repository at this point in the history
In Linux 6.9 a new ioctl for epoll was added:
https://man.archlinux.org/man/ioctl_eventpoll.2.en

Add support for it

Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
  • Loading branch information
tammela committed Oct 10, 2024
1 parent 2c0250f commit 810aa44
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3806,6 +3806,9 @@ fn test_linux(target: &str) {
// kernel so we can drop this and test the type once this new version is used in CI.
"sched_attr" => true,

// FIXME: Requires >= 6.9 kernel headers.
"epoll_params" => true,

_ => false,
}
});
Expand Down Expand Up @@ -4254,6 +4257,10 @@ fn test_linux(target: &str) {
| "SCHED_FLAG_UTIL_CLAMP"
| "SCHED_FLAG_ALL" if musl => true, // Needs more recent linux headers.

// FIXME: Requires >= 6.9 kernel headers.
"EPIOCSPARAMS"
| "EPIOCGPARAMS" => true,

_ => false,
}
});
Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ ENOTSUP
ENOTUNIQ
EOF
EOWNERDEAD
EPIOCGPARAMS
EPIOCSPARAMS
EPOLLERR
EPOLLET
EPOLLEXCLUSIVE
Expand Down Expand Up @@ -3532,6 +3534,7 @@ epoll_create
epoll_create1
epoll_ctl
epoll_event
epoll_params
epoll_pwait
epoll_wait
erand48
Expand Down
4 changes: 4 additions & 0 deletions src/unix/linux_like/linux/arch/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ cfg_if! {
}
}

// ioctl_eventpoll: added in Linux 6.9
pub const EPIOCSPARAMS: ::Ioctl = 0x40088a01;
pub const EPIOCGPARAMS: ::Ioctl = 0x80088a02;

cfg_if! {
if #[cfg(any(target_arch = "arm",
target_arch = "s390x"))] {
Expand Down
9 changes: 9 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,15 @@ s! {
pub get_args: __u16,
pub name: [c_char; ::IFNAMSIZ],
}

// #include <linux/eventpoll.h>

pub struct epoll_params {
pub busy_poll_usecs: u32,
pub busy_poll_budget: u16,
pub prefer_busy_poll: u8,
pub __pad: u8, // Must be zero
}
}

cfg_if! {
Expand Down

0 comments on commit 810aa44

Please sign in to comment.