From nobody Sat Nov 12 12:41:44 2022 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 4N8ZvY3D8qz4ffJQ; Sat, 12 Nov 2022 12:41:45 +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 4N8ZvY11xgz3skS; Sat, 12 Nov 2022 12:41:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668256905; 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=8IieZ5UI89IBAosMt2FboeZax8IY9pTmbl7aAg93vF0=; b=SnEuJ1rXtjbODGcqkVVaVcScn/Cfl5zJjJQv+rc4Nbf7Fthz33OByczJQUDLTCZWFzE1Li Va7pcw+7B9ebbDG2x9LEq4/WsSPi9ndgfLy0iE/STI92L3OggLmJf53HaROXWDq/2+WkY0 8T8d8AYUzZ8S/fv2T/LmhHRHwbmx1di4bnk8hRJ1war+FvFzdeUlDOTGixUV+Hi97xul4K 1m/nksgscUHhwsGphh7MKKjAolp29pHatDrjDTksEEr21W9OvwRB5kgKJMPSzwp3cqQneW 0FYr4XNSyiatgHR+LEpxCXUD/6m5KYLzAiF1bDbdXiceQ280sJsQz7bqBga2mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668256905; 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=8IieZ5UI89IBAosMt2FboeZax8IY9pTmbl7aAg93vF0=; b=kiEgIEnt79H8Sh1bqpQ8MsP1gVvUY3gzgR6DKUy7lybZc/RzMw32lFY6aB9be9pHKqEYUA pBuAFafYVCR73SKkOsFw+NkIHa8zQqaHsbptf5VeF5vuWKFxJzqpfG/45ilfImu5iTfsnM zo+332bwU7OF55wfCcycbxsiESJNxdNl8IUQEcjLHIVmO4OP76V64jmKCMWU19e1oqbp7Y 2kIDDJNlZBdOA7+TGmPIkroJZw9GIn96rjgb/hxxSCdEhyBF0SHlgq+oFeCm3hgTc6QlRs MTRiaYcZKnQqmuGhASU3Yo2+ztXcDkolqnoq/D5qEnib5fqRKx8lCHObIojiEw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668256905; a=rsa-sha256; cv=none; b=n5wTpA/5rHD+Hqq65qV866QJeYEf4WIF6SYmLJAR5a7VMV0VBts5TGL7atIbGgD7PGm3Gl AziVQIPQNboUBy1iSdmoBSVgfiUaTjgIpoUdYnkx3zL0JivwWwAklpxJ7xm8OkPecBGOmF h5hIpoHeas+9a0AyCX5iennN3W4QRaQViXkRvfrc3k5AGE5lpibpKWoJVcoIyG1Gu5s6As qjseZnAs0gULIe0BN8wMjCt45cTNU3cQNg/LKMb1bOpW/kq9Cz1yzdRTmtWiF1Iz+kNYU6 CUaRL/rlx/lS0b82947MPofKWfPWC1QWJUaWkBeJFSAhCZO+x/BYcOcnNPNA5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4N8ZvX75MKzNmJ; Sat, 12 Nov 2022 12:41:44 +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 2ACCfiNp054799; Sat, 12 Nov 2022 12:41:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ACCfiQK054798; Sat, 12 Nov 2022 12:41:44 GMT (envelope-from git) Date: Sat, 12 Nov 2022 12:41:44 GMT Message-Id: <202211121241.2ACCfiQK054798@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: eb9766b37ca5 - stable/13 - time(3): Align fast clock times to avoid firing multiple timers. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: eb9766b37ca5432ddab6590a2c96e9043843bfaa Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=eb9766b37ca5432ddab6590a2c96e9043843bfaa commit eb9766b37ca5432ddab6590a2c96e9043843bfaa Author: Hans Petter Selasky AuthorDate: 2022-10-03 08:54:40 +0000 Commit: Hans Petter Selasky CommitDate: 2022-11-12 11:59:32 +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 @ Sponsored by: NVIDIA Networking Differential Revision: https://reviews.freebsd.org/D36858 (cherry picked from commit 0def80f1a5c8f7a02b92c823e5c71f9f746c3e6b) --- 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 8a0b140c2794..f0129e96a294 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -707,6 +707,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) { @@ -739,14 +740,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;