From nobody Mon Oct 2 20:38:53 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rzt8Z0vvTz4wT3T; Mon, 2 Oct 2023 20:38:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rzt8Z0P4Fz3KLh; Mon, 2 Oct 2023 20:38:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696279134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sMew1gSyNVPm0xhzNs0Ur6CLjqtEyw9TPQHss5M2/sA=; b=oHdrREMmKGhdaOjmD5YhqwvAU4NO4V9e6tuvAlYtHAcST2HfQIDOjW5Zr8haWlt5RF4XFS wcdee+G4V7PS5CCW9fNnA/82/DL20dqXiJPkumeLTrA6qq54oWuIZ64vxIU8mCFPdOa6bR VUmIBzMrEdBrp3AGeu/Rnup9Av+IwcJwke0wODSMzMAxgvJUEs3eICcVS+26erUdXuqRfq iYPqEVgkVaYkQAsWaEUgcxw+1UxWVXVjuba8gdcDQxHVKU0eonJtM7JYj4JZ+6zsKUuM11 SUyp5aumxslVy7tuuC2HB4GYiasfVP8HQDkJ5bC5A3blKZGafVaYgJ/M/2FHSQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696279134; a=rsa-sha256; cv=none; b=ICAF5EzBs0eh91kyF0YJ+gishfjC/n/0AY67WUCLveX7RSpghZsh/9tp6cWsHv/JjpF3x/ VmP+++tqhi/eB6+86S6qSCu2ZSOWsPRFgOW/JGf2JsPzeTrYKWHr9VhqmVcTnQwOlxnfsb MmTkCYfArpJJyb/FdM0u0evQlx0TH1evEMlKV0UglziCvfkGr17Vwda0OLRR7HuEy2uBea F44K/2P+wm5OmOEl7wl1BHoPIqL7844LBVsViCoGPOwuQCO6jRDDR5y343fgpSpBUx8jqY 4geY73oPPih3yA7iEdfSfdBgj6u5Evjxs4cBfqBDVjwthMfCas1OnFq7EM5+og== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696279134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sMew1gSyNVPm0xhzNs0Ur6CLjqtEyw9TPQHss5M2/sA=; b=eyjBvLbESszYkO4oVuWRXmZwBg6Nhhb6S/jfxKtRhdeKXTRZcTBDvIdw83qr10rQxWft1p FGbZJpg1qfmaY0f7R9r/Ru4k9LoDINsh2Gfw+FBsFhXdggBftXGy1H/pYdg81QxTwFCSIL CJu4JuBwpLtHINRQsR92v013YSxhnN91TwqybNn6R9Q0+kgpgqkep83ZCaDgpOLBQVriuD 8q0+4QMPE5vb/Epgkizhq0w791UoDVr2WaiPxEloNzqUD3dPKfCie8NPG61U7wb64M44HL TG04Ztdea34uAux1qRZHYd3r4EHSu61DPLqp0yImDPkEDu1Y7BV06OZWYtpwVQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rzt8Y6Yl0zBfK; Mon, 2 Oct 2023 20:38:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 392Kcrbg003018; Mon, 2 Oct 2023 20:38:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 392Kcrrf003015; Mon, 2 Oct 2023 20:38:53 GMT (envelope-from git) Date: Mon, 2 Oct 2023 20:38:53 GMT Message-Id: <202310022038.392Kcrrf003015@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: bd572be78436 - main - setusercontext(): Fix gap when setting a realtime-class priority List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bd572be78436473a2ad4c1b78728b739c74ef238 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=bd572be78436473a2ad4c1b78728b739c74ef238 commit bd572be78436473a2ad4c1b78728b739c74ef238 Author: Olivier Certner AuthorDate: 2023-05-25 07:10:27 +0000 Commit: Ed Maste 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(-) diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index f561479690c1..90a3ec5d106a 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -452,7 +452,7 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in if (p > PRIO_MAX) { rtp.type = RTP_PRIO_IDLE; - p -= PRIO_MAX + 1; + p += RTP_PRIO_MIN - (PRIO_MAX + 1); rtp.prio = p > RTP_PRIO_MAX ? RTP_PRIO_MAX : p; if (rtprio(RTP_SET, 0, &rtp)) syslog(LOG_WARNING, "rtprio '%s' (%s): %m", @@ -460,7 +460,7 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in lc ? lc->lc_class : LOGIN_DEFCLASS); } else if (p < PRIO_MIN) { rtp.type = RTP_PRIO_REALTIME; - p -= PRIO_MIN - RTP_PRIO_MAX; + p += RTP_PRIO_MAX - (PRIO_MIN - 1); rtp.prio = p < RTP_PRIO_MIN ? RTP_PRIO_MIN : p; if (rtprio(RTP_SET, 0, &rtp)) syslog(LOG_WARNING, "rtprio '%s' (%s): %m",