Closed duqiang closed 1 year ago
Thank you for pointing this out. It looks like there's more broken PVs than just those ones. For example:
>>> dbpr("my_ioc:CPU_CNT")
AMSG: ASG : DESC: Number of CPUs
DISA: 0 DISV: 1 NAME: my_ioc:CPU_CNT
NAMSG: RVAL: 0 SEVR: NO_ALARM STAT: NO_ALARM
SVAL: 0 TPRO: 0 VAL : 1
As you can see, it looks like devIocStats is not correctly picking up the number of CPUs on my system (I have 4). This number is used in a lot of calculations, so is probably a/the source of the issue.
Looking at the devIocStatsOSD.h file, it seems there is a defaults version but there is no override header file for Linux. This means the number of CPUs defaults to 1, and is never adjusted.
(We use the Linux distribution as that's how we set up the build in setup.py - the OS_CLASS
variable returns Linux
)
I'm tempted to say this is an issue in devIocStats, although I'd probably have to do more investigation to prove that.
I think something in the EPICS build system will pick up the posix
version too, which we are not currently pulling into the build.
This file would appear to give the right CPU count: https://github.com/epics-modules/iocStats/blob/fa12cb2172e3477debd1372f57e68d2ae21f7c1b/devIocStats/os/posix/devIocStatsOSD.h#L42-L43
I think the best thing to do would be to build devIocStats once standalone and look at the gcc command it generates for Linux, which files it picks up, and replicate that in setup.py
Here's the gcc line from devIocStats:
/usr/bin/gcc -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_X86_64_ -DUNIX -Dlinux -O3 -g -Wall -Werror-implicit-function-declaration -mtune=generic -m64 -fPIC -I. -I../O.Common -I. -I. -I../os/Linux -I../os/posix -I../os/default -I.. -I../../include/compiler/gcc -I../../include/os/Linux -I../../include -I/repos/epics/support/sncseq/include -I/repos/epics/epics-base/include/compiler/gcc -I/repos/epics/epics-base/include/os/Linux -I/repos/epics/epics-base/include -MM -MF osdCpuUtilization.d ../os/Linux/osdCpuUtilization.c
When enabling:SYS_CPU_LOAD and :IOC_CPU_LOAD are incorrect.
softioc.devIocStats
, the values ofTo reproduce, compose
ioc.py
based on tutorial:Result when running
ioc.py
:True cpu load is about 0.3 - 0.4%: