From nobody Wed Jul 28 01:43:50 2021 X-Original-To: freebsd-stable@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 21E3C12BFC72 for ; Wed, 28 Jul 2021 01:44:00 +0000 (UTC) (envelope-from mgrooms@shrew.net) Received: from mx2.shrew.net (mx2.shrew.net [38.97.5.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4GZGfR0nHBz3RK8 for ; Wed, 28 Jul 2021 01:43:59 +0000 (UTC) (envelope-from mgrooms@shrew.net) Received: from mail.shrew.net (mail.shrew.prv [10.24.10.20]) by mx2.shrew.net (8.15.2/8.15.2) with ESMTP id 16S1hqkI074875 for ; Tue, 27 Jul 2021 20:43:52 -0500 (CDT) (envelope-from mgrooms@shrew.net) Received: from [10.22.200.30] (unknown [136.49.68.36]) by mail.shrew.net (Postfix) with ESMTPSA id 7F04C19B0B9 for ; Tue, 27 Jul 2021 20:43:47 -0500 (CDT) Subject: Re: aarch64 and kqueue timer events To: freebsd-stable@freebsd.org References: <03ff40c7-b755-8421-713c-90aa4d8535fe@shrew.net> From: Matthew Grooms Message-ID: Date: Tue, 27 Jul 2021 20:43:50 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 List-Id: Production branch of FreeBSD source code List-Archive: https://lists.freebsd.org/archives/freebsd-stable List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-stable@freebsd.org X-BeenThere: freebsd-stable@freebsd.org MIME-Version: 1.0 In-Reply-To: <03ff40c7-b755-8421-713c-90aa4d8535fe@shrew.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx2.shrew.net [10.24.10.11]); Tue, 27 Jul 2021 20:43:52 -0500 (CDT) X-Rspamd-Queue-Id: 4GZGfR0nHBz3RK8 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of mgrooms@shrew.net designates 38.97.5.132 as permitted sender) smtp.mailfrom=mgrooms@shrew.net X-Spamd-Result: default: False [0.70 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-stable@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[3]; DMARC_NA(0.00)[shrew.net]; NEURAL_SPAM_SHORT(1.00)[0.999]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:174, ipnet:38.0.0.0/8, country:US]; RCVD_TLS_LAST(0.00)[]; MAILMAN_DEST(0.00)[freebsd-stable] X-ThisMailContainsUnwantedMimeParts: N On 7/24/2021 8:18 PM, Matthew Grooms wrote: > Hi all, > > I'm seeing some strange behavior with kqueue timers on my aarch64 > host. Here is a simple test program that I've compiled on both amd64 > and aarch64. It just sets up a simple kqueue timer with a loop that > waits for the event to fire every 3 seconds ... > > #include > #include > #include > #include > #include > > int main( int argc, char *argv[] ) > { >     int kq = kqueue(); >     if( kq < 0 ) >         err( 1, "failed to obtain kqueue handle" ); > >     struct kevent ke; >     EV_SET( &ke, 1, EVFILT_TIMER, EV_ADD | EV_ENABLE, 0, 3000, 0 ); >     if( kevent( kq, &ke, 1, NULL, 0, NULL ) < 0 ) >         err( 1, "failed to add kevent timer filter" ); > >     printf( "started at %i\n", (int)time(NULL) ); > >     while( true ) >     { >         int r = kevent( kq, NULL, 0, &ke, 1, NULL ); >         if( r < 0 ) >             err( 1, "failed to read kevent list" ); > >         printf( "timer fired %i times at %i\n", r, (int)time(NULL) ); >     } > >     return 0; > } > > When I compile and run the code on an amd64 host, everything works as > expected. The event timer expires once every 3 seconds ... > > mgrooms@amd64:~/devel$ cc test.cpp -o test && ./test > started at 1627175311 > timer fired 1 times at 1627175314 > timer fired 1 times at 1627175317 > timer fired 1 times at 1627175320 > > However, when I compile and run the same code on an aarch64 host ( > rpi4b ), something very different happens. The event timer expires > after 3 seconds the first time. But each subsequent expiration is for > exactly twice the defined interval, 6 seconds ... > > mgrooms@aarch64:~/devel$ cc test.cpp -o test && ./test > started at 1625789207 > timer fired 1 times at 1625789210 > timer fired 1 times at 1625789216 > timer fired 1 times at 1625789222 > > Any idea what's going on here? Seems like a bug somewhere on the arm > side. > > Thanks in advance, > Hi Everyone, Sorry for the cross post. I started by asking this question in freebsd-arm but didn't get a response. I figured, since aarch64 is Tier1 now, asking wrt stable is fair game. Another user ( José Pérez ) confirmed that this issue was also present on current but my testing was on 13 ... FreeBSD generic 13.0-STABLE FreeBSD 13.0-STABLE #8 stable/13-n246015-ade8b810b02-dirty: Tue Jun 15 21:04:38 CDT 202 Any help would be greatly appreciated. Thanks in advance, -Matthew