From owner-svn-src-all@freebsd.org Fri Apr 17 03:38:18 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0F8B32CFFB1; Fri, 17 Apr 2020 03:38:18 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 493MHs6D3lz4TRm; Fri, 17 Apr 2020 03:38:17 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id C45A18D1B; Fri, 17 Apr 2020 03:38:17 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qk1-f181.google.com with SMTP id l25so1138245qkk.3; Thu, 16 Apr 2020 20:38:17 -0700 (PDT) X-Gm-Message-State: AGi0PubcGZLn+NAGUryWtb2kw5/5eHta/F5KqaiDYuHOyTRidzhP9ucv 1/RHtJQH91Y3LRept5moqKC78y3oeaTNrJ8MS4c= X-Google-Smtp-Source: APiQypIb8KIdkBLuYQkaMMmri/l4DM/jxps4vy/A8DujN3t2/APpaCxAmOciWqanE7NG+5zjfnnwsFjoHsEo3LjESYY= X-Received: by 2002:ae9:e805:: with SMTP id a5mr1211770qkg.493.1587094697174; Thu, 16 Apr 2020 20:38:17 -0700 (PDT) MIME-Version: 1.0 References: <202004170222.03H2MFso026451@repo.freebsd.org> <28f9262a36dc4b7d4437ef3860ac8e472f6df2ff.camel@freebsd.org> In-Reply-To: <28f9262a36dc4b7d4437ef3860ac8e472f6df2ff.camel@freebsd.org> From: Kyle Evans Date: Thu, 16 Apr 2020 22:38:06 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r360033 - head/tests/sys/kqueue/libkqueue To: Ian Lepore Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Apr 2020 03:38:18 -0000 On Thu, Apr 16, 2020 at 9:33 PM Ian Lepore wrote: > > On Fri, 2020-04-17 at 02:22 +0000, Kyle Evans wrote: > > Author: kevans > > Date: Fri Apr 17 02:22:15 2020 > > New Revision: 360033 > > URL: https://svnweb.freebsd.org/changeset/base/360033 > > > > Log: > > tests: kqueue: use a more precise timer for the NOTE_ABSTIME test > > > > Originally noticed while attempting to run the kqueue tests under > > qemu-user-static, this apparently just happens sometimes when running in a > > jail in general -- the timer will fire off "too early," but it's really just > > the result of imprecise measurements (noted by cem). > > > > Kicking this over to NOTE_USECONDS still tests the correct thing while > > allowing it to work more consistently; a basic sanity test reveals that we > > often end up coming in just less than 200 microseconds after the timer > > fired off. > > > > MFC after: 3 days > > > > Modified: > > head/tests/sys/kqueue/libkqueue/timer.c > > > > Modified: head/tests/sys/kqueue/libkqueue/timer.c > > ============================================================================== > > --- head/tests/sys/kqueue/libkqueue/timer.c Fri Apr 17 02:21:46 2020 (r360032) > > +++ head/tests/sys/kqueue/libkqueue/timer.c Fri Apr 17 02:22:15 2020 (r360033) > > @@ -216,17 +216,17 @@ test_abstime(void) > > { > > const char *test_id = "kevent(EVFILT_TIMER, EV_ONESHOT, NOTE_ABSTIME)"; > > struct kevent kev; > > - time_t start; > > - time_t stop; > > - const int timeout = 3; > > + long end, start, stop; > > + const int timeout_sec = 3; > > > > test_begin(test_id); > > > > test_no_kevents(); > > > > - start = time(NULL); > > + start = now(); > > + end = start + SEC_TO_US(timeout_sec); > > EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT, > > - NOTE_ABSTIME | NOTE_SECONDS, start + timeout, NULL); > > + NOTE_ABSTIME | NOTE_USECONDS, end, NULL); > > if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0) > > err(1, "%s", test_id); > > > > @@ -235,10 +235,10 @@ test_abstime(void) > > kev.data = 1; > > kev.fflags = 0; > > kevent_cmp(&kev, kevent_get(kqfd)); > > - stop = time(NULL); > > - if (stop < start + timeout) > > - err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)(start + timeout)); > > > > + stop = now(); > > + if (stop < end) > > + err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)end); > > /* Check if the event occurs again */ > > sleep(3); > > test_no_kevents(); > > Not caused by you, but this change made me notice: using 'long' to > hold the number of microseconds since the unix epoch will only work on > amd64 and arm64. Everything involved with that needs to use uint64_t > to work on all arches. > > -- Ian > Good point, I'll go fix that after arichardson's in-flight change near these tests lands. Thanks, Kyle Evans