summaryrefslogtreecommitdiff
path: root/libs/cputimeinstate
diff options
context:
space:
mode:
author Connor O'Brien <connoro@google.com> 2020-08-14 13:13:37 -0700
committer Connor O'Brien <connoro@google.com> 2020-08-14 16:55:18 -0700
commitb83af347fcba3b12e27ce441c06f817d09740e0e (patch)
tree2959176956589ffab0930b67f81531d50eccaee4 /libs/cputimeinstate
parentea8305102a6cdd1b2cf89b1f020391bd19f71244 (diff)
libtimeinstate: improve error handling in single-UID functions
getUidCpuFreqTimes and getUidConcurrentTimes return all zeros if the requested UID is not present in the BPF maps on the assumption that that UID has zero runtime, but this could also indicate that tracking never started (in which case the map will be empty). Add a check to distinguish these cases and return an error when tracking is not working. Test: load maps (but not progs) from time_in_state.o, enable track_cpu_times_by_proc_state, run BstatsCpuTimesValidationTest Bug: 163593704 Signed-off-by: Connor O'Brien <connoro@google.com> Change-Id: I1d889cd02e67263c0b031be74f0b963ed80961b0
Diffstat (limited to 'libs/cputimeinstate')
-rw-r--r--libs/cputimeinstate/cputimeinstate.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libs/cputimeinstate/cputimeinstate.cpp b/libs/cputimeinstate/cputimeinstate.cpp
index b2ebf5d729..e56c79989d 100644
--- a/libs/cputimeinstate/cputimeinstate.cpp
+++ b/libs/cputimeinstate/cputimeinstate.cpp
@@ -251,7 +251,7 @@ std::optional<std::vector<std::vector<uint64_t>>> getUidCpuFreqTimes(uint32_t ui
for (uint32_t i = 0; i <= (maxFreqCount - 1) / FREQS_PER_ENTRY; ++i) {
key.bucket = i;
if (findMapEntry(gTisMapFd, &key, vals.data())) {
- if (errno != ENOENT) return {};
+ if (errno != ENOENT || getFirstMapKey(gTisMapFd, &key)) return {};
continue;
}
@@ -362,7 +362,7 @@ std::optional<concurrent_time_t> getUidConcurrentTimes(uint32_t uid, bool retry)
time_key_t key = {.uid = uid};
for (key.bucket = 0; key.bucket <= (gNCpus - 1) / CPUS_PER_ENTRY; ++key.bucket) {
if (findMapEntry(gConcurrentMapFd, &key, vals.data())) {
- if (errno != ENOENT) return {};
+ if (errno != ENOENT || getFirstMapKey(gConcurrentMapFd, &key)) return {};
continue;
}
auto offset = key.bucket * CPUS_PER_ENTRY;