From nobody Tue Apr 21 15:45:30 2026 X-Original-To: dev-commits-src-branches@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 4g0RWt46LBz6Wv83 for ; Tue, 21 Apr 2026 15:45:30 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g0RWt2gBKz3RYM for ; Tue, 21 Apr 2026 15:45:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776786330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n3uMALdmiPT8IRxGkDk8g1z+dPymhqTyYA29+Nf5HvQ=; b=Qu5YNtknAakiqfV2Nn4EFzF/rWQ14jJRLGltUalBXe/F+Y5MQVwaN8QEfVBncHPK76Ql0O UvtHERs1NI5iir/tkq+mbxNIukUdHcl5uGLAkyCB2oZpXR6oUUnUKLT8qENKY10HyviKJM O1aK8WAglJJKj2x3QsoOfMhq7D6NA+l2OxdSc2owdyAeGEn38TLwqMJJKSdOVzgPW9kfsE Ng+QBRexTdrxZ1KDKJ1nlgHbntXOEP69OMkLGedl+5KIb6blqUVSZ80XfdCYpViufP7vBL xQE314bSuQNfF87Fpkm8xm8O0tWUD47h1edRzbsE2JbzpZU23Adg5nQ98LtueA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776786330; a=rsa-sha256; cv=none; b=SBff5OR+A4W1+BvWiVDUlsFXBUSg6U/jUZD0H3OCch3lGATSMsWPYNxw3v/FdNUFWtZsKU A4ttx+qlr0iV/+qx8BVuGU9O+xWfktpHyAmfrVoaHwvSS4fTu7z/YMnuU0BbndYlUUz7pQ 5P6vNR+LSjVbPWnOb2QM9Rrj82nSEOReTfaT67pY9YcYpK38edNnCUaT8Wd/Ni4o9KurFU RG9J6HXdpWFGKfQsh1aOlLIxXjJyWnsCOLSAYrwD42cCad0aWJJ6Kax/uIaxXPSuOFPVYS cvkEaZXR1Gj+/kOWuKoXfvlBpHas6Gj0KBjfQnqTOewg6q7UQWp7K+vFWOM7rg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776786330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n3uMALdmiPT8IRxGkDk8g1z+dPymhqTyYA29+Nf5HvQ=; b=WtdV7UjzPs7tkYzXaOUTqfJBm1BehDHObGKaSJYQOeOcxXAa6gvYPgoraiS1BmKeLh79mR XCdDuTKwZ1idS9dZxynfzz417iouVFk5UJrsEyZ5p9m5n91L8sn+O66J2UpYWhv31jUIe5 VN4Sjg7YOqz4yxQ8/+CDqqTXPCR2HRRp5C5Had+YvMdNvzLthtsRQzSrEAhx5VhhO+hKwu QnkWrt8GTgbUhDxK0bM7ifNqqEvK9FGToqD3eFJ+M6DrmEStsNLGWdTk9gUjXu1wdI89It GaTJGD4/wI8cIjkshPl0LywVGQGF6zSsGCJAggf9pX8Bla8OkDrHxrWQRWimhA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g0RWt1zCyzr8N for ; Tue, 21 Apr 2026 15:45:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 36694 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 21 Apr 2026 15:45:30 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Jake Freeland From: Mark Johnston Subject: git: df8d2f945028 - releng/14.4 - timerfd: Fix interval callout scheduling List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.4 X-Git-Reftype: branch X-Git-Commit: df8d2f94502890cd2c40705deb70657d475ad8ed Auto-Submitted: auto-generated Date: Tue, 21 Apr 2026 15:45:30 +0000 Message-Id: <69e79b9a.36694.629fd11e@gitrepo.freebsd.org> The branch releng/14.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=df8d2f94502890cd2c40705deb70657d475ad8ed commit df8d2f94502890cd2c40705deb70657d475ad8ed Author: Jake Freeland AuthorDate: 2026-03-20 06:33:03 +0000 Commit: Mark Johnston CommitDate: 2026-04-21 15:45:06 +0000 timerfd: Fix interval callout scheduling When a timerfd interval callout misses its scheduled activation time, a differential is calculated based on the actual activation time and the scheduled activation time. This differential is divided by the timerfd's interval time and the quotient is added to the timerfd's counter. Before this change, the next callout was scheduled to activate at: scheduled activation time + timerfd interval. This change fixes the scheduling of the next callout to activate at: actual activation time + timerfd interval - remainder. Security: FreeBSD-26:06.timerfd Approved by: so Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D55790 MFC after: 2 weeks (cherry picked from commit 85c0f1a87da1fd1eb3e646e86f70e630c48da91a) (cherry picked from commit 3c00f603a2801fd780666f9e94a26f264a887c90) --- sys/kern/sys_timerfd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sys/kern/sys_timerfd.c b/sys/kern/sys_timerfd.c index 565ab3ad6ee6..236dfe8bb96a 100644 --- a/sys/kern/sys_timerfd.c +++ b/sys/kern/sys_timerfd.c @@ -393,23 +393,25 @@ static void timerfd_expire(void *arg) { struct timerfd *tfd = (struct timerfd *)arg; - struct timespec uptime; + sbintime_t exp, interval, now, next, diff; ++tfd->tfd_count; tfd->tfd_expired = true; if (timespecisset(&tfd->tfd_time.it_interval)) { + exp = tstosbt(tfd->tfd_time.it_value); + interval = tstosbt(tfd->tfd_time.it_interval); + now = sbinuptime(); + next = now + interval; + /* Count missed events. */ - nanouptime(&uptime); - if (timespeccmp(&uptime, &tfd->tfd_time.it_value, >)) { - timespecsub(&uptime, &tfd->tfd_time.it_value, &uptime); - tfd->tfd_count += tstosbt(uptime) / - tstosbt(tfd->tfd_time.it_interval); + if (now > exp) { + diff = now - exp; + tfd->tfd_count += diff / interval; + next -= diff % interval; } - timespecadd(&tfd->tfd_time.it_value, - &tfd->tfd_time.it_interval, &tfd->tfd_time.it_value); - callout_schedule_sbt(&tfd->tfd_callout, - tstosbt(tfd->tfd_time.it_value), - 0, C_ABSOLUTE); + + callout_schedule_sbt(&tfd->tfd_callout, next, 0, C_ABSOLUTE); + tfd->tfd_time.it_value = sbttots(next); } else { /* Single shot timer. */ callout_deactivate(&tfd->tfd_callout);