From nobody Thu Dec 21 13:43:46 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 4Sws8g4k02z54pty; Thu, 21 Dec 2023 13:43:47 +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 4Sws8g1Y3vz4P2q; Thu, 21 Dec 2023 13:43:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703166227; 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=E/m5nWXpQ8vk/tsvr1K6HjPgD6wZbOeEidmXplB+V3A=; b=Dl5XqmxOpRoOrk42uDp/cOpLzwh1X7v7EyZneDQCz9QqUC1CkCqvT28W/Lrb4tDcONtkju 9nN06MaI5DLedb7nC60IFyZI+YHImS2hzgR98oaa3C+AMuB/0EpL+CEBTmMbvvJO39yQUL mNmbzuH93hayRecimpGIv6oStSiCGvc5oS9RHa7AwxO8fWLmN+nzi8u0Y1cWXbW2Rzu14x OogrrBlV4oGbNgHI/5wWxRXs+2GUTAFh8zy+pNjLVBfV10pkZUDiFlV7tBTw1Lj4hQytZd Ieyh6kUzuvpyFMTtV1RlK/nnRKRSPlyiqkcp6HKoRw7zxiK4cRu0lW+syJN2mA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703166227; a=rsa-sha256; cv=none; b=I5xDNFNiyumZ1SfPx9KMTGZ8PnbLdAlI+X3Cd7sh36zSsU3vMdnvhBajpIphPUiPWH/4Ho sZle0DYp6lreyb4ku0MU54eio2vMUtTKTX4L4Gq/OJFuXGQe613ViIEFLkIZ1YnRoeST8i ApQ7n+sVVq7chwGhpxSBpUJGpdlVzkVgCpUm7Ipn5x9HkQFlsX58jgGBdFNI1RUOKOsxsW GGxrvBZHigC29rQFV3S/ieoAdsr5RqZ5vF83qTVunIp41+yZfokHTXWbGNaREcUjeAgPGz oJ0T2oxAS2LM4VKW0xn1siS78n+xoIHp1uk+XTdZtQGzjf0Z+p9vPP+7203T1w== 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=1703166227; 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=E/m5nWXpQ8vk/tsvr1K6HjPgD6wZbOeEidmXplB+V3A=; b=GZ3j1b9f3t6+Hp8w8cB2O79+qLf/G+PyiQLK1CqA/mqW87vESA8yqUtX/7TIsY/Fr8vpJB bEOORNxojU7ykAuMbXUcyK40ePXGa+AFocQ1vc1FoSOqZZcdCIlsbFAOBqQ+N0Pz0LKtlA A6c7csioWdzAJGwrKw6LbA5sOPwnuRcJ3cauw6PZeTG/FAvQ5IhWc9vKaNy4eiwb85uqh1 JNLpn07LgFbHz0HWCy8hgKq5AMZ0O/VFbMg93bqASXqPOgQxvtddnx/s2Hx/Ubqoc1H51h FL3PtELGC88nAiKkfWUZsh1sd3DEKk/U2OVSYjbFdeBbPHGiNCFKlft3O8oISQ== 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 4Sws8g0HSLzZmQ; Thu, 21 Dec 2023 13:43:47 +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 3BLDhksh079564; Thu, 21 Dec 2023 13:43:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BLDhksw079561; Thu, 21 Dec 2023 13:43:46 GMT (envelope-from git) Date: Thu, 21 Dec 2023 13:43:46 GMT Message-Id: <202312211343.3BLDhksw079561@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 831792fc07ca - stable/13 - 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: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 831792fc07cadd1aa3bc404843f45b8c2982b1bf Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=831792fc07cadd1aa3bc404843f45b8c2982b1bf commit 831792fc07cadd1aa3bc404843f45b8c2982b1bf Author: Olivier Certner AuthorDate: 2023-05-25 07:10:27 +0000 Commit: Olivier Certner 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(-) 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",