From nobody Thu Nov 06 03:38:05 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 4d27F95zw4z6Fk5M; Thu, 06 Nov 2025 03:38:05 +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 4d27F95KSsz3wQr; Thu, 06 Nov 2025 03:38:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762400285; 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=9wHGXSi55GMhctkQX71BZLjgcEdzm91YhbDu7Uk3IQg=; b=ymQrorFjpDOhSxvOhjIGtQB05lDi6w+3pD20HTKosks5TSmmhW5KmaPIJ+W81AAKtxUnI8 Hf9mamHnPx8X6xGKyO1WDrxbA7BA4NpTJKEdxBdaPQlpCgGmzk5I6TThK2rgp9l941FZgq NDjH2uwkmpwmnPWTLKgZ9StRi9fJxCFQWEchk0xne7x6/sgm/E8CSLl8HZuQ0mbANF+6Kg uoTYWhxYMxMm5latUQdz4v3ja6Y7kZ8L7K1jYlaJI3q1VrlcMgI1hPh+9JdArrRnSiW9Uw mrxX+5slJUiFh5t4gVDDsyRfMA/zuLCkLupTerqKcza7cU9KQ6fnjT1dgtFBnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762400285; 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=9wHGXSi55GMhctkQX71BZLjgcEdzm91YhbDu7Uk3IQg=; b=ZEF91V92aM1LvEGszjhlcupl5ZyIOo5OyBduu0/jidS7vqycjh8NUv+DszQW94s4+1IizH II9jubhR2q9vXZucioJT26DdslrYFS/ZkhqcqSAIRRYYLI7ryhVIP4zbsmvZv8JrTxr0YE EFfSF16uYbwyrg2TCGeBJcSVSpIRhZdYUi0UzDDfE+rxxG8gt/6fTd9houtvvx3eGdfZJJ XbQHHk3xc2fuJmhbvXy614YQ/KctJ1EtkEr2x8f3BWrjSOt+MAU3ZdB7+ODg/kVYAjx3eA /e6QnZFYaWqLTKJvaac6jWay1SbjHT9oTtrbMxUEuApuKoYdiMlEuLpSkZJF1g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762400285; a=rsa-sha256; cv=none; b=URvoSS77T1U7IuPs5vWcgeMQNhk20wy9VFIxas4vsUVvHp+EjLC3l6Yvt98HBBFkdJTB0f Pb6BHZ3rWmIFQzFtJC+Cv0AiXkFh+asNO1NWaISkGS/bK2qsHRNCr0FSxbq7Sp6+KUAVJa MRz5IF1gb3bLO7Yb5P2SSOzqBiCyNkQnskl2IPjWwoUkogntb5k1NUndG8g1vfrLcDu4Cx FfkK9fiH3RYNns30v9iFMi78w83Ezpb5qTeyJDhca5J6z7ZvJRGPdc3FKNhzYj+s7KQT+w sbv2lAb1zqdAmNpGoCeqYSHfjyl2sRbIMpHFSukRM1/PLDqVHWz+6HImCm9E3g== 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 4d27F94FQFz1BB2; Thu, 06 Nov 2025 03:38:05 +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 5A63c5Ov090254; Thu, 6 Nov 2025 03:38:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A63c569090251; Thu, 6 Nov 2025 03:38:05 GMT (envelope-from git) Date: Thu, 6 Nov 2025 03:38:05 GMT Message-Id: <202511060338.5A63c569090251@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: 3ee596eeee19 - stable/15 - 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/stable/15 X-Git-Reftype: branch X-Git-Commit: 3ee596eeee198ede6860cf0c862fb5f8cfc81411 Auto-Submitted: auto-generated The branch stable/15 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=3ee596eeee198ede6860cf0c862fb5f8cfc81411 commit 3ee596eeee198ede6860cf0c862fb5f8cfc81411 Author: Olivier Certner AuthorDate: 2025-10-29 15:47:25 +0000 Commit: Olivier Certner CommitDate: 2025-11-06 03:36:28 +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 (cherry picked from commit 9530c6f082ada9e6d0323f36697ce53997ab2326) --- 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 7351e9cb6313..61e92678b54d 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; }