docs: resolve IMPROVEMENT-PLAN, update MASTER+RAPL plans, add RAPL energy reader

IMPROVEMENT-PLAN: marked RESOLVED (38/38 items done). Now historical record.

IMPLEMENTATION-MASTER-PLAN: removed quality gap references, added status
tables for active vs resolved subsystem plans.

RAPL-IMPLEMENTATION-PLAN: P0 blocker resolved — MSR scheme exists at
src/scheme/sys/msr.rs. Proceed to Phase 1.

redbear-power/sensor.rs: added RAPL energy register reader:
- MSR_PKG_ENERGY_STATUS (0x611) — Package domain
- MSR_PP0_ENERGY_STATUS (0x639) — Core domain
- MSR_PP1_ENERGY_STATUS (0x641) — Graphics domain
- MSR_DRAM_ENERGY_STATUS (0x619) — DRAM domain
- read_rapl_energy(), read_rapl_energy_unit(), read_rapl_energy_uj()
- RaplDomain enum (Package/Core/Graphics/Dram)
- Energy unit conversion: MSR_RAPL_POWER_UNIT (0x606) ESU bits
Cross-referenced with Linux 7.1 arch/x86/events/intel/rapl.c.
This commit is contained in:
2026-07-09 01:02:00 +03:00
parent 5c94daf4b2
commit d85702a3ca
4 changed files with 91 additions and 38 deletions
+28 -14
View File
@@ -1,23 +1,37 @@
# Red Bear OS — Master Implementation Plan
**Date**: 2026-07-07
**Status**: Authoritative — current state after USB/Wi-Fi/Bluetooth quality audits
**Date**: 2026-07-08
**Status**: Authoritative — IMPROVEMENT-PLAN resolved (38/38), Wi-Fi subsystem complete, kernel/relibc enhanced
**Source of truth**: Linux kernel 7.1 (`local/reference/linux-7.1/`)
This plan is the **master execution document** covering quality gaps found during the 2026-07-07 quality audits. It delegates subsystem authority to specialized plans:
Quality audit remediation (2026-07-07 through 2026-07-08) is **complete**. The IMPROVEMENT-PLAN.md
is now a historical record. Forward-looking work is in the subsystem plans below.
| Plan | Subsystem | Relationship |
|------|-----------|-------------|
| `ACPI-IMPROVEMENT-PLAN.md` | ACPI sleep, thermal, EC, power | **Authoritative** for ACPI |
| `IRQ-AND-LOWLEVEL-CONTROLLERS-ENHANCEMENT-PLAN.md` | PCI IRQ, MSI-X, IOMMU, controllers | **Authoritative** for IRQ/PCI |
| `USB-IMPLEMENTATION-PLAN.md` | xHCI, EHCI, device lifecycle | **Authoritative** for USB features |
| `DRM-MODERNIZATION-EXECUTION-PLAN.md` | GPU/DRM, KMS, Mesa | **Authoritative** for GPU |
| `BLUETOOTH-IMPLEMENTATION-PLAN.md` | BT host/controller | **Authoritative** for BT |
| `WIFI-IMPLEMENTATION-PLAN.md` | Wi-Fi control plane | **Authoritative** for Wi-Fi |
| `CONSOLE-TO-KDE-DESKTOP-PLAN.md` | Desktop/KDE path | **Authoritative** for desktop |
| `IMPROVEMENT-PLAN.md` | **Current quality gaps** | **Authoritative** for code quality |
Subsystem plans with active gaps:
This master plan covers: storage, network, audio, input drivers, cross-cutting quality, CPU/power, virtio, and kernel substrate. The **IMPROVEMENT-PLAN.md** has detailed quality gap remediation tasks for USB, Wi-Fi, and Bluetooth.
| Plan | Subsystem | Status |
|------|-----------|--------|
| `ACPI-IMPROVEMENT-PLAN.md` | ACPI sleep, thermal, EC, power | Active: GPE/wake, EC queries |
| `IRQ-AND-LOWLEVEL-CONTROLLERS-ENHANCEMENT-PLAN.md` | PCI IRQ, MSI-X, IOMMU | Active |
| `USB-IMPLEMENTATION-PLAN.md` | xHCI, EHCI, device lifecycle | Mostly done; feature gaps remain |
| `DRM-MODERNIZATION-EXECUTION-PLAN.md` | GPU/DRM, KMS, Mesa | Active: Intel GPU display init |
| `BLUETOOTH-IMPLEMENTATION-PLAN.md` | BT host/controller | Active: stub backend |
| `WIFI-IMPLEMENTATION-PLAN.md` | Wi-Fi control plane | Mostly done: iwlwifi driver complete |
| `NETWORKING-IMPROVEMENT-PLAN.md` | TCP/IP, netstack, drivers | Active: multi-NIC, IPv6, firewall |
| `CONSOLE-TO-KDE-DESKTOP-PLAN.md` | Desktop/KDE path | Active: Phase 1 runtime substrate |
| `RAPL-IMPLEMENTATION-PLAN.md` | CPU power monitoring | Active: MSR scheme exists |
| `SLEEP-IMPLEMENTATION-PLAN.md` | Sleep/suspend | Active |
| `RELIBC-IPC-ASSESSMENT-AND-IMPROVEMENT-PLAN.md` | relibc IPC | Active |
Subsystem plans resolved/no longer active:
| Plan | Status |
|------|--------|
| `IMPROVEMENT-PLAN.md` | **RESOLVED** — all 38 quality gaps verified/fixed |
| `KERNEL-IPC-CREDENTIAL-PLAN.md` | Resolved |
| `SYSCALL-MIGRATION-PLAN.md` | Resolved |
| `WAYLAND-IMPLEMENTATION-PLAN.md` | Resolved |
| `WIFI-IMPLEMENTATION-PLAN.md` | Resolved (iwlwifi driver complete) |
---
+19 -3
View File
@@ -1,7 +1,23 @@
# Red Bear OS — Current Improvement Plan
# Red Bear OS — Current Improvement Plan (RESOLVED)
**Date**: 2026-07-08
**Status**: Authoritative — P0-P1 complete (16/16), P2 8/8 (100%), P3 5/5 (100%), P4+ 9/9 (100%). All audit items verified or implemented. Document is now a historical record of the 2026-07-07 quality audit and subsequent remediation (2026-07-07 through 2026-07-08).
**Date**: 2026-07-08 (resolved)
**Status**: **COMPLETE** — P0-P4+ all verified/implemented (38/38 = 100%)
**Source of truth**: Linux kernel 7.1 (`local/reference/linux-7.1/`)
This document is a **historical record** of the 2026-07-07 quality audit of USB, Wi-Fi,
and Bluetooth subsystems, and the subsequent remediation (2026-07-07 through 2026-07-08).
All items have been verified or implemented. No open work remains from this audit.
Remediation summary:
- **USB**: 6 P0+P1+P2 items: EDTLA fix, PortId Option return, protocol_speeds bound,
remove #![allow(warnings)], DMA pool documentation, 12+ quirks enforced, 20+ unit tests
- **Wi-Fi**: 9 P4+ items: Mini-MVM, TLV parser, Minstrel rate scaling, 6GHz scan,
power management, AMPDU, thermal CT-KILL, WoWLAN, EHT rates
- **Drivers**: uhcid bulk/interrupt transfers, NVMe multi-queue, HDA verb constants
- **Kernel**: 6 procfs files (stat/status/maps/statm/limits/io), rlimits, I/O accounting
- **relibc**: 15+ stubs replaced with real POSIX implementations
**See `IMPLEMENTATION-MASTER-PLAN.md` for forward-looking work.**
**Source of truth**: Linux kernel 7.1 (`local/reference/linux-7.1/`)
This plan is derived from three fresh quality audits conducted on 2026-07-07,
+7 -21
View File
@@ -4,29 +4,15 @@
**Status:** Draft — awaiting review
**Linux Reference:** `local/reference/linux-7.1/drivers/powercap/`
## P0 Blocker: Kernel MSR Scheme Does Not Exist
## P0 Blocker: Kernel MSR Scheme — RESOLVED (2026-07-08) ✅
**The `/scheme/sys/msr/{cpu}/0x{msr_hex}` path used by `redbear-power` and
`cpufreqd` is NOT implemented in the kernel.** The kernel's `sys:` scheme handler
has modules for `cpu`, `exe`, `irq`, `block`, `syscall`, `context`, `uname`,
`fdstat`, `iostat`, `log`, `stat` — but NO `msr` module. The kernel uses
`rdmsr`/`wrmsr` internally (via the x86 crate) but never exposes MSRs to userspace.
**The `/scheme/sys/msr/{cpu}/0x{msr_hex}` path IS implemented in the kernel.**
The kernel's `sys:` scheme handler has an `msr` module at
`src/scheme/sys/msr.rs` with full read/write support including
cross-CPU IPI for remote MSR access and mailbox-based synchronization.
Verified 2026-07-08.
This is the single blocking gap for ALL RAPL work. Without it:
- `read_msr(0x611)` returns `None` on bare-metal Redox
- `redbear-power` can only read RAPL on Linux hosts via sysfs or `/dev/cpu/*/msr`
- `cpufreqd` cannot write `IA32_PERF_CTL` on Redox bare metal
- `thermald` cannot read thermal status MSRs
**Resolution options (pick one before Phase 1):**
1. **Kernel `sys:msr` handler** — Add `src/scheme/sys/msr.rs` to kernel, expose as `/scheme/sys/msr/{cpu}/0x{msr_hex}`. Requires `CAP_SYS_MSR`.
2. **Userspace `msrd` daemon** — Register `scheme:msr` via `redox-scheme`. More portable, easier to iterate, no kernel rebuild.
3. **Linux-compatible `/dev/cpu/*/msr` device** — Matches what `thermald` already uses. Requires VFS-level char device emulation.
**Recommendation:** Option 2 (userspace daemon). It's the fastest path,
doesn't require kernel changes, and can use `iopl(3)` + `inl`/`outl` for
x86 port-based MSR access, or the `x86` crate's `rdmsr` if ring0 access
is available through a capability scheme.
**Status**: MSR access from userspace works. Proceed to Phase 1.
## Executive Summary
@@ -127,6 +127,43 @@ fn read_first_cpu_temp_msr() -> Option<f64> {
None
}
// ── RAPL (Running Average Power Limit) energy registers ──
// Cross-referenced with Linux 7.1 arch/x86/events/intel/rapl.c
const MSR_PKG_ENERGY_STATUS: u32 = 0x611;
const MSR_PP0_ENERGY_STATUS: u32 = 0x639;
const MSR_PP1_ENERGY_STATUS: u32 = 0x641;
const MSR_DRAM_ENERGY_STATUS: u32 = 0x619;
const MSR_RAPL_POWER_UNIT: u32 = 0x606;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RaplDomain { Package, Core, Graphics, Dram }
pub fn read_rapl_energy(cpu: u32, domain: RaplDomain) -> Option<u64> {
let msr = match domain {
RaplDomain::Package => MSR_PKG_ENERGY_STATUS,
RaplDomain::Core => MSR_PP0_ENERGY_STATUS,
RaplDomain::Graphics => MSR_PP1_ENERGY_STATUS,
RaplDomain::Dram => MSR_DRAM_ENERGY_STATUS,
};
let raw = read_msr(cpu, msr)?;
if raw == 0 { return None; }
Some(raw as u32 as u64)
}
pub fn read_rapl_energy_unit(cpu: u32) -> Option<f64> {
let raw = read_msr(cpu, MSR_RAPL_POWER_UNIT)?;
let esu = ((raw >> 8) & 0x1F) as u32;
if esu == 0 { return None; }
Some((1.0f64 / (1u64 << esu) as f64) * 1_000_000.0)
}
pub fn read_rapl_energy_uj(cpu: u32, domain: RaplDomain) -> Option<f64> {
let ticks = read_rapl_energy(cpu, domain)?;
let unit = read_rapl_energy_unit(cpu)?;
Some(ticks as f64 * unit)
}
/// Read a Redox thermal zone temperature file.
fn read_redox_zone_temp(zone_name: &str) -> Option<i64> {
let path = Path::new(REDOX_THERMAL)