Bug 271727 - login.conf(5), setusercontext(): Gap when setting a realtime-class priority
Summary: login.conf(5), setusercontext(): Gap when setting a realtime-class priority
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Olivier Certner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-30 17:42 UTC by Olivier Certner
Modified: 2023-12-27 12:29 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Certner freebsd_committer freebsd_triage 2023-05-30 17:42:49 UTC
Using -21 is login.conf(5) results in a priority of 30 being set within the realtime class.  Lower values diminish the final priority (as expected), making it impossible to specify RTP_PRIO_MAX (31) from login.conf(5).

Differential revision to be linked after bug creation.
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-10-02 20:39:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=bd572be78436473a2ad4c1b78728b739c74ef238

commit bd572be78436473a2ad4c1b78728b739c74ef238
Author:     Olivier Certner <olce.freebsd@certner.fr>
AuthorDate: 2023-05-25 07:10:27 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-10-02 20:38:03 +0000

    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
    MFC after:              2 weeks
    Sponsored by:           Kumacom SAS
    Differential Revision:  https://reviews.freebsd.org/D40339

 lib/libutil/login_class.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-10-16 12:31:35 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=af632cc56bc3781ef4409dffe9296d5a69bb281a

commit af632cc56bc3781ef4409dffe9296d5a69bb281a
Author:     Olivier Certner <olce.freebsd@certner.fr>
AuthorDate: 2023-05-25 07:10:27 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-10-16 12:29:46 +0000

    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
    MFC after:              2 weeks
    Sponsored by:           Kumacom SAS
    Differential Revision:  https://reviews.freebsd.org/D40339

    (cherry picked from commit bd572be78436473a2ad4c1b78728b739c74ef238)

 lib/libutil/login_class.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-12-21 13:45:07 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=831792fc07cadd1aa3bc404843f45b8c2982b1bf

commit 831792fc07cadd1aa3bc404843f45b8c2982b1bf
Author:     Olivier Certner <olce.freebsd@certner.fr>
AuthorDate: 2023-05-25 07:10:27 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2023-12-21 13:38:46 +0000

    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)

 lib/libutil/login_class.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2023-12-27 12:29:25 UTC
^Triage: assign to committer that resolved and MFCed.