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>

(backport <rust-lang#3922>)
(cherry picked from commit fb58c01)

Signed-off-by: Trevor Gross <tmgross@umich.edu>
  • Loading branch information
tammela authored and tgross35 committed Nov 7, 2024
1 parent b0dd5ff commit bcae06e
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 @@ -3864,6 +3864,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 @@ -4306,6 +4309,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 @@ -550,6 +550,8 @@ ENOTSUP
ENOTUNIQ
EOF
EOWNERDEAD
EPIOCGPARAMS
EPIOCSPARAMS
EPOLLERR
EPOLLET
EPOLLEXCLUSIVE
Expand Down Expand Up @@ -3489,6 +3491,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 @@ -880,6 +880,15 @@ s! {
pub salt: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE],
pub rec_seq: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE],
}

// #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
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -4936,6 +4945,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 bcae06e

Please sign in to comment.