feat: NPU metrics logger daemon#14
Open
Sam Freund (samfreund-qc) wants to merge 5 commits into
Open
Conversation
Signed-off-by: samfreund-qc <freund@qti.qualcomm.com>
ProtectSystem=strict sets up a mount namespace before ExecStartPre runs. That namespace setup requires ReadWritePaths to already exist, causing a 226/NAMESPACE failure on first install when /var/log/qcperf doesn't exist. Replace ExecStartPre=/bin/mkdir + ReadWritePaths= with LogsDirectory=qcperf. systemd creates LogsDirectory-managed paths before namespace setup. Signed-off-by: samfreund-qc <freund@qti.qualcomm.com>
Signed-off-by: samfreund-qc <freund@qti.qualcomm.com>
Signed-off-by: samfreund-qc <freund@qti.qualcomm.com>
- Move uint8_t cleanup declaration to top of copy_backend_info() to comply with C89-style variable declarations at function scope. - Rewrite main loop as while (0 != g_running) to avoid the always-true loop pattern prohibited by the Semgrep rules. Signed-off-by: samfreund-qc <freund@qti.qualcomm.com>
cec1184 to
d8683e5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
QcPerfNpuLogger, a standalone systemd-compatible daemon that uses the publicqcperf_*API to continuously sample all four NPU metrics and write a point-in-time snapshot to/var/log/qcperf/npu_metrics.logonce per second.What it does
The daemon connects to
QC_PERF_BACKEND_DSP_NPU, samples at 100 ms intervals, and fires a streaming callback every 1000 ms. Each callback atomically replaces the output file (write to.npu_metrics.tmp, thenrename(2)) so readers never observe a partial write. The most recent sample per metric within each streaming window is kept; earlier samples are discarded.Output format:
Files added
qcperf/npu_logger/src/qcperf_npu_logger.cmain, callbacks, helpers)qcperf/npu_logger/systemd/qcperf-npu-logger.serviceqcperf/npu_logger/CMakeLists.txt-DBUILD_NPU_LOGGER=ONBuild
cmake -S qcperf -B build-linux-aarch64-release \ -DTARGET_ARCH=linux-aarch64 \ -DCMAKE_BUILD_TYPE=Release \ -DProjectVersion="0.1.0.0" \ -DBACKENDS="CPU;NPU;DUMMY" \ -DBUILD_NPU_LOGGER=ON cmake --build build-linux-aarch64-releaseThe target is off by default. Enabling it without
NPUinBACKENDSemits a CMake warning and skips the build gracefully.Runtime requirement
/usr/lib/libcdsprpc.somust be present on the target device. If absent, the dynamic linker fails at process startup — this is a constraint of the underlying FastRPC transport, not something the daemon can work around.systemd unit highlights
ProtectSystem=strict+LogsDirectory=qcperf(creates/var/log/qcperfbefore the namespace is set up, required for first install)PrivateTmp=true,NoNewPrivileges=trueRestart=on-failurewith a 5 s back-offSyslogIdentifier=qcperf-npu-loggerTesting
Run on a Qualcomm Linux ARM64 device with
libcdsprpc.sopresent:Checklist
goto, no always-true loopsNULL == ptr)callocused instead ofmalloc; pointers set toNULLafterfreesnake_case/PascalCase/UPPER_CASEnaming conventions followedclang-format— not available on the development host; please run before merge:clang-format -i qcperf/npu_logger/src/qcperf_npu_logger.c