Date: Sat, 24 Jul 2021 20:21:55 -0500 From: Matthew Grooms <mgrooms@shrew.net> To: freebsd-arm@freebsd.org Subject: Re: aarch64 and kqueue timer events Message-ID: <f5d3a817-08a4-4be7-8e4b-5f07b1fb68cd@shrew.net> In-Reply-To: <03ff40c7-b755-8421-713c-90aa4d8535fe@shrew.net>
index | next in thread | previous in thread | raw e-mail
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 <err.h>
> #include <time.h>
> #include <stdio.h>
> #include <unistd.h>
> #include <sys/event.h>
>
> 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 in somewhere on the
> arm side.
Sorry. Forgot to mention the OS version. It's 13 stable on the aarch64
side ...
FreeBSD generic 13.0-STABLE FreeBSD 13.0-STABLE #8
stable/13-n246015-ade8b810b02-dirty: Tue Jun 15 21:04:38 CDT 2021
-Matthew
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f5d3a817-08a4-4be7-8e4b-5f07b1fb68cd>
