Commit df2283c5 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

perf/pm: Fix reading check



Since we use precision with bc to calculate the reading, the actual
value may include decimal point (".") in its string. This breaks
the arithmetic check. Replace it with a string check to see if the
value we got is indeed negative.

Change-Id: I2b24c661e4201e33179fd44591af0c0d42d7ac44
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18437


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent cc4498ac
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ get_cpu_socket_reading() {

		# Convert to Watts - use bc since $interval can be an actual float
		reading=$(calc "(${socket_uj[-1]} - ${socket_uj[-2]}) / 1000000 / $interval")
		if ((reading < 0)); then
		if [[ $reading == "-"* ]]; then
			# Somehow this may happen, probably when the counter wraps over. Consider
			# this as a faulty reading and don't include it since it may impact overall
			# avg.