From nobody Sun Nov 02 18:17:13 2025 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 4d02xQ0VlPz6FD7S; Sun, 02 Nov 2025 18:17:14 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d02xQ0306z3QJ0; Sun, 02 Nov 2025 18:17:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762107434; 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=kItCZs9ImJ3wLErRzLvh+m9jqNq1HeiX/Ho1qvL705o=; b=W1Z+yrJEIH6Sfdqw4wjNQyZy+d1msP/+EA9nMieY7B6k1WpUQqphqAsKnRF1PDbd4okTLY eMBiSWpTabB0LIQb9fKhC7sCUwRnVjdEBXFJQv8wiBwP1g9/0ip8Dj7yIr1hSdCHXPxpWW ICiFNAlncs/ZisKxTpikSl6LSy/5BRrLHbHEh128arKDg2AeltGbgs7FfzU30ZrC1mfBiF 4pzoUmZIdS1zdEc53eDNuDCYaIvwD6iQWq+gpsaQCAWmBEeNyCF/fumS9zXiaAZSbk6BYD KUMY8BEVImJzjO9qh2uhLcwwpGoBlb791JxJgzh9eViiRZ6e80Mkrdoy9HtY0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762107434; 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=kItCZs9ImJ3wLErRzLvh+m9jqNq1HeiX/Ho1qvL705o=; b=tQ/aqOYl+cqRHT/h1iMMOA9duz24eKDjvhuX5pgGkHkf/b55WyGzCk8mDL14t6KkGmd/27 leMdx52XlZgQ05Ju/GSCuYH+VP6zkcGyFje8qTYVRE7BB1fsoHe62NB1TJAzOm34+Vxv8Q 3J3FCGvpNMphgScyDfYJ7pJSca/ehquQymPQIhYOlLlyxE6l1knW/uMHEFp3Lt3/jfvBgV n5iHxc5UEyK2AStQQjSds38xzZgxYTKYsAhEvPJ8ulIuZ/4lMUfNwG7HWol1Bsd+FaElEl gK9ST1uUPNsQCu6ATvVEKikG9ffZR4qJ7nC6Qg4y6Av/aoKUzciVNqCohnbCmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762107434; a=rsa-sha256; cv=none; b=N3IZ0WJVGwR0/wywLp+ysUPdlonlKpE3MfUgz80dUaW/Kk/boABt+YytsbzcS9YrLZ24EE GHfPxW6MSZVLJ1nQznGf+DZNMNB7hvUCyODhjVq6LIPQus8vNoYgYGCojeZxBkzAuCZILa EjKeD7WAW1ynOmjED5DTLaxsFU6b8oA2z+lsiPfSoz6tPrll8VSOwcdf5BmRGQrbUTsNiV ko7L0DVh87Q64a2uem6BgtBx9fRso+UcC2UPFS10ogYFbx9A+BaODGykTLQ86ji8G2cEtp IcquPDvhP2rvlLiWxHIYB3uUlvIe3jQuq2dJDSR0yKl7miLkZNa1Fjjf07Mm9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4d02xP5ln3zd25; Sun, 02 Nov 2025 18:17:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5A2IHD4w093807; Sun, 2 Nov 2025 18:17:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A2IHDJq093804; Sun, 2 Nov 2025 18:17:13 GMT (envelope-from git) Date: Sun, 2 Nov 2025 18:17:13 GMT Message-Id: <202511021817.5A2IHDJq093804@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 9530c6f082ad - main - racct: Simplify skipping idle process in the throttling daemon 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: 9530c6f082ada9e6d0323f36697ce53997ab2326 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=9530c6f082ada9e6d0323f36697ce53997ab2326 commit 9530c6f082ada9e6d0323f36697ce53997ab2326 Author: Olivier Certner AuthorDate: 2025-10-29 15:47:25 +0000 Commit: Olivier Certner CommitDate: 2025-11-02 18:15:23 +0000 racct: Simplify skipping idle process in the throttling daemon In racctd(), commit c72188d85a79 ("racct: Improve handling of the pcpu resource") added a superfluous test to skip the idle process when computing the resource usage and checking for limits, consisting of a comparison of the considered process' pointer with that of the process of the first CPU's idle thread. The P_IDLEPROC flag introduced in commit 33be1632047c ("racct: Fix accounting of CPU time for the system idle process") is sufficient and simpler for this purpose. In the second loop throttling processes based on their %CPU usage, the test excluding processes not in PRS_NORMAL was not consistent with that of the first loop (which tests for the idle process also). This had no practical consequences except a superfluous call to racct_pcpu_available() as the RACCT_PCTCPU counter stays at 0 on the idle process (because of the first loop). Factor out the test in the new racct_proc_to_skip() function. No functional change intended. Reviewed by: markj MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D53455 --- sys/kern/kern_racct.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c index 2aab151aba08..17b64ad00bb5 100644 --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -1236,16 +1236,20 @@ racct_updatepcpu_containers(void) racct_updatepcpu_post, NULL, NULL); } +static bool +racct_proc_to_skip(const struct proc *p) +{ + PROC_LOCK_ASSERT(p, MA_OWNED); + return (p->p_state != PRS_NORMAL || (p->p_flag & P_IDLEPROC) != 0); +} + static void racctd(void) { struct proc *p; - struct proc *idle; ASSERT_RACCT_ENABLED(); - idle = STAILQ_FIRST(&cpuhead)->pc_idlethread->td_proc; - for (;;) { racct_decay(); @@ -1253,12 +1257,7 @@ racctd(void) FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - if (p == idle) { - PROC_UNLOCK(p); - continue; - } - if (p->p_state != PRS_NORMAL || - (p->p_flag & P_IDLEPROC) != 0) { + if (racct_proc_to_skip(p)) { PROC_UNLOCK(p); continue; } @@ -1284,7 +1283,7 @@ racctd(void) */ FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - if (p->p_state != PRS_NORMAL) { + if (racct_proc_to_skip(p)) { PROC_UNLOCK(p); continue; }