HomeFreeBSD

setusercontext(): Fix gap when setting a realtime-class priority

Description

setusercontext(): Fix gap when setting a realtime-class priority

The login.conf's "priority" capability allows to set priorities in the
idle or realtime classes in addition to the classical nice values (-20
to 20), through a natural extension where values greater than 20 put the
processes in the idle class (with priority adjusted within RTP_PRIO_MIN
and RTP_PRIO_MAX, 21 being converted to 0, 22 to 1, etc.) and values
lower than -20 put the process in the realtime class (with priority
adjusted within RTP_PRIO_MIN and RTP_PRIO_MAX, -21 being converted to
RTP_PRIO_MAX (31), -22 to 30, etc.).

Before this fix, in the latter case (realtime class), -21 was converted
to 30, and RTP_PRIO_MAX (31) could never be specified.

While here, change the priority computation for the idle-class case to
be symmetrical and use RTP_PRIO_MIN (in practice, this changes nothing
at all, since RTP_PRIO_MIN is 0; but this is the correct theoretical
formula, which would work as well with other values of RTP_PRIO_MIN).

PR: 271727
Reviewed by: imp, kib
Sponsored by: Kumacom SAS
Differential Revision: https://reviews.freebsd.org/D40339

(cherry picked from commit bd572be78436473a2ad4c1b78728b739c74ef238)

Approved by: markj (mentor)

Details

Provenance
olceAuthored on May 25 2023, 7:10 AM
Reviewer
imp
Differential Revision
D40339: setusercontext(): Fix gap when setting a realtime-class priority
Parents
rGf63da9704585: sysctl(8): Mention more security.bsd knobs; Refer to security(7)
Branches
Unknown
Tags
Unknown