Skip to content

Conversation

devnexen
Copy link
Contributor

cookie.

What does this PR do

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

@devnexen devnexen force-pushed the prctl_sched_core branch 3 times, most recently from dbc3859 to dc9add9 Compare April 11, 2025 20:31
@devnexen devnexen marked this pull request as ready for review April 11, 2025 20:47
Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These APIs do not seem right? From the kernel commit message, they should look like this:

prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, tgtpid, pidtype, &cookie)
prctl(PR_SCHED_CORE, PR_SCHED_CORE_CREATE, tgtpid, pidtype, NULL)
prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, tgtpid, pidtype, NULL)
prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_FROM, srcpid, pidtype, NULL)

The third argument should always be a process ID, and the fourth argument should be a kernel enum pid_type:

enum pid_type {
	PIDTYPE_PID,
	PIDTYPE_TGID,
	PIDTYPE_PGID,
	PIDTYPE_SID,
	PIDTYPE_MAX,
};

For the PR_SCHED_CORE_GET sub-command, the cookie should be of type unsigned long long according to the kernel doc:

userspace pointer to an unsigned long long for storing the cookie returned by PR_SCHED_CORE_GET command. Should be 0 for all other commands.

@SteveLauC
Copy link
Member

I think we should:

  1. Add pid_type to the libc crate
  2. Expose the full APIs, e.g., for the PR_SCHED_CORE_GET sub-command, it should be something like:
pub fn sched_core_get(tgtpid: Pid, pid_type: PidType) -> Result<libc::c_ulonglong>;

@devnexen devnexen marked this pull request as draft April 13, 2025 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants