Re: [PATCH v2] selftests: timers: Partially revert "Remove local NSEC_PER_SEC and USEC_PER_SEC defines"

From: Wake Liu

Date: Tue Jun 09 2026 - 23:16:14 EST


Hi John,

Thanks for the review and Ack!


On Wed, Jun 10, 2026 at 10:00 AM John Stultz <jstultz@xxxxxxxxxx> wrote:
>
> On Tue, Jun 9, 2026 at 6:47 PM Wake Liu <wakel@xxxxxxxxxx> wrote:
> >
> > This partially reverts commit 80fa614e2fbc ("selftests: timers: Remove
> > local NSEC_PER_SEC and USEC_PER_SEC defines").
> >
> > The original commit removed local definitions of NSEC_PER_SEC and
> > USEC_PER_SEC in favor of including <include/vdso/time64.h>. However,
> > NSEC_PER_SEC in vdso/time64.h is defined as 1000000000L, which is
> > 32-bit on 32-bit architectures. This causes integer overflow warnings
> > in several timer tests when doing arithmetic like NSEC_PER_SEC * 10 on
> > 32-bit systems.
> >
> > To fix this, restore the local definitions of NSEC_PER_SEC and
> > USEC_PER_SEC in the test files, but use "LL" suffix consistently
> > (1000000000LL and 1000000LL) to ensure 64-bit arithmetic and avoid
> > overflows.
> >
> > We keep the cleanup from the original commit that renamed plural
> > definitions (NSECS_PER_SEC/USECS_PER_SEC) to singular ones in
> > posix_timers.c, but we now define them locally there as well.
> > This also removes the dependency of the selftests on the internal
> > kernel header <include/vdso/time64.h>.
> >
> > Signed-off-by: Wake Liu <wakel@xxxxxxxxxx>
>
> This looks ok to me. Thanks for putting this together!
>
> Acked-by: John Stultz <jstultz@xxxxxxxxxx>



--
Best Regards,
Wake Liu