From nobody Mon Oct 3 15:53:55 2022 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 4Mh53l6sG3z4d48J; Mon, 3 Oct 2022 15:53:55 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mh53l6HjHz3GWl; Mon, 3 Oct 2022 15:53:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664812435; 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=W54HglRTGOfmGs/c84+XLJH+B+6A5sGoapSsyOjuuqQ=; b=nw6muAIox0VO/lUwr7LIiVPjHOAFBPNZQ8NJ6pGbfnjxMRiH8TUCPVV96ya1z7oNrHPMRR KxRtJepEqeeYmnMcgzSXWstQjqSiwWKJ49SuLQfKKXw8snWOjMvOT0O7A9OtckELAAI8H4 Hfczr4saAmhVzbCJ8zX+dJqP0fb2/fACi6Yu4HaQks/qd5kLyNZkxiyy0nH0XufkiCp6Nt 85K3zRiRHktxF3uGRYjw8Z2q8rWqWsVByNBKcHVZ6denaNfi5H/Dol1iJKfcKJqKnT0dX7 pgNiz8mrVg8wZXvB3dC1CDG27YsvNwMTKWuC215DErC/62ZqTa1jv4ZoPtBzrw== 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 4Mh53l5JpyzG3H; Mon, 3 Oct 2022 15:53:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 293FrtKd008929; Mon, 3 Oct 2022 15:53:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 293Frt08008928; Mon, 3 Oct 2022 15:53:55 GMT (envelope-from git) Date: Mon, 3 Oct 2022 15:53:55 GMT Message-Id: <202210031553.293Frt08008928@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 0def80f1a5c8 - main - time(3): Align fast clock times to avoid firing multiple timers. 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0def80f1a5c8f7a02b92c823e5c71f9f746c3e6b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664812435; 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=W54HglRTGOfmGs/c84+XLJH+B+6A5sGoapSsyOjuuqQ=; b=X7lTSNIuaeKkaI1Q875352I+JZVE3SuSeMpAu72Vkl/6ZZlShG83b7vmFFLCqNPxpwoaIq 2ecQJJeRGoDXtX7TSYuX6Cwsu/lE99m18LKX9ZQiyJ4nIa5cw1Daf5b6spQDzOfX6P5I8H iIDpjy6wgy/SdvoGKl2fMgyYOiipOMNh9p49No1stKEk3QuBPKKGhuUdmnl6MpZPF+mTFP GGntxeRGNP6fvldmpIOWioKwsDHNy9b7RVS/IJv56zbkQXlXYvfmWHuXoERCLJI3S09VQi E45QJ3SghLeRQD4ExXhOC04tuOwT1mPr3oTEJpA4SfKWozX15neTdg/n88ZBmA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664812435; a=rsa-sha256; cv=none; b=tOG9Kx+mP9UO9j1SBdYQxs0Awf6+gLUJuYsT0Cq5c4yO3cCo53XnajxR2iPfbiHevLDkjL apLM0ZtcpCwpbblKqV79LXS3BitoVFmeo63BqWh5srMjKE9G8OveGYkEmY5scEzwYgjvYO A/UYUiu+cX6edOEAr63V+R/kcoNBWwA18On3wD6QNBAB/Lx4oA9wg2MSz5YAkgM8Yz9kvU vXwhvrIQTEfavqVvemfxsRWsti4i06iEOHFv0VOIcP0TNlAzVUXandUoBY1EU3sFM+jQvs XDJ0O5lDl7AgzeIOY6xrAISzoy5ebW/w/pLTqZz+pFdnn+vvboEBHdMeCUfkmQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=0def80f1a5c8f7a02b92c823e5c71f9f746c3e6b commit 0def80f1a5c8f7a02b92c823e5c71f9f746c3e6b Author: Hans Petter Selasky AuthorDate: 2022-10-03 08:54:40 +0000 Commit: Hans Petter Selasky CommitDate: 2022-10-03 15:53:17 +0000 time(3): Align fast clock times to avoid firing multiple timers. In non-periodic mode absolute timers fire at exactly the time given. When specifying a fast clock, align the firing time so that less timer interrupt events are needed. Reviewed by: rrs @ Differential Revision: https://reviews.freebsd.org/D36858 MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/kern/kern_umtx.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 6b4e3ca38d03..75ce1dc43f81 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -706,6 +706,7 @@ umtx_abs_timeout_getsbt(struct umtx_abs_timeout *timo, sbintime_t *sbt, { struct bintime bt, bbt; struct timespec tts; + sbintime_t rem; switch (timo->clockid) { @@ -738,14 +739,24 @@ umtx_abs_timeout_getsbt(struct umtx_abs_timeout *timo, sbintime_t *sbt, return (0); } *sbt = bttosbt(bt); + + /* + * Check if the absolute time should be aligned to + * avoid firing multiple timer events in non-periodic + * timer mode. + */ switch (timo->clockid) { case CLOCK_REALTIME_FAST: case CLOCK_MONOTONIC_FAST: case CLOCK_UPTIME_FAST: - *sbt += tc_tick_sbt; + rem = *sbt % tc_tick_sbt; + if (__predict_true(rem != 0)) + *sbt += tc_tick_sbt - rem; break; case CLOCK_SECOND: - *sbt += SBT_1S; + rem = *sbt % SBT_1S; + if (__predict_true(rem != 0)) + *sbt += SBT_1S - rem; break; } *flags = C_ABSOLUTE;