From nobody Wed Jun 18 02:13:12 2025 X-Original-To: dev-commits-src-main@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 4bMS2K392Jz5q6Gb; Wed, 18 Jun 2025 02:13:13 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bMS2J4l7Kz41PD; Wed, 18 Jun 2025 02:13:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750212792; 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=RTL4KR/XcV11or2EIDxtNYfVBFjyvI51ddlYp6gCJXk=; b=tHtmVKeg5pyFzYeKVNKNtk3KNFf+MpTAdxVXr1mcVSy4RM/vO5toLrIpcjJJOFHQbQEgzy 34fiYL/TzfdGp62Vc/1KCb8I9KxIak0Azzo4hqEP/LdONKHP9JFCOG+EOSNaDUFtR/Os3e gyI+ZdDuILmc/oAj+yBqoa786pZfFoUsKZ/BJ4eP82SJtXVlieI2h8tbtceqv2n8mFPlm/ QzXLRvfcpWef3b5jiThiu8cX2QS1rZfgvwSH3/l/r7llSmtJcIO9maShZz0vDed+fIJXyg 1wLUgeBVSSIIAzvRd8wp+02kvZkAzQzWJOPWcWcG05jeOCirlT0uc+00N9hbOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750212792; 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=RTL4KR/XcV11or2EIDxtNYfVBFjyvI51ddlYp6gCJXk=; b=xcEcQxeNaDrHfsZY25qLrvXaPapYgub24vAY9IT8KWBXb17fbuA9tCmbD/fQSEoqxVdmBh wf5belDBlQp3J9hMNfUH9X/2M+iNhQADAXAoBP8vC6CEasQYb0zu1n/O/Zvud7N/mKVjQh vkPuj/IJlCxdB465C2tEVm2/XrJTQ/ub8X9eLS0GFVYqUIExrd54N87GIxZtANErU7XjbU +ZTovLGQi4zqp6HHxingOfpJVHdKnHhz3x8MshPUpnlD3Q0UJn59ChrA+SyHWcQrQtcEJP YOkWobqRKegr8FtUOrHHQLqKmwggAeBv/oZa/70nuEGVV4c4v1fYMGL1+W0tmw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750212792; a=rsa-sha256; cv=none; b=a+Z1YC6TaN55gf6CdUjde0P0oEcPez5XpWpqpqXdm+/e/UkcYEgeZgMF1kSu1cxrg9jLin PuWt27vFo9Z6A9VtxkCDroPIQf8PXWCdeAjFxyOcMtY1TeWAw7ETO/JiHR3B0mPMIR+Xzc xBG8gnj2xBlJlWA7L7gakCYy60hjYRVECAN2/fBqL+6jtYXgRjNY2RDVjGYWaFqv7vzqC7 T61nNaT3bPNEWKWr3l+BR4AmAvQ3VX6KAB5wSh3vfxsb795OHn2ZXayq4opdRBzVsRrB4F CubAvrucru2tYsBGU4aYgK7ILBNFqCMpdVNV1IqIMgsVvnxBZYDUWdgww+OxSQ== 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 4bMS2J3DW4z18S9; Wed, 18 Jun 2025 02:13: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 55I2DCYh024073; Wed, 18 Jun 2025 02:13:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55I2DCXa024070; Wed, 18 Jun 2025 02:13:12 GMT (envelope-from git) Date: Wed, 18 Jun 2025 02:13:12 GMT Message-Id: <202506180213.55I2DCXa024070@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: 57540a0666f6 - main - runq: Clarity and style pass List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 57540a0666f6bfebf55c905dceac36230c0743c5 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=57540a0666f6bfebf55c905dceac36230c0743c5 commit 57540a0666f6bfebf55c905dceac36230c0743c5 Author: Olivier Certner AuthorDate: 2024-03-01 09:47:13 +0000 Commit: Olivier Certner CommitDate: 2025-06-18 02:07:58 +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 --- 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 */