feat: Add PREEMPT_RT optimization resources and extensions for cyclictest(RT benchmarking)#32
feat: Add PREEMPT_RT optimization resources and extensions for cyclictest(RT benchmarking)#32DeewanS wants to merge 3 commits intoqualcomm:mainfrom
Conversation
Signed-off-by: Deewan Singh <deewsing@qti.qualcomm.com>
| // --------------------------- | ||
| // Basic I/O helpers | ||
| // --------------------------- | ||
| static int writeAttr(const std::string& path, const std::string& value) { |
There was a problem hiding this comment.
Can you check if the helper method provided in the file Helpers.h called "writeLineToFile" can work here, seems wasteful is each extension module has to specify its own versions of such common utils.
| if (!isLogEnabled()) return; | ||
| static bool opened = false; | ||
| if (!opened) { | ||
| openlog("URM-EXT-RT", LOG_PID | LOG_CONS, LOG_DAEMON); |
There was a problem hiding this comment.
This code will run in the context of urm daemon itself, which already has it's logging mechanisms set (maybe syslog, ftract). So no need to call openlog again
| return s.substr(b, e - b); | ||
| } | ||
|
|
||
| static std::string toLower(std::string s) { |
There was a problem hiding this comment.
Use common helper for this
Configs/SignalsConfig.yaml
Outdated
| - {ResCode: "0x00040004", ResInfo: "0x00000100", Values: [1]} | ||
| - {ResCode: "0x00040005", ResInfo: "0x00000200", Values: [1]} | ||
| - {ResCode: "0x00800003", Values: [0]} | ||
| Timeout: -1 |
There was a problem hiding this comment.
As a convention, we try to specify the "Resources" list at the end, can you move the Timeout field to in b/w Permissions and Resources
| }; | ||
|
|
||
| // Hostname-based policy | ||
| static const std::map<std::string, MaskEntry> kHostPolicyMap = { |
There was a problem hiding this comment.
this is not scalable, lets discuss this in a meeting
…signal Signed-off-by: Deewan Singh <deewsing@qti.qualcomm.com>
…nity and CPU WQ This adds the registration and defination for irq affinity & cpu workqueue applier and tear callbacks. Update the cpufreq governor callbacks. Add logging support. Signed-off-by: Deewan Singh <deewsing@qti.qualcomm.com>
df9921c to
e0f6bee
Compare
This PR introduces new URM resources and PREEMPT_RT‑aware extensions that optimize system behavior during Real‑Time (RT) benchmarking workloads such as cyclictest. The newly added resources enable dynamic tuning of CPU frequency governance, IRQ affinity, and Workqueue affinity to minimize latency and jitter on PREEMPT_RT‑enabled kernels.
Key Changes
New Resources (ResourceConfigs.yaml)
RES_CPU_FREQ_GOV (0x8001)
Forces all CPU policies to use the performance governor during RT benchmarking.
RES_IRQ_AFFINITY (0x8002)
Applies platform‑specific IRQ affinity masks to isolate interrupts.
RES_CPU_WQ_AFFINITY (0x8003)
Updates CPU masks for Workqueues to reduce cross‑CPU noise.
Signal Configuration Updates (SignalsConfig.yaml)
Updated signal‑to‑resource mappings so these new resources activate automatically when cyclictest is triggered.
Removed outdated or unused resource entries and normalized the configuration structure.
INF(-1) Timeout added.
Extension Enhancements (PreemptRtExtn.cpp)
Applier & Tear Callbacks
Implemented apply and restore callbacks for all new resources.
Backups original values (governor, smp_affinity, cpumask) and restores them after the session completes.
Ensures no persistent system changes after cyclictest execution.
PREEMPT_RT Detection
Added isPreemptRtActive() to detect PREEMPT_RT via:
/sys/kernel/realtime
Kernel version flags
cyclictest post‑process callback is registered only when PREEMPT_RT is active.
Device‑Specific Policy Handling
Added platform maps:
kHostPolicyMap
kMachinePolicyMap
Automatically resolves correct IRQ and WQ hex masks for supported platforms:
QCS6490
QCS8275
QCS9075
QCS9100
RB3 Gen2/Core Kit
And more.
Includes a default fallback mask when a platform entry isn’t present.
Added conditional logging controlled via environment variable:
URM_EXT_RT=1
Logs all writes, errors, and resolved mask details to syslog for debugging.
Technical Details:
This PR modifies or interacts with:
/sys/devices/system/cpu/cpufreq/policy*/scaling_governor
/proc/irq/*/smp_affinity
/sys/devices/virtual/workqueue/ * /cpumask
Validation
Tested on iq-9075-evk with PREEMPT_RT kernel.
Verified:
Governor switches to performance and reverts correctly.
IRQ affinity masks apply and restore reliably.
WQ CPU masks update and restore successfully.
cyclictest triggers correct resource handling.
Confirmed logs appear when URM_EXT_RT=1.