From owner-freebsd-hackers@FreeBSD.ORG Sat Oct 4 16:02:33 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 12FD0CE7; Sat, 4 Oct 2014 16:02:33 +0000 (UTC) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (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 D8B2A3BA; Sat, 4 Oct 2014 16:02:32 +0000 (UTC) Received: from [73.34.117.227] (helo=ilsoft.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1XaRmr-0009fx-Jh; Sat, 04 Oct 2014 16:02:25 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by ilsoft.org (8.14.9/8.14.9) with ESMTP id s94G2O2H024120; Sat, 4 Oct 2014 10:02:24 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 73.34.117.227 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX18RO1IMZKw53K0h4Fh6wy51 X-Authentication-Warning: paranoia.hippie.lan: Host revolution.hippie.lan [172.22.42.240] claimed to be [172.22.42.240] Subject: Re: freebsd 10 kqueue timer regression From: Ian Lepore To: Paul Albrecht In-Reply-To: <8587D819-AA2F-4387-A4E9-523014384672@glccom.com> References: <8ABC0977-FB8F-45E7-ACCC-BFA92EE22E1C@glccom.com> <8587D819-AA2F-4387-A4E9-523014384672@glccom.com> Content-Type: text/plain; charset="iso-8859-13" Date: Sat, 04 Oct 2014 10:02:23 -0600 Message-ID: <1412438543.12052.107.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by ilsoft.org id s94G2O2H024120 Cc: "freebsd-hackers@freebsd.org" , Adrian Chadd X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Oct 2014 16:02:33 -0000 On Thu, 2014-10-02 at 13:13 -0500, Paul Albrecht wrote: > On Oct 2, 2014, at 12:18 PM, Adrian Chadd wrote: >=20 > > On 2 October 2014 08:07, Paul Albrecht wrote: > >>=20 > >> Hi, > >>=20 > >> What=FFs up with freebsd 10? I=FFm testing some code that uses the k= queue timer for timing and it doesn=FFt work because the precision of the= timer is off. > >=20 > > Can you provide a test case for it? >=20 > Here=FFs the code: >=20 > #include > #include > #include > #include > #include > #include > #include > #include >=20 > int > main(void) > { > int i,msec; > int kq,nev; > struct kevent inqueue; > struct kevent outqueue; > struct timeval start,end; >=20 > if ((kq =3D kqueue()) =3D=3D -1) { > fprintf(stderr, "kqueue error!? errno =3D %s", strerror= (errno)); > exit(EXIT_FAILURE); > } > EV_SET(&inqueue, 1, EVFILT_TIMER, EV_ADD | EV_ENABLE, 0, 20, 0)= ; >=20 > gettimeofday(&start, 0); > for (i =3D 0; i < 50; i++) { > if ((nev =3D kevent(kq, &inqueue, 1, &outqueue, 1, NULL= )) =3D=3D -1) { > fprintf(stderr, "kevent error!? errno =3D %s", = strerror(errno)); > exit(EXIT_FAILURE); > } else if (outqueue.flags & EV_ERROR) { > fprintf(stderr, "EV_ERROR: %s\n", strerror(outq= ueue.data)); > exit(EXIT_FAILURE); > } > } > gettimeofday(&end, 0); >=20 > msec =3D ((end.tv_sec - start.tv_sec) * 1000) + (((1000000 + en= d.tv_usec - start.tv_usec) / 1000) - 1000); >=20 > printf("msec =3D %d\n", msec); >=20 > close(kq); > return EXIT_SUCCESS; > } >=20 > When I run it on my system I get these results: >=20 > ./a.out > msec =3D 1072 > ./a.out > msec =3D 1071 > ./a.out > msec =3D 1071 >=20 > Which is over about 3.5 times the wait time per second. >=20 >=20 > >=20 > > I just chased down one of those recently; maybe it's the same thing > > (callout() API changes.) > >=20 > >=20 FYI, I just committed the fix to -current as r272528. I'll MFC it to 10-stable in 3 days, and then we'll see if it can get into the 10.1 release cycle. -- Ian