From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 14 19:24:02 2014 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7D68B1E0 for ; Mon, 14 Apr 2014 19:24:02 +0000 (UTC) Received: from mail-wi0-x22e.google.com (mail-wi0-x22e.google.com [IPv6:2a00:1450:400c:c05::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0BE9A1147 for ; Mon, 14 Apr 2014 19:24:01 +0000 (UTC) Received: by mail-wi0-f174.google.com with SMTP id d1so4583688wiv.7 for ; Mon, 14 Apr 2014 12:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=MKW341N4cNxkx5goxVNNkFm5twIbKKqlR0hEIbP6zbc=; b=WZiQDSPSP7NUBCEmWnw/RKFQNCy0TQw5Lp/GCOgAQy0pBys46Lbvx/uI3taxNAfa8M LNYV93P+a0wY9zrj1LvSSiziNcZi6zPs4T8Zq1GvSmmJ7mOIVJZrouHoDfGUdYnifxQ7 cAsdUBP2+pcg1sQgwyjLBUL8AWlRj0zUGFIMztFUrsFFlVTmZRAmpMuppFu8ynvvSbcU ui3xs6ZZpaJUETlnPTCYmaymRI3Qv3rcgvTEMcu5YSoUBrC/PnbpB/4w/MdhGlBHxYxj Pz6BLEO1HO6M9nTMKB6+1XOy923ud86C6Q1Nss+/Reh7rvYp+TdLKsvTMbAlPHl/Newz vNag== X-Received: by 10.194.174.42 with SMTP id bp10mr2974886wjc.57.1397503439517; Mon, 14 Apr 2014 12:23:59 -0700 (PDT) Received: from ivaldir.etoilebsd.net ([2001:41d0:8:db4c::1]) by mx.google.com with ESMTPSA id rx9sm26286612wjb.20.2014.04.14.12.23.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Apr 2014 12:23:58 -0700 (PDT) Sender: Baptiste Daroussin Date: Mon, 14 Apr 2014 21:23:56 +0200 From: Baptiste Daroussin To: Konstantin Belousov Subject: Re: [CFR] Kevent timer improvements Message-ID: <20140414192356.GB37560@ivaldir.etoilebsd.net> 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> <20140414171834.GJ4016@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cmJC7u66zC7hs+87" Content-Disposition: inline In-Reply-To: <20140414171834.GJ4016@kib.kiev.ua> User-Agent: Mutt/1.5.23 (2014-03-12) 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 19:24:02 -0000 --cmJC7u66zC7hs+87 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 14, 2014 at 08:18:34PM +0300, Konstantin Belousov wrote: > 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 wrot= e: > > > > > > I have splitted my patch in multiple parts, let start with the = first 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 = else 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 im= precise > > > > > callout scheduling. > > > > >=20 > > > > While I do agree this might be useful I do not have time to work on= that right > > > > now so I just removed the comment which wasn't really accurate anyw= ay. > > > >=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, righ= t ? > >=20 > > I can check that only one flags is passed and no invalid flagrs are sup= plied 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. >=20 > See the RFTSIGNUM/RFTSIGFLAGS/RFTSIGMASK in unistd.h or > VM_ALLOC_COUNT/VM_ALLOC_COUNT_SHIFT for the idiomatic way to handle > similar needs. I'll do thanks for tips! >=20 > >=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. ok I'll come back with a better patch. regards, Bapt --cmJC7u66zC7hs+87 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlNMNcwACgkQ8kTtMUmk6ExLdgCgkKJGiy8YROs6SqBJkguSJY/e 0HwAnjM+WallTnWWchv3WOhfu2IWdI5H =lMPZ -----END PGP SIGNATURE----- --cmJC7u66zC7hs+87--