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. The ioctls constants are padded to
64 bits alignment even on 32 bits machines.

Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
  • Loading branch information
tammela committed Oct 10, 2024
1 parent 2c0250f commit 465a935
Show file tree
Hide file tree
Showing 3 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
13 changes: 13 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 Expand Up @@ -5143,6 +5152,10 @@ pub const SCHED_FLAG_ALL: ::c_int = SCHED_FLAG_RESET_ON_FORK
| SCHED_FLAG_KEEP_ALL
| SCHED_FLAG_UTIL_CLAMP;

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

f! {
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
Expand Down

0 comments on commit 465a935

Please sign in to comment.