From nobody Wed May 25 00:18:18 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 2EA1D1B3B77A; Wed, 25 May 2022 00:18:19 +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 4L7BVf6cp3z3mp5; Wed, 25 May 2022 00:18:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653437899; 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=qWApRzRV415RT8G3Q4s49Gcw8l046q1qMyXvj4US6Ps=; b=DblnQOSV1u4fnkdBDLLCMw3tNUhYA5Q3vsmDIrhI1uPs35ewCo7eodORY1DX+7EsOwAuzS uqLRt3XbxFvWIdPpcoqfzz0c24YQfDdO+lH18ABKtqNBtCf1WNmsTL5BSq5bgUIoHhOi/d MDSlN8B7/VvAK8YAApxJC4sYIFO3QAwRWfw941BpusHiY1Y7lE2/ya+WbjL7H/l7imxA7J oslDmzVulejPRBelDKE7AEzv1dyvlYblFr3+Kxuj4fthkoHnSnQnTBCPK+WZ/jHF+pslC+ dVPio7jDMaJhV01WVmWN9yZd+wUeWHgGC35hHpHobJZEk8zVzoKPqp8SfHBetg== 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 9C1F55F7F; Wed, 25 May 2022 00:18:18 +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 24P0IINB006062; Wed, 25 May 2022 00:18:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24P0IIuw006061; Wed, 25 May 2022 00:18:18 GMT (envelope-from git) Date: Wed, 25 May 2022 00:18:18 GMT Message-Id: <202205250018.24P0IIuw006061@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 524dadf7a872 - main - kevent: Fix an off-by-one in filt_timerexpire_l() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 524dadf7a8725dea144571843e611dbdbd59d668 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653437899; 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=qWApRzRV415RT8G3Q4s49Gcw8l046q1qMyXvj4US6Ps=; b=MSp/hUdxIPTUjwgStRlJ+kxjkPLOyoXR0RAU7o39w1o98rXPqzSGHdYZ68SEHUolpcu4WG hdHi6DkXBYCne6+NZI5tkYUw9pN3503NWW2uDkf2iMw0+ky3FqDY5CdiBxFaLLyE/TECPK df8BxWfuId8E1WtxuH2+IX5CZ9qf/GPMWi9k8KyHCgRktBhb0fz0uGJEuAx+eOPuGlhlIl wIjYJjdvVsE1xZBKtFkld4N6T4euYD7Qk9d/Lz0QaxobKYQtlYB8ydR1FHafOaBM3O742e 8HZoiUDd6fjZ8NfusNZngNF13rXO8qSQfLnpNzpAHc0edmlRTbZgqqBZrFWHFA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653437899; a=rsa-sha256; cv=none; b=Fo0dL6HLBejSpnAGXb5CA8AVBJaxD4Lj6igHdyIL21j8B3MJCsWDRIxV/j5JXTBZVKyOyr tkB56vrHWuelETuMsga8RMF+V1kSpVwCnUl1/PQSjNTPEF2P3XoeS47eC2r+H4hqltwy3w alp1cI5QlVj337bOewepDRWI5W9OQxktCHVRgE2Tngff1UEw4LFr49v3Dl1wY+mg64sgwD g7M5iVEH0E2F/rSiidf3QZ0GyU2JwsgLYX9UvEhyQreUXUxKxZ1Pu3V3qgrtluFLWc2rAA 29rfAU3IHdIrWHXt6tzqa1IGXeOWzNwreXKsLNh0YXiffh0ggJL2ipbREI1KfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=524dadf7a8725dea144571843e611dbdbd59d668 commit 524dadf7a8725dea144571843e611dbdbd59d668 Author: Mark Johnston AuthorDate: 2022-05-25 00:14:33 +0000 Commit: Mark Johnston CommitDate: 2022-05-25 00:14:33 +0000 kevent: Fix an off-by-one in filt_timerexpire_l() Suppose a periodic kevent timer fires close to its deadline, so that now - kc->next is small. Then delta ends up being 1, and the next timer deadline is set to (delta + 1) * kc->to, where kc->to is the timer period. This means that the timer fires at half of the requested rate, and the value returned in kn_data is similarly inaccurate. PR: 264131 Fixes: 7cb40543e964 ("filt_timerexpire: do not iterate over the interval") Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35313 --- sys/kern/kern_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 33607fe8c5f4..f1ee8de4e7ee 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -739,7 +739,7 @@ filt_timerexpire_l(struct knote *kn, bool proc_locked) if (delta == 0) delta = 1; kn->kn_data += delta; - kc->next += (delta + 1) * kc->to; + kc->next += delta * kc->to; if (now >= kc->next) /* overflow */ kc->next = now + kc->to; KNOTE_ACTIVATE(kn, 0); /* XXX - handle locking */