From nobody Fri Sep 18 14:15:01 2026 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 4hmZQG0ZVjz6sWP8 for ; Fri, 18 Sep 2026 14:15:02 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hmZQF2Sl2z4jVF for ; Fri, 18 Sep 2026 14:15:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789740901; 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=T6H1TaZiValf4bh4rOZ6JXXo26Y10IF+Sx4o2Y6VeuI=; b=C+EpAiHz0GxI4WQqMGDPzWBMiymPIWjgggsfW01PUWTbsTBH4AAH53YWRnYjTzcDRA9ksU HeqDoqtwWi3Ew/ZPEkoCu9pYQgi2+wwsRvhSmMKI8sWpCMcOJVXHAPjYYwZWu6oLS3eXdj 3XoJJ76Gn0FnD+dUOFzhwaIDHAJr9JOnfYmnw2gCu3B2PfSCXTsq1z3jt3PgN7ROj78rMp 7UiysfuAvwUatu2n6LxsjzRZlBtiNgEdEj6c/scku+vF4bbGd05Zy18zbU7JEXnJ5Rrx67 7KtOesoWJxcjThclegd7lUBcw4hx/Ye/z5S+7yUPK6nsDREur1gtdxfT0+/MHw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789740901; b=qjt7nhB/rH4JBNCfLjgGEOhVLRg4IhlJViJCVG46T/4GvoQDwffst0b4vR8ZPuutMQKFvX m4wQNvD7wJ7pVhVIhfm66UrAL3VpxlfESR6HjWIW7lTmNrI7GDJkxa/GlbQ5ztNtOIaLOS dOUK83toMpu5jw/tbgltMxLD+z+K/5PiVlqIavKFDgGUyte+N4IXa8dfCF8QtImdzX8wWO 19sbvDrIWw3+hDL2YWUR/26b8f1SHvMFU49TKtX0bfooeCnx0a6NObx/1t5NMJwPf/mnih c99Wqdrb/1M+ykT1MVtyaRfKF5fWngPBFwDm7mMUuc46iUpYiXllZ9rIWO6nfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789740901; 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=T6H1TaZiValf4bh4rOZ6JXXo26Y10IF+Sx4o2Y6VeuI=; b=Tc++YLcaKokpGMbXbZsa7Fv3Ff8vwxUzm+fPZHgHCsDPs90EOvvj6xnb0yn3gwtVmspmUb lG3q4LXus24htr0OB3B3c4gvMxo88nu4LhSfr2rw3OIcqVek89G6yVx/prIudDwT2DDFJ8 jGNwt1mE6f+4WNuNsAYtNUDmYSgdPcXQhoDxPXEs/ofbKTb9gBFVj7D797bPe7OBGRYX61 wfY5wTuB0hqRANo5ZwfdgBVmSa4+4e05S8AYegjJgD4KC7KouLuuS1k1PnYl7vGLEyeupC X1fjkW8I7XpMOPYyzVEcQuPw7UqkvomKsFvpz8S3ReQGEwZq1h/HYnLmmFhJLw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hmZQF1StwzM6T for ; Fri, 18 Sep 2026 14:15:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 44475 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 18 Sep 2026 14:15:01 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Minsoo Choo Subject: git: 5a879394ba2e - main - sched: factor out hogticks calculation into sched_update_hogticks() 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mchoo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5a879394ba2eac14f65b466a46dae39326df00db Auto-Submitted: auto-generated Date: Fri, 18 Sep 2026 14:15:01 +0000 Message-Id: <6aad4765.44475.35ecaa32@gitrepo.freebsd.org> The branch main has been updated by mchoo: URL: https://cgit.FreeBSD.org/src/commit/?id=5a879394ba2eac14f65b466a46dae39326df00db commit 5a879394ba2eac14f65b466a46dae39326df00db Author: Minsoo Choo AuthorDate: 2026-09-06 22:49:02 +0000 Commit: Minsoo Choo CommitDate: 2026-09-18 14:14:14 +0000 sched: factor out hogticks calculation into sched_update_hogticks() Suggested by: olce Reviewed by: olce Approved by: olce (mentor) MFC after: 2 weeks Sponsored by: FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D59471 --- sys/kern/sched_4bsd.c | 16 ++++++++++------ sys/kern/sched_ule.c | 17 +++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index cd039501b609..61b8c0e68691 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -133,6 +133,13 @@ static int realstathz = 127; /* stathz is sometimes 0 and run off of hz. */ static int sched_tdcnt; /* Total runnable threads in the system. */ static int sched_slice = 12; /* Thread run time before rescheduling. */ +static inline void +sched_update_hogticks(void) +{ + hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) / + realstathz); +} + static void setup_runqs(void); static void schedcpu(void); static void schedcpu_thread(void); @@ -206,8 +213,7 @@ sysctl_kern_4bsd_quantum(SYSCTL_HANDLER_ARGS) if (new_val <= 0) return (EINVAL); sched_slice = imax(1, (new_val + period / 2) / period); - hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) / - realstathz); + sched_update_hogticks(); return (0); } @@ -223,8 +229,7 @@ sysctl_kern_slice(SYSCTL_HANDLER_ARGS) if (new_val <= 0) return (EINVAL); sched_slice = new_val; - hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) / - realstathz); + sched_update_hogticks(); return (0); } @@ -660,8 +665,7 @@ sched_4bsd_initticks(void) realstathz = stathz ? stathz : hz; sched_slice = realstathz / 10; /* ~100ms */ - hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) / - realstathz); + sched_update_hogticks(); } /* External interfaces start here */ diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 34b376857ad9..ca55e5c1da7b 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -232,6 +232,14 @@ static int __read_mostly tickincr = 8 << SCHED_TICK_SHIFT; static int __read_mostly realstathz = 127; /* reset during boot. */ static int __read_mostly sched_slice = 10; /* reset during boot. */ static int __read_mostly sched_slice_min = 1; /* reset during boot. */ + +static inline void +sched_update_hogticks(void) +{ + hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) / + realstathz); +} + #ifdef PREEMPTION #ifdef FULL_PREEMPTION static int __read_mostly preempt_thresh = PRI_MAX_IDLE + 1; @@ -1659,8 +1667,7 @@ sched_ule_initticks(void) realstathz = stathz ? stathz : hz; sched_slice = realstathz / SCHED_SLICE_DEFAULT_DIVISOR; sched_slice_min = sched_slice / SCHED_SLICE_MIN_DIVISOR; - hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) / - realstathz); + sched_update_hogticks(); /* * tickincr is shifted out by 10 to avoid rounding errors due to @@ -3477,8 +3484,7 @@ sysctl_kern_quantum(SYSCTL_HANDLER_ARGS) return (EINVAL); sched_slice = imax(1, (new_val + period / 2) / period); sched_slice_min = imax(1, sched_slice / SCHED_SLICE_MIN_DIVISOR); - hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) / - realstathz); + sched_update_hogticks(); return (0); } @@ -3495,8 +3501,7 @@ sysctl_kern_slice(SYSCTL_HANDLER_ARGS) return (EINVAL); sched_slice = new_val; sched_slice_min = imax(1, sched_slice / SCHED_SLICE_MIN_DIVISOR); - hogticks = imax(1, (2 * hz * sched_slice + realstathz / 2) / - realstathz); + sched_update_hogticks(); return (0); }