Skip to content

feat(workq): optional per-queue statistics (KRN-WQ-011, M2 leftover) - #44

Open
teo1747 wants to merge 4 commits into
mainfrom
feat/m2-workq-stats
Open

teo1747 wants to merge 4 commits into
mainfrom
feat/m2-workq-stats

Conversation

@teo1747

@teo1747 teo1747 commented Oct 31, 2026

Copy link
Copy Markdown
Member

Contains #42 and #43 as its base: merge them first, after which this diff shows only the statistics.

Completes KRN-WQ-011, whose trace records already existed (A52) but whose statistics did not.

  • CONFIG_EMB_WORKQ_STATS is off by default.
  • emb_workq_get_stats() fills emb_workq_stats_t:
    • the worst submit-to-start latency;
    • the longest handler and its function;
    • the items queued now and the most queued at once.
  • emb_workq_reset_stats() restarts the maxima; the pending maximum restarts from the items queued now.
  • Both are thread isr and O(1), with new API IDs 143 and 144 (registry regenerated).
  • Times are kernel-clock ticks. A submit while the handler runs starts the latency of the run it queues, and flush markers are not items. Each work item gains a submit timestamp when the option is on.
  • A65 records the contract.

Evidence

  • New conformance case workq_stats_record_depth_latency_and_longest_handler.
    • It runs on native-timeslice, which now also builds this option.
    • Also passed under QEMU Cortex-M4 with EMB_SET=EMB_WORKQ_STATS=y, where real-time slack applies.
  • Local runs, all passing: native gcc/clang/release/tiny/periodic/timeslice/timeslice-tickless, cm4-an386, rv32-virt and avr-uno.
  • Checks: generate --check, the fault/storage/toolchain/kconfig/evidence tests, check_bounds and check-banned are clean; the docs build has the 9 known shim warnings.

Docs

KRN-WQ-011, SPEC-006 §7, STATUS, CHANGELOG, the configuration guide and the tasks guide.

CONFIG_EMB_WORKQ_STATS (off by default) completes KRN-WQ-011.
emb_workq_get_stats() reports, per queue, the worst submit-to-start
latency, the longest handler with its function and the deepest backlog.
emb_workq_reset_stats() restarts the maxima. Both are thread and ISR
safe, O(1), with API IDs 143 and 144.

Times are kernel-clock ticks. Each work item gains a submit timestamp. A
resubmission while the handler runs starts the latency of the run it
queues, and flush markers are not counted.

native-timeslice now also builds the option and runs the new
conformance case, which was also checked under QEMU Cortex-M4 with the
option set. A65 records the contract.

Signed-off-by: teo1747 <motsoujunior17@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant