Date: Fri, 19 Dec 2025 09:19:17 +0000 From: Olivier Certner <olce@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: bd26c99b688e - stable/14 - racct: Simplify skipping idle process in the throttling daemon Message-ID: <69451895.3f0fc.100b66eb@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=bd26c99b688e4f9dabfc477d6e89ead587f923f4 commit bd26c99b688e4f9dabfc477d6e89ead587f923f4 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2025-10-29 15:47:25 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2025-12-19 09:16:47 +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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c index 13df4724f860..0e359dfe85cf 100644 --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -1226,6 +1226,13 @@ racct_decay(void) racct_decay_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) { @@ -1243,8 +1250,7 @@ racctd(void) FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - if (p->p_state != PRS_NORMAL || - (p->p_flag & P_IDLEPROC) != 0) { + if (racct_proc_to_skip(p)) { if (p->p_state == PRS_ZOMBIE) racct_set(p, RACCT_PCTCPU, 0); PROC_UNLOCK(p); @@ -1297,7 +1303,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; }help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69451895.3f0fc.100b66eb>
