From nobody Mon Jul 28 13:31:12 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 4brKBB1rCmz634XX; Mon, 28 Jul 2025 13:31: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4brKB86Xsrz3tHB; Mon, 28 Jul 2025 13:31:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753709472; 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=1fOrEZIOnL+2H38XdyPblSpcJYUVPHbQ6RkSvPAC2oI=; b=ywO8Jmb/cJAsE++K+DV8ILkgW+RAldPs4gsUmM3juZrwUXcAGKuB+y8UW18SV/IBsvQG8F kH3LS5JZKyxKghtoQTN+9qqs4UAsLZ6O2P0q8BAkfrmhZ6iC90t+byLYePkX/hSYfMVVfS dQxCvkBqqW6ZAwG7Hyw4pYRV1FyNhnLCa0yJsWzV5bOFEmva6zOb0oHkGrTd9Ve0BgrAUt DuACgqBRzrjxzUisTRt7kTTRZe/jI3qOav8Mzg5gB1YuxPiBEJPGVmulNACQZhVrtR4HfI mKosmeeOhY0eUejyPxSJXRzGHvxvkf0FTO/N6n9CtIvyj4FV/8ebc8SXH2nwjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753709472; 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=1fOrEZIOnL+2H38XdyPblSpcJYUVPHbQ6RkSvPAC2oI=; b=D1CcOasflOavDK4J21rF2RPV+jbAZAW9MP8zuJhcU7SmCmpifukWIsY04fH1agdOd4OMSn t5OI1YZC9eQGcPZLE3eFGogM8uPmcNuAjtz9R0CUB9wYTO37Vp6PG+Ue/M58FmmBz8DOpd /PC0/Aj0KMAID/CIWN/YB1q7KOpgWC3XqWO7uVOTo1GtFJEXsJCHLhmfn0wL4kL+PUweDi JVtsCsGO0a+V5DwOdXAuKdynb3AQ3FYCA28y71EL+znmx/3ufB33VlTuiMt0FlUYTjCgtz sWE80VvzgmtmTb56WWffc84P9C97Q6YRolylTxBoUSo42rbmD4YBvQdPYJNvyg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753709472; a=rsa-sha256; cv=none; b=aGBg1Drghs9CrxVD3dWBSrJyDElyNxNkvKGWnuz5t8JFN8vatrZJdOzqj2bIIFYMAEfWuM QMna8/Ygdg+pG8FENECXxnBLy0/XJcMlLl+l6DL6ZLVUdEOJAfMWp7h0ZvuVSWjzko/Swq LeIRoJNcT25HJTwmMuyn2k80/hPq5zCJu/XaS8sUkztBvOxhenD2lkO2aaoiAk0GY/nqRd SkbLeqAiFr3wN9W26D+XB9DLdWuAppCeplcH5PAlNdNnKdDOS8PkOUJeUWETdUTr4O5oE4 wNi2OL1Z7KAwwwCxEnF6goVVoc3C4/GXpkhiEIOMcauVFcrCQAu8PQXaS4+NUA== 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 4brKB84fJFznJQ; Mon, 28 Jul 2025 13:31:12 +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 56SDVCs9080025; Mon, 28 Jul 2025 13:31:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56SDVCP9080022; Mon, 28 Jul 2025 13:31:12 GMT (envelope-from git) Date: Mon, 28 Jul 2025 13:31:12 GMT Message-Id: <202507281331.56SDVCP9080022@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: b6e0a4f51747 - stable/14 - runq: Clarity and style pass 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/14 X-Git-Reftype: branch X-Git-Commit: b6e0a4f51747375dfe80fda19a64930912a8ac33 Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=b6e0a4f51747375dfe80fda19a64930912a8ac33 commit b6e0a4f51747375dfe80fda19a64930912a8ac33 Author: Olivier Certner AuthorDate: 2024-03-01 09:47:13 +0000 Commit: Olivier Certner CommitDate: 2025-07-28 13:28:04 +0000 runq: Clarity and style pass In runq_choose() and runq_choose_fuzz(), replace an unnecessary 'while' with an 'if', and separate assignment and test of 'idx' into two lines. Add missing parentheses to one 'sizeof' operator. Remove superfluous brackets for one-line "then" and "else" branches (to match style elsewhere in the file). Declare loop indices in their 'for'. Test for non-empty bit sets with an explicit '!= 0'. Move TABs in some prototypes of (should not split the return type specifier, but instead separate the type specifier with the function declarator). No functional change intended. Reviewed by: kib MFC after: 1 month Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45387 (cherry picked from commit 57540a0666f6bfebf55c905dceac36230c0743c5) --- sys/kern/kern_switch.c | 24 ++++++++++++------------ sys/sys/runq.h | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index 5c529862bc53..906efca4bb51 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -269,7 +269,7 @@ runq_init(struct runq *rq) { int i; - bzero(rq, sizeof *rq); + bzero(rq, sizeof(*rq)); for (i = 0; i < RQ_NQS; i++) TAILQ_INIT(&rq->rq_queues[i]); } @@ -300,11 +300,11 @@ static __inline int runq_findbit(struct runq *rq) { struct rqbits *rqb; - int idx, i; + int idx; rqb = &rq->rq_status; - for (i = 0; i < RQB_LEN; i++) - if (rqb->rqb_bits[i]) { + for (int i = 0; i < RQB_LEN; i++) + if (rqb->rqb_bits[i] != 0) { idx = RQB_FFS(rqb->rqb_bits[i]) + i * RQB_BPW; CHECK_IDX(idx); CTR3(KTR_RUNQ, "runq_findbit: bits=%#x i=%d idx=%d", @@ -390,11 +390,10 @@ runq_add_idx(struct runq *rq, struct thread *td, int idx, int flags) rqh = &rq->rq_queues[idx]; CTR4(KTR_RUNQ, "runq_add_idx: td=%p pri=%d idx=%d rqh=%p", td, td->td_priority, idx, rqh); - if (flags & SRQ_PREEMPTED) { + if (flags & SRQ_PREEMPTED) TAILQ_INSERT_HEAD(rqh, td, td_runq); - } else { + else TAILQ_INSERT_TAIL(rqh, td, td_runq); - } } /* @@ -405,11 +404,10 @@ bool runq_not_empty(struct runq *rq) { struct rqbits *rqb; - int i; rqb = &rq->rq_status; - for (i = 0; i < RQB_LEN; i++) - if (rqb->rqb_bits[i]) { + for (int i = 0; i < RQB_LEN; i++) + if (rqb->rqb_bits[i] != 0) { CTR2(KTR_RUNQ, "runq_not_empty: bits=%#x i=%d", rqb->rqb_bits[i], i); return (true); @@ -429,7 +427,8 @@ runq_choose_fuzz(struct runq *rq, int fuzz) struct thread *td; int idx; - while ((idx = runq_findbit(rq)) != -1) { + idx = runq_findbit(rq); + if (idx != -1) { rqh = &rq->rq_queues[idx]; /* fuzz == 1 is normal.. 0 or less are ignored */ if (fuzz > 1) { @@ -471,7 +470,8 @@ runq_choose(struct runq *rq) struct thread *td; int idx; - while ((idx = runq_findbit(rq)) != -1) { + idx = runq_findbit(rq); + if (idx != -1) { rqh = &rq->rq_queues[idx]; td = TAILQ_FIRST(rqh); KASSERT(td != NULL, ("runq_choose: no thread on busy queue")); diff --git a/sys/sys/runq.h b/sys/sys/runq.h index 693a3666d7a8..030b4bb370a8 100644 --- a/sys/sys/runq.h +++ b/sys/sys/runq.h @@ -90,9 +90,9 @@ struct runq { void runq_add(struct runq *, struct thread *, int _flags); void runq_add_idx(struct runq *, struct thread *, int _idx, int _flags); bool runq_not_empty(struct runq *); -struct thread *runq_choose(struct runq *); -struct thread *runq_choose_from(struct runq *, int _idx); -struct thread *runq_choose_fuzz(struct runq *, int _fuzz); +struct thread *runq_choose(struct runq *); +struct thread *runq_choose_from(struct runq *, int _idx); +struct thread *runq_choose_fuzz(struct runq *, int _fuzz); void runq_init(struct runq *); bool runq_remove(struct runq *, struct thread *); #endif /* _KERNEL */