#975032 watchdog: Incorrect pagesize used to calculate allocatable memory on arm

Package:
watchdog
Source:
watchdog
Description:
system health checker and software/hardware watchdog handler
Submitter:
Adam Cecile
Date:
2020-11-18 08:33:06 UTC
Severity:
important
Tags:
#975032#5
Date:
2020-11-18 08:31:59 UTC
From:
To:
Dear Maintainer,

I'm using watchdog daemon on multiple type of hardware and it seems there is a
bug on arm64.
Command "getconf PAGESIZE" returns 4096 si I sized allocatable-memory options
using this value.
However the system immediately rebooted because "cannot allocate 6637223936
bytes (errno = 12 = 'Cannot allocate memory')".

Well, the problem is with 4096 bytes pages, this value in bytes is absolutely
wrong. Log entry when starting the service actually shows that the used
pagesize is 65536: "memory: minimum pages = 0 free, 101276 allocatable (65536
byte pages)".

So I tried to understand why such thing occurred:
The log entry with incorrect pagesize is here:
https://sourceforge.net/p/watchdog/code/ci/master/tree/src/watchdog.c#l253
And the variable containing the pagesize here:
https://sourceforge.net/p/watchdog/code/ci/master/tree/src/watchdog.c#l26

My understanding is that this is incorrect. While it seems to work on amd64 it
does not on arm64, because I suspect arm64 build machine has different settings
that my Jetsons systems.
I'm pretty sure this is not correct, pagesize should be detected at runtime,
not at buildtime.

And I actually found a proof for that:
https://reviews.llvm.org/file/data/czbtafe5ozyi25sxhbeq/PHID-FILE-
qpahm22gtfydywupbps5/file

It seems indeed that using EXEC_PAGESIZE is marked as unreliable on non x86
architectures and uses instead a call to sysconf, which is equivalent to the
getconf command I used to check the actual pagesize on my Jetson boards.

Thanks in advance,

Regards, Adam.