From nobody Mon Oct 16 12:30:24 2023 X-Original-To: dev-commits-src-branches@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 4S8GfS6nthz4xJxG; Mon, 16 Oct 2023 12:30:24 +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 4S8GfS68SSz3c3x; Mon, 16 Oct 2023 12:30:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697459424; 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=wTjkyqevDmpoGtd6kTZMHAmTWvvVyjKGnLF9r7SJh40=; b=KGqGvPuiSSRSn4ZQ+fHASGQGulR6nM9CFlNlSlLVD7EACsDXr1YHUf+REItdtHtY1HSM2g kCYg+xxh4Og5GeVJF4zzdQFhAlpM35oyQElQyKBFDBJHRNQC+EI3DTGX5sxO3KPy/hTjB8 QxiQtL7Q5lhrbGfCafcS15ZPiXmTDA+c2GDao1N0EWO4yE2wjnu6UO+ntnWbZVrg/8r51s Lt8F+GEoqjQ7SEs3wItTm/OiB/mm2jrVHvilpl7YFWS/HQ/KMdx4LcMVoxk3fTvpXAcHlq W6k31PNv3ZHMpz1lpTT46wZtaRGMGs3ownF/qBp+djQ6P+sijcwIh2qws/RMxg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697459424; a=rsa-sha256; cv=none; b=h5ckszYNZulI1wbgZDgcNnfSSsBmZqT5gw+ChONtGpoyR2cRQ3GzGCGl9UpBiBGQm9J2nR vFP3EM9MIXaM/agKjLxPRUL81Q89TqKFtHtdFTbe1bjvqzviwbELs+8IaK1VeD7qHzueKr dy+GqFNrxQaquYD8x+jNnNmTGp+6LG3442Mxov6w9cUUXJXetcx0opAb+IdwS3WDNsypek CavP9FZhV+l9b8qxR+5pAltQgyTUsStdDcK7fbaIqxpj6etRTYjFjwy6vnVeJfapNplGw8 Ok2YnQWD64hpLViDVgZd0GNux5xbKqmjzLk/ZpG7U/zy8ghTaYIlb3AG089z2w== 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=1697459424; 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=wTjkyqevDmpoGtd6kTZMHAmTWvvVyjKGnLF9r7SJh40=; b=E7xbjbRErB2m64gkaCQwfL1VC65VgFaFgKsDI/Gtesa2PhQSNQBuPL0suLCL96wW5uBMIe 4iIJyPgeZzDZYyLwvld81Q8Md2hbh34nWkofgcvHCw1VLaiu0Xt81xRLsUZN5WiqnCN7b7 b0Wpi0klX+wzzR6g/BsDN4sYuU0oMRwy1oHzkbiXEokJ0TWbzLvrxfHZa2SfINYplMLuy5 rTSnLVeRk21F0cHUTQKDUzT6GJAX6uSy0HBSTyJ2M5aYY9b/qfLznrF+r0QcKXz/SfatHc duUgfMGptU20C31DetsfFF9b9mmx8IBYAUrX4al9jnIYcBfmg+qKguIafxZa5Q== 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 4S8GfS4TmJzgYn; Mon, 16 Oct 2023 12:30:24 +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 39GCUOoj079267; Mon, 16 Oct 2023 12:30:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39GCUOFJ079264; Mon, 16 Oct 2023 12:30:24 GMT (envelope-from git) Date: Mon, 16 Oct 2023 12:30:24 GMT Message-Id: <202310161230.39GCUOFJ079264@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: af632cc56bc3 - stable/14 - setusercontext(): Fix gap when setting a realtime-class priority List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: af632cc56bc3781ef4409dffe9296d5a69bb281a Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=af632cc56bc3781ef4409dffe9296d5a69bb281a commit af632cc56bc3781ef4409dffe9296d5a69bb281a Author: Olivier Certner AuthorDate: 2023-05-25 07:10:27 +0000 Commit: Ed Maste 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(-) 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",