From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 14 17:18:47 2014 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C6DCDC51; Mon, 14 Apr 2014 17:18:47 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4EE11129A; Mon, 14 Apr 2014 17:18:47 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.8/8.14.8) with ESMTP id s3EHIZcm042940; Mon, 14 Apr 2014 20:18:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua s3EHIZcm042940 Received: (from kostik@localhost) by tom.home (8.14.8/8.14.8/Submit) id s3EHIYJW042939; Mon, 14 Apr 2014 20:18:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 14 Apr 2014 20:18:34 +0300 From: Konstantin Belousov To: Baptiste Daroussin Subject: Re: [CFR] Kevent timer improvements Message-ID: <20140414171834.GJ4016@kib.kiev.ua> References: <20140310131632.GI6900@ithaqua.etoilebsd.net> <20140310180404.GI32089@funkthat.com> <20140413131550.GD17898@ivaldir.etoilebsd.net> <20140413142028.GD4016@kib.kiev.ua> <20140413191928.GE17898@ivaldir.etoilebsd.net> <20140413202038.GE4016@kib.kiev.ua> <20140414061936.GA60058@ivaldir.etoilebsd.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="poemUeGtc2GQvHuH" Content-Disposition: inline In-Reply-To: <20140414061936.GA60058@ivaldir.etoilebsd.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: desrt@desrt.ca, John-Mark Gurney , "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Apr 2014 17:18:47 -0000 --poemUeGtc2GQvHuH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 14, 2014 at 08:19:37AM +0200, Baptiste Daroussin wrote: > On Sun, Apr 13, 2014 at 11:20:38PM +0300, Konstantin Belousov wrote: > > On Sun, Apr 13, 2014 at 09:19:28PM +0200, Baptiste Daroussin wrote: > > > On Sun, Apr 13, 2014 at 05:20:28PM +0300, Konstantin Belousov wrote: > > > > On Sun, Apr 13, 2014 at 03:15:51PM +0200, Baptiste Daroussin wrote: > > > > > I have splitted my patch in multiple parts, let start with the fi= rst one: > > > > > adding NOTE_NSECONDS, NOTE_USECONDS, NOTE_NSECONDS > > > > >=20 > > > > > http://people.freebsd.org/~bapt/kevent_timer.diff > > > >=20 > > > [...] > > > > > + else if (flags & NOTE_NSECONDS) > > > > > + modifier =3D SBT_1NS; > > > > It is better to put the 'modifier =3D SBT_1MS;' statement as the el= se part. > > > >=20 > > > > That said, IMO it would be sometimes beneficial to have real flag to > > > > specify milliseconds precision, in addition to milliseconds be the > > > > default. > > >=20 > > > Done in the new patch > > > > > + > > > > > + timer2sbintime(kn->kn_sdata, kn->kn_sfflags), 0 /* 1ms? */, > > > > There, at least the comment about precision should be updated. > > > > But, it seems that for the seconds precision, it makes sense to > > > > specify e.g. 1/2 sec as precision; or add an API flag to allow impr= ecise > > > > callout scheduling. > > > >=20 > > > While I do agree this might be useful I do not have time to work on t= hat right > > > now so I just removed the comment which wasn't really accurate anyway. > > >=20 > > > Is that ok? > > Leave XXX comment right near the zero argument, at least ? > >=20 > > > + if (flags & NOTE_SECONDS) > > > + modifier =3D SBT_1S; > > > + else if (flags & NOTE_USECONDS) > > > + modifier =3D SBT_1US; > > > + else if (flags & NOTE_NSECONDS) > > > + modifier =3D SBT_1NS; > > > + else > > > + modifier =3D SBT_1MS; > > There should be a case for NOTE_MSECONDS. > >=20 > ok I'll do > > Hm, I think the checks should be made stronger. System should ensure > > that only one flag is passed, and no invalid flags are supplied, right ? >=20 > I can check that only one flags is passed and no invalid flagrs are suppl= ied but > from what I see not a single part of kqueue(2) is checking that, so won't= that > be inconsistent with the rest of the API? IMO we should move forward with the better practice. I consider the current lack of the checks as the deficiency, which hides the application bugs. See the RFTSIGNUM/RFTSIGFLAGS/RFTSIGMASK in unistd.h or VM_ALLOC_COUNT/VM_ALLOC_COUNT_SHIFT for the idiomatic way to handle similar needs. >=20 > I can probably check that only ona or 0 of the NOTE_*SECONDS is passed and > return EINVAL in that case but no more. >=20 > (note that more NOTE_* are to be added later) When added, the checks should be changed. --poemUeGtc2GQvHuH Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTTBhqAAoJEJDCuSvBvK1BDdsP/iLkwQTacAH8tXDbQj1Ue73p PtMKzGyjcmQ5LW8I5yUwoHg+zaL9VYUApmkE/aJ4lKL1btlyAPVJiQwwzDz43aMv I7Nhs9rpeRLWI6KlpB/cpJ8sRkAEB/nlrNmbou5hNEmFRp/wRi8nelOwpfULFsVP pzGZvAU4NaRU05/KFxP+zg0mvplA5pieJDzwYV/3dsi9wXih8FQTrWGpOnSoREnh zKFIHhjEgDDVmyj+6sfP1WL90bCqiCzTEvUxAv5MyNIUAQzjiHaIT4+PTm0MKQC4 E3mE9n+CD+Qn9A6qy+YHQiKpn5SV45mE5Kg6yAYP615NJbWEiJw4FLePaWkyQG/J nFFREydsxDfEDWnL2wmrllLkMbCMwj09Rkl2gFG3ggcgKXTLrpFjm1KEE/1/LkbK IaylvOolgL9XvWiZI7vEBGCwJMb9TrWuyNZWJ9GoMDNDuS0Z8vFhGaQw00gFR0/Z cSpqht6qmVGcs7WOtMSMvJ3ihXPNFfPw3N2LZ2PHbxtOhi+MH8mBjnaSYy2v9HB9 1vyRNg+nUR2ZU3mbQEtBKuYU2Tkkv1KPV8aquR7mrobRwzly1NpXQIeTZlRsIHOw olH9DDJ0oqNZiC9WR9+Cru7PXiE3dZLk5FEvTBt1xqpChsldYHR2d36g+Na8vhLG pOqwVe0WARJr6yDOqRzT =LcdI -----END PGP SIGNATURE----- --poemUeGtc2GQvHuH--