load average calculation failing
Mark Geisert
mark@maxrnd.com
Sun May 8 07:01:22 GMT 2022
Mark Geisert wrote (on the main Cygwin mailing list):
> I've recently noticed that the 'xload' I routinely run shows zero load even with
> compute-bound processes running. This is on both Cygwin pre-3.4.0 as well as
> 3.3.4. A test program, shown below, indicates that getloadavg() is returning with
> 0 status, i.e. not an error but no elems
> of the passed-in array updated.
>
> Stepping with gdb through the test program seems weird within the
> loadavginfo::load_init method. Single-stepping at line loadavg.cc:68 goes to
> strace.h:52 and then to _sigbe ?!
>
> I had recently updated both Cygwin and Windows 10 to latest at the same time so I
> cannot say when the failure started. Last day or two at most.
>
> ..mark
>
> -------------------
> #define _GNU_SOURCE
> #include <stdio.h>
> #include <stdlib.h>
>
> int
> main (int argc, char **argv)
> {
> double loadavg[3];
>
> int res = getloadavg (loadavg, 3);
> if (res == -1)
> return 0xFF;
> if (res > 0)
> for (int i = 0; i < res; i++)
> printf ("%f.2 ", loadavg[i]);
>
> return res;
> }
I've debugged a bit further.. Within Cygwin's loadavg.cc:load_init(), the
PdhOpenQueryW() call returns successfully. The subsequent PdhAddEnglishCounterW()
call is unsuccessful. It returns status 0x800007D0 == PDH_CSTATUS_NO_MACHINE.
The code (at line 68 mentioned above) calls debug_printf() to conditionally
display the error, which is what leads to the strace.h and _sigbe; that's fine.
The weird PDH_CSTATUS_NO_MACHINE is the problem. I'll try running the example
from an elevated shell. Or rebooting the machine. After that it's consulting
some oracle TBD. :-(
..mark
More information about the Cygwin-developers
mailing list