Skip to content
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

Feat(Linux): Add new process flags #4174

Merged
merged 3 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2003,9 +2003,9 @@ fn test_android(target: &str) {
| "PF_IO_WORKER"
| "PF_WQ_WORKER"
| "PF_FORKNOEXEC"
| "PF_MCE_PROCESS"
| "PF_SUPERPRIV"
| "PF_DUMPCORE"
| "PF_MCE_PROCESS"
| "PF_SIGNALED"
| "PF_MEMALLOC"
| "PF_NPROC_EXCEEDED"
Expand All @@ -2021,6 +2021,7 @@ fn test_android(target: &str) {
| "PF_NO_SETAFFINITY"
| "PF_MCE_EARLY"
| "PF_MEMALLOC_PIN"
| "PF_BLOCK_TS"
| "PF_SUSPEND_TASK" => true,

_ => false,
Expand Down Expand Up @@ -4240,7 +4241,9 @@ fn test_linux(target: &str) {
| "PF_RANDOMIZE"
| "PF_NO_SETAFFINITY"
| "PF_MCE_EARLY"
| "PF_MEMALLOC_PIN" => true,
| "PF_MEMALLOC_PIN"
| "PF_BLOCK_TS"
| "PF_SUSPEND_TASK" => true,

// FIXME: Requires >= 6.9 kernel headers.
"EPIOCSPARAMS"
Expand Down
27 changes: 27 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2085,40 +2085,67 @@ PF_ASH
PF_ATMPVC
PF_ATMSVC
PF_AX25
PF_BLOCK_TS
PF_BLUETOOTH
PF_BRIDGE
PF_CAIF
PF_CAN
PF_DECnet
PF_DUMPCORE
PF_ECONET
PF_EXITING
PF_FORKNOEXEC
PF_IDLE
PF_IEEE802154
PF_IO_WORKER
PF_IPX
PF_IRDA
PF_ISDN
PF_IUCV
PF_KEY
PF_KSWAPD
PF_KTHREAD
PF_LLC
PF_LOCAL
PF_LOCAL_THROTTLE
PF_MASKOS
PF_MASKPROC
PF_MCE_EARLY
PF_MCE_PROCESS
PF_MEMALLOC
PF_MEMALLOC_NOFS
PF_MEMALLOC_NOIO
PF_MEMALLOC_PIN
PF_NETBEUI
PF_NETLINK
PF_NETROM
PF_NFC
PF_NOFREEZE
PF_NO_SETAFFINITY
PF_NPROC_EXCEEDED
PF_PACKET
PF_PHONET
PF_POSTCOREDUMP
PF_PPPOX
PF_R
PF_RANDOMIZE
PF_RDS
PF_ROSE
PF_ROUTE
PF_RXRPC
PF_SECURITY
PF_SIGNALED
PF_SNA
PF_SUPERPRIV
PF_SUSPEND_TASK
PF_TIPC
PF_USED_MATH
PF_USER_WORKER
PF_VCPU
PF_VSOCK
PF_W
PF_WANPIPE
PF_WQ_WORKER
PF_X
PF_X25
PIPE_BUF
Expand Down
44 changes: 44 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5668,31 +5668,75 @@ pub const NET_DCCP: c_int = 20;
pub const NET_IRDA: c_int = 412;

// include/linux/sched.h
/// I'm a virtual CPU.
pub const PF_VCPU: c_int = 0x00000001;
/// I am an IDLE thread.
pub const PF_IDLE: c_int = 0x00000002;
/// Getting shut down.
pub const PF_EXITING: c_int = 0x00000004;
/// Coredumps should ignore this task.
pub const PF_POSTCOREDUMP: c_int = 0x00000008;
/// Task is an IO worker.
pub const PF_IO_WORKER: c_int = 0x00000010;
/// I'm a workqueue worker.
pub const PF_WQ_WORKER: c_int = 0x00000020;
/// Forked but didn't exec.
pub const PF_FORKNOEXEC: c_int = 0x00000040;
/// Process policy on mce errors.
pub const PF_MCE_PROCESS: c_int = 0x00000080;
/// Used super-user privileges.
pub const PF_SUPERPRIV: c_int = 0x00000100;
/// Dumped core.
pub const PF_DUMPCORE: c_int = 0x00000200;
/// Killed by a signal.
pub const PF_SIGNALED: c_int = 0x00000400;
/// Allocating memory to free memory.
///
/// See `memalloc_noreclaim_save()`.
pub const PF_MEMALLOC: c_int = 0x00000800;
/// `set_user()` noticed that `RLIMIT_NPROC` was exceeded.
pub const PF_NPROC_EXCEEDED: c_int = 0x00001000;
/// If unset the fpu must be initialized before use.
pub const PF_USED_MATH: c_int = 0x00002000;
/// Kernel thread cloned from userspace thread.
pub const PF_USER_WORKER: c_int = 0x00004000;
/// This thread should not be frozen.
pub const PF_NOFREEZE: c_int = 0x00008000;
/// I am `kswapd`.
pub const PF_KSWAPD: c_int = 0x00020000;
/// All allocations inherit `GFP_NOFS`.
///
/// See `memalloc_nfs_save()`.
pub const PF_MEMALLOC_NOFS: c_int = 0x00040000;
/// All allocations inherit `GFP_NOIO`.
///
/// See `memalloc_noio_save()`.
pub const PF_MEMALLOC_NOIO: c_int = 0x00080000;
/// Throttle writes only against the bdi I write to, I am cleaning
/// dirty pages from some other bdi.
pub const PF_LOCAL_THROTTLE: c_int = 0x00100000;
/// I am a kernel thread.
pub const PF_KTHREAD: c_int = 0x00200000;
/// Randomize virtual address space.
pub const PF_RANDOMIZE: c_int = 0x00400000;
/// Userland is not allowed to meddle with `cpus_mask`.
pub const PF_NO_SETAFFINITY: c_int = 0x04000000;
/// Early kill for mce process policy.
pub const PF_MCE_EARLY: c_int = 0x08000000;
/// Allocations constrained to zones which allow long term pinning.
///
/// See `memalloc_pin_save()`.
pub const PF_MEMALLOC_PIN: c_int = 0x10000000;
/// Plug has ts that needs updating.
pub const PF_BLOCK_TS: c_int = 0x20000000;
/// This thread called `freeze_processes()` and should not be frozen.
pub const PF_SUSPEND_TASK: c_int = PF_SUSPEND_TASK_UINT as _;
// The used value is the highest possible bit fitting on 32 bits, so directly
// defining it as a signed integer causes the compiler to report an overflow.
// Use instead a private intermediary that assuringly has the correct type and
// cast it where necessary to the wanted final type, which preserves the
// desired information as-is in terms of integer representation.
const PF_SUSPEND_TASK_UINT: c_uint = 0x80000000;

pub const CSIGNAL: c_int = 0x000000ff;

Expand Down
Loading