LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
LordBench watches the Raspberry Pi firmware during the whole run: the rpi_volt under-voltage alarm (the only flag the LordOS 6.18 kernel exposes), get_throttled where an older kernel has it (strictly parsed, now and since-boot bits, sticky bits from before the run ignored), and 80 °C on a Pi counted as the firmware's temperature limit; peak tests stop as throttled, the sustained test records it, under-voltage never stops a run; piFirmware in the result, the Stability verdict and a Board firmware row in Conditions (en/es/pt); fake-sysfs tests; BENCHMARK, CHANGELOG
Federico Pereira8b37c328071f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 012d30c..c262f2c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -145,15 +145,42 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),- **Boot measured:** the Pi 5 reaches the login screen on its monitor 5.99 s after the kernel starts (systemd: 2.1 skernel + 4.2 s userspace).- **Pi limitation:** the LordOS Pi kernel exposes neither the firmware's `get_throttled` nor a cpufreq cooling- device, so LordBench's stop on throttling can't fire there (the under-voltage alarm is read); the sustained curve- and the temperature are the evidence instead.+ device, so the firmware's own flags can't be seen there (the under-voltage alarm is read); the sustained curve+ and the temperature are the evidence instead, and the firmware's documented 80 °C limit now counts as+ throttling (next item).+ - **The Raspberry Pi firmware's throttling during a run** (`bench/lbcond.c`, `bench/lbrun.c`; `docs/BENCHMARK.md`,+ "The Raspberry Pi firmware's throttling"; tested on fake sysfs trees and VM 116, **not yet run on a real Pi**).+ Checked in Raspberry Pi's `rpi-6.18.y` source, the kernel LordOS ships: `drivers/firmware/raspberrypi.c` has no+ `get_throttled` file any more, and the `rpi_volt` hwmon (`drivers/hwmon/raspberrypi-hwmon.c`, a module in+ `bcm2712_defconfig`) asks the firmware every 2 s with the sticky bits cleared and exposes only+ `in0_lcrit_alarm` (0444), "under-voltage in the last 2 s"; the capped, throttled and soft-limit bits are not+ exposed without the mailbox, which LordBench never opens. So lord-server now: reads the alarm strictly (`0` or+ `1`); still reads `get_throttled` where an older kernel has it, strictly (1-8 hex digits, optional `0x`,+ `lb_rpi_parse_throttled`, masked to bits 0-3 "now" and 16-19 "has occurred"; anything else is unknown instead of+ being half-parsed); knows a Pi from that hwmon, that file or the device tree's `raspberrypi,` compatible; and on a+ Pi counts the hottest zone at or above 80 °C as the firmware's limit (Raspberry Pi documents progressive Arm+ throttling from 80 °C; the Pi 5's thermal zone has no passive trip, so before this the guard waited for 100 °C).+ Every guard sample of the run (once a second) is accumulated (`lb_rpi_watch`): "now" bits and the 80 °C limit+ always count, while a sticky bit or alarm already set at the start counts only after it was seen clear and set+ again, so an event from before the run is never blamed on it. Before, the alarm and the bits were only looked at+ in the start and end snapshots, so an under-voltage in the middle of a run was lost. In a peak test, capped,+ throttled, soft limit or the 80 °C limit stop the run as `throttled` (like the x86 counters); in the sustained+ test the first one is recorded as `throttleAtS`/`throttleTempC`; under-voltage is never a stop and is recorded+ on its own. A result on a Pi carries `piFirmware` (`flags`, `voltageAlarm`, `underVoltage`, `capped`,+ `throttled`, `softLimit`, `tempLimit`, `tempLimitC`; what could not be read is left out, not `false`), and+ `before`/`after` add `rpiUnderVoltageAlarm`. System Information → Performance: the Stability verdict uses+ `piFirmware` for "The board reports throttling", a new "It reached 80 °C, where the board's firmware starts+ slowing the processor down" and "The board reports low supply voltage" (older results keep the end's bits), and+ Conditions has a new **Board firmware** row (en, es, pt). Machines that are not a Pi are unchanged.- **Tests:** `tests/lordbench_test.c` (records, workloads, fake sysfs trees of an x86 laptop and a Pi 5, boothistory, the frame recorder and its pointer latency, the synthetic pointer's thread and eventfd, the videorecords, the boot test state file, the interface scene with every style key known, each paragraph shaped with no- missing glyph and the same twice, the sandbox self-test's records; 1,178 checks) and- `tests/sysinfo_perf_test.mjs` (55 checks, with the desktop verdict, the pointer latency notes, the video- category, the self-test in the stability verdict with and without Landlock, and the engine workloads compared- only within one LordOS version).+ missing glyph and the same twice, the sandbox self-test's records, the Pi firmware's flags and alarm on a Pi 5 with+ LordOS's kernel, a Pi known from its device tree and an older kernel with `get_throttled`, and the strict+ `get_throttled` parser; 1,198 checks) and+ `tests/sysinfo_perf_test.mjs` (62 checks, with the desktop verdict, the pointer latency notes, the video+ category, the self-test in the stability verdict with and without Landlock, the engine workloads compared+ only within one LordOS version, and `piFirmware` in the stability verdict).- **Not built yet:** hardware video decoding and the x86 PC reference.- **Flatpak and Flathub design review, kept for the future** (`docs/FLATPAK.md`, no code; the maintainer decided on2026-10-27 not to implement Flatpak for now, to keep the system stable, and it is not planned for any release): adiff --git a/apps/sysinfo/perf.js b/apps/sysinfo/perf.jsindex 1dcd8e9..ce7cb11 100644--- a/apps/sysinfo/perf.js+++ b/apps/sysinfo/perf.js@@ -66,6 +66,22 @@ export function comparableReferences(res) {const throttled = (c) => c && c.rpiThrottled != null && (c.rpiThrottled & 0x7) !== 0;+// The Raspberry Pi firmware during the run (res.piFirmware, server/src/bench/lbrun.c and lbcond.h): what it+// reported between the start and the end, not since boot. `flags` says get_throttled was readable (capped,+// throttled and softLimit are known only then); `voltageAlarm` that rpi_volt's under-voltage alarm was; tempLimit+// is the hottest zone at or above the firmware's documented limit (tempLimitC). Results from before it have only+// the end's rpiThrottled bits.+export const PI_FIRMWARE_EVENTS = ['underVoltage', 'capped', 'throttled', 'softLimit', 'tempLimit'];+export function piFirmware(res) {+ const pf = res && res.piFirmware;+ if (!pf || typeof pf !== 'object') return null;+ return {+ flags: pf.flags === true, voltageAlarm: pf.voltageAlarm === true,+ tempLimitC: typeof pf.tempLimitC === 'number' ? pf.tempLimitC : null,+ events: PI_FIRMWARE_EVENTS.filter((id) => pf[id] === true),+ };+}+export function stability(res) {if (!res) return { state: 'unknown', notes: [] };const notes = [];@@ -77,8 +93,16 @@ export function stability(res) {if (failed.length) warn('measureFailed', { count: failed.length });const b = res.before || {}, a = res.after || {};if (b.throttleEvents != null && a.throttleEvents != null && a.throttleEvents > b.throttleEvents) warn('throttleSeen', { count: a.throttleEvents - b.throttleEvents });- if (throttled(a)) warn('piThrottled');- if (a.rpiThrottled != null && (a.rpiThrottled & 1)) warn('underVoltage');+ const pf = piFirmware(res);+ if (pf) {+ const ev = pf.events;+ if (ev.includes('capped') || ev.includes('throttled') || ev.includes('softLimit')) warn('piThrottled');+ else if (ev.includes('tempLimit')) warn('piTempLimit', { temp: pf.tempLimitC });+ if (ev.includes('underVoltage')) warn('underVoltage');+ } else {+ if (throttled(a)) warn('piThrottled');+ if (a.rpiThrottled != null && (a.rpiThrottled & 1)) warn('underVoltage');+ }const s = res.results || {};if (s['sustained.start'] && s['sustained.end']) {const drop = 1 - s['sustained.end'].value / s['sustained.start'].value;diff --git a/apps/sysinfo/performance.jsx b/apps/sysinfo/performance.jsxindex d901218..ba0ca24 100644--- a/apps/sysinfo/performance.jsx+++ b/apps/sysinfo/performance.jsx@@ -11,7 +11,7 @@ import {View, Text, ScrollView, Button, useTheme, useLocale, GroupBox, FormRow, Segmented, formatNumber, spacing, typeScale, fs, userDirs, wm, admin, session,} from '@lordos/sdk';import { useEffect, useMemo, useState } from 'react';-import { CATEGORIES, DESKTOP_CATEGORIES, ratio, categoryRatios, comparableReferences, stability, compatibilityVerdict, desktopVerdict, conditionDiffs, changes, sustainedSeries, fileName } from './perf.js';+import { CATEGORIES, DESKTOP_CATEGORIES, ratio, categoryRatios, comparableReferences, stability, compatibilityVerdict, desktopVerdict, conditionDiffs, changes, sustainedSeries, fileName, piFirmware } from './perf.js';import { startScene } from './scene.jsx';import { compatibility } from './model.js';@@ -118,6 +118,11 @@ function Conditions({ res }) {const temp = (c) => (c.tempC != null ? tr('sysinfo.perf.tempC', { v: formatNumber(c.tempC, 0) }) : '');const trips = [b.passiveC ? tr('sysinfo.perf.passive', { v: formatNumber(b.passiveC, 0) }) : '', b.criticalC ? tr('sysinfo.perf.critical', { v: formatNumber(b.criticalC, 0) }) : ''].filter(Boolean).join(' · ');const ds = ((res.session && res.session.displays) || []).map((d) => (d.mode ? `${d.mode.w}×${d.mode.h} @ ${formatNumber(d.mode.refresh / 1000, 0)} Hz${d.scale && d.scale !== 100 ? ` (${d.scale} %)` : ''}` : '')).filter(Boolean).join(', ');+ // a Raspberry Pi: what its firmware reported during the run; "none" says what could be watched+ const pf = piFirmware(res);+ const pfVars = { temp: formatNumber((pf && pf.tempLimitC) || 80, 0) };+ const pfText = !pf ? '' : pf.events.length ? pf.events.map((id) => tr(`sysinfo.perf.pi.${id}`, pfVars)).join(', ')+ : tr(pf.flags ? 'sysinfo.perf.pi.none' : pf.voltageAlarm ? 'sysinfo.perf.pi.noneVoltage' : 'sysinfo.perf.pi.noneTemp', pfVars);return (<GroupBox title={tr('sysinfo.perf.conditions')} footer={tr('sysinfo.perf.conditionsFooter')}><Row label={tr('sysinfo.perf.c.versions')} value={`LordOS ${res.lordos} · ${tr('sysinfo.perf.kernel', { v: res.kernel })} · LordBench ${res.lordbench}`} />@@ -125,6 +130,7 @@ function Conditions({ res }) {<Row label={tr('sysinfo.perf.c.quiet')} value={tr(res.quiet && res.quiet.quiet ? 'sysinfo.perf.quietYes' : 'sysinfo.perf.quietNo', { pct: formatNumber((res.quiet && res.quiet.busyPct) || 0, 0), s: formatNumber((res.quiet && res.quiet.waitedS) || 0, 0) })} /><Row label={tr('sysinfo.perf.c.temps')} value={[temp(b) && tr('sysinfo.perf.startEnd', { a: temp(b), b: temp(a) || '—' }), trips].filter(Boolean).join(' · ')} /><Row label={tr('sysinfo.perf.c.power')} value={[tr(`sysinfo.perf.power.${b.power || 'unknown'}`), b.batteryPct != null ? `${b.batteryPct} %` : '', b.platformProfile || ''].filter(Boolean).join(' · ')} />+ {pf ? <Row label={tr('sysinfo.perf.c.piFirmware')} value={pfText} /> : null}<Row label={tr('sysinfo.perf.c.cpufreq')} value={[b.governor, b.freqMaxMHz ? tr('sysinfo.perf.maxMHz', { v: formatNumber(b.freqMaxMHz, 0) }) : ''].filter(Boolean).join(' · ')} /><Row label={tr('sysinfo.perf.c.gpu')} value={[res.gpuKind ? tr(`sysinfo.perf.gpuKind.${res.gpuKind}`) : '', res.session && res.session.renderer].filter(Boolean).join(' · ')} /><Row label={tr('sysinfo.perf.c.displays')} value={[ds, res.session && res.session.composition ? tr('sysinfo.perf.composition', { c: res.session.composition }) : ''].filter(Boolean).join(' · ')} />diff --git a/assets/locales/en/sysinfo.json b/assets/locales/en/sysinfo.jsonindex 87615d9..b8c4bac 100644--- a/assets/locales/en/sysinfo.json+++ b/assets/locales/en/sysinfo.json@@ -258,6 +258,7 @@"perf.c.displays": "Displays","perf.c.gpu": "Graphics","perf.c.live": "System",+ "perf.c.piFirmware": "Board firmware","perf.c.power": "Power","perf.c.quiet": "Before starting","perf.c.storage": "Storage test",@@ -386,6 +387,7 @@"perf.note.measureFailed": "{count} measurement(s) failed.","perf.note.none": "Ran to the end with no throttling, no stops and no failed measurement.","perf.note.notQuiet": "The computer was busy before starting ({pct} % CPU): the numbers may be low.",+ "perf.note.piTempLimit": "It reached {temp} °C, where the board's firmware starts slowing the processor down.","perf.note.piThrottled": "The board reports throttling.","perf.note.sandboxHeld": "The benchmark helper's sandbox refused all {count} things it must not do.","perf.note.sandboxLeaks": "The benchmark helper's sandbox did not stop it from: {list}.",@@ -398,6 +400,14 @@"perf.note.throttleSeen": "The processor throttled {count} time(s) during the run.","perf.note.underVoltage": "The board reports low supply voltage: use a better power supply.","perf.passive": "slows down at {v} °C",+ "perf.pi.capped": "processor clock capped",+ "perf.pi.none": "no under-voltage or throttling during the run",+ "perf.pi.noneTemp": "stayed below {temp} °C (this kernel reports no firmware flags)",+ "perf.pi.noneVoltage": "no under-voltage and below {temp} °C during the run",+ "perf.pi.softLimit": "soft temperature limit",+ "perf.pi.tempLimit": "reached {temp} °C (the firmware slows down)",+ "perf.pi.throttled": "throttled",+ "perf.pi.underVoltage": "under-voltage","perf.power.battery": "on battery","perf.power.mains": "plugged in","perf.power.unknown": "no battery reported",diff --git a/assets/locales/es/sysinfo.json b/assets/locales/es/sysinfo.jsonindex 5562c04..8a54dfe 100644--- a/assets/locales/es/sysinfo.json+++ b/assets/locales/es/sysinfo.json@@ -258,6 +258,7 @@"perf.c.displays": "Pantallas","perf.c.gpu": "Gráficos","perf.c.live": "Sistema",+ "perf.c.piFirmware": "Firmware de la placa","perf.c.power": "Energía","perf.c.quiet": "Antes de empezar","perf.c.storage": "Prueba de disco",@@ -386,6 +387,7 @@"perf.note.measureFailed": "{count} medición(es) fallaron.","perf.note.none": "Llegó al final sin bajar la velocidad, sin detenerse y sin mediciones fallidas.","perf.note.notQuiet": "El equipo estaba ocupado antes de empezar ({pct} % de CPU): los números pueden ser bajos.",+ "perf.note.piTempLimit": "Llegó a {temp} °C, donde el firmware de la placa empieza a bajar la velocidad del procesador.","perf.note.piThrottled": "La placa informa que bajó la velocidad.","perf.note.sandboxHeld": "El aislamiento del ayudante de la prueba rechazó las {count} cosas que no debe hacer.","perf.note.sandboxLeaks": "El aislamiento del ayudante de la prueba no le impidió: {list}.",@@ -398,6 +400,14 @@"perf.note.throttleSeen": "El procesador bajó la velocidad {count} vez/veces durante la prueba.","perf.note.underVoltage": "La placa informa bajo voltaje de alimentación: usá una fuente mejor.","perf.passive": "baja la velocidad a {v} °C",+ "perf.pi.capped": "reloj del procesador limitado",+ "perf.pi.none": "sin bajo voltaje ni baja de velocidad durante la prueba",+ "perf.pi.noneTemp": "se mantuvo debajo de {temp} °C (este kernel no informa las señales del firmware)",+ "perf.pi.noneVoltage": "sin bajo voltaje y debajo de {temp} °C durante la prueba",+ "perf.pi.softLimit": "límite suave de temperatura",+ "perf.pi.tempLimit": "llegó a {temp} °C (el firmware baja la velocidad)",+ "perf.pi.throttled": "bajó la velocidad",+ "perf.pi.underVoltage": "bajo voltaje","perf.power.battery": "con batería","perf.power.mains": "enchufado","perf.power.unknown": "sin batería informada",diff --git a/assets/locales/pt/sysinfo.json b/assets/locales/pt/sysinfo.jsonindex 532e536..2d064fe 100644--- a/assets/locales/pt/sysinfo.json+++ b/assets/locales/pt/sysinfo.json@@ -258,6 +258,7 @@"perf.c.displays": "Telas","perf.c.gpu": "Gráficos","perf.c.live": "Sistema",+ "perf.c.piFirmware": "Firmware da placa","perf.c.power": "Energia","perf.c.quiet": "Antes de começar","perf.c.storage": "Teste de disco",@@ -386,6 +387,7 @@"perf.note.measureFailed": "{count} medição(ões) falharam.","perf.note.none": "Chegou ao fim sem reduzir a velocidade, sem parar e sem medições com falha.","perf.note.notQuiet": "O computador estava ocupado antes de começar ({pct} % de CPU): os números podem estar baixos.",+ "perf.note.piTempLimit": "Chegou a {temp} °C, onde o firmware da placa começa a reduzir a velocidade do processador.","perf.note.piThrottled": "A placa informa redução de velocidade.","perf.note.sandboxHeld": "O isolamento do auxiliar do teste recusou as {count} coisas que não deve fazer.","perf.note.sandboxLeaks": "O isolamento do auxiliar do teste não o impediu de: {list}.",@@ -398,6 +400,14 @@"perf.note.throttleSeen": "O processador reduziu a velocidade {count} vez(es) durante o teste.","perf.note.underVoltage": "A placa informa tensão de alimentação baixa: use uma fonte melhor.","perf.passive": "reduz a velocidade a {v} °C",+ "perf.pi.capped": "relógio do processador limitado",+ "perf.pi.none": "sem subtensão nem redução de velocidade durante o teste",+ "perf.pi.noneTemp": "ficou abaixo de {temp} °C (este kernel não informa os sinais do firmware)",+ "perf.pi.noneVoltage": "sem subtensão e abaixo de {temp} °C durante o teste",+ "perf.pi.softLimit": "limite suave de temperatura",+ "perf.pi.tempLimit": "chegou a {temp} °C (o firmware reduz a velocidade)",+ "perf.pi.throttled": "reduziu a velocidade",+ "perf.pi.underVoltage": "subtensão","perf.power.battery": "na bateria","perf.power.mains": "na tomada","perf.power.unknown": "sem bateria informada",diff --git a/docs/BENCHMARK.md b/docs/BENCHMARK.mdindex 73ad296..a7d2dc3 100644--- a/docs/BENCHMARK.md+++ b/docs/BENCHMARK.md@@ -326,10 +326,54 @@ development package.(a device's own battery, such as a mouse's, is ignored) and mains. A run is refused on battery below30 %, waits for 10 s in a row below 15 % CPU (at most 30 s, then it runs marked "busy"), stops within2 °C of the passive trip point (or 10 °C of the critical one when there is no passive), and in the peak- tests stops when the throttle counters grow or the Pi says it is throttling now; in the sustained test- throttling is recorded with its time and temperature instead. The kind of disk under the scratch file- is recorded (NVMe, SD/eMMC, SSD, HDD, USB, virtual, or RAM in the live session). Unit tests on fake- sysfs trees (`tests/lordbench_test.c`): an x86 laptop on battery, a Raspberry Pi 5.+ tests stops when the throttle counters grow or the Pi firmware slowed the processor during the run (below);+ in the sustained test throttling is recorded with its time and temperature instead. The kind of disk under+ the scratch file is recorded (NVMe, SD/eMMC, SSD, HDD, USB, virtual, or RAM in the live session). Unit tests+ on fake sysfs trees (`tests/lordbench_test.c`): an x86 laptop on battery, a Raspberry Pi 5 with the kernel+ LordOS ships, a Pi known only from its device tree, and an older Pi kernel with `get_throttled`.+- **The Raspberry Pi firmware's throttling** (0.8.6 in development, 2026-10-28; `bench/lbcond.c`, not yet run+ on a real Pi). On a Pi the firmware itself lowers the ARM clock on under-voltage, at its temperature limit+ or when the clock is capped, and cpufreq may not show it. What the kernel tells an unprivileged process,+ checked in Raspberry Pi's `rpi-6.18.y` source (the branch `tools/rpi/build-kernel.sh` builds;+ `bcm2712_defconfig` has `CONFIG_SENSORS_RASPBERRYPI_HWMON=m`):+ - `drivers/firmware/raspberrypi.c` on that branch has **no** `get_throttled` file: it only asks the firmware+ for GET_THROTTLED once to decide whether to register the `raspberrypi-hwmon` device. (Older Raspberry Pi+ kernels had a `get_throttled` attribute under the firmware node; the 2026-10-27 run on the Pi 5 found+ none, as the source says.)+ - `drivers/hwmon/raspberrypi-hwmon.c` (hwmon `rpi_volt`) asks GET_THROTTLED every 2 s **with the sticky bits+ cleared each time** (request value `0xffff`) and exposes one file, `in0_lcrit_alarm` (mode 0444): bit 16,+ "under-voltage has occurred", of the last answer. So it means "under-voltage in the last 2 s window".+ - The frequency-capped, throttled and soft-limit bits are not exposed at all on this kernel; reading them+ would need the mailbox (`/dev/vcio`, `vcgencmd`), which LordBench never opens or runs.++ So lord-server reads, world-readable and without exec or root: `rpi_volt`'s `in0_lcrit_alarm` (exactly `0`+ or `1`, anything else is unknown); `get_throttled` where a kernel has it (directly under a+ `/sys/devices/platform` node or its `<node>:firmware` child; 1-8 hex digits with an optional `0x` and a+ newline, nothing else, `lb_rpi_parse_throttled`; masked to the eight known bits: 0 under-voltage now, 1 ARM+ frequency capped now, 2 throttled now, 3 soft temperature limit now, 16-19 the same "has occurred"); and+ whether the machine is a Pi at all (that hwmon, that file, or a `raspberrypi,` entry in the device tree's+ root `compatible`). On a Pi, the hottest zone at or above **80 °C** counts as the firmware's limit+ (`LB_RPI_HOT`): Raspberry Pi's documentation says the Arm cores are progressively throttled between 80 and+ 85 °C, and the Pi 5's kernel thermal zone has no passive trip point that would show it (only the 110 °C+ critical one, so the thermal guard alone would wait until 100 °C).++ Every guard sample (once a second, also during the video jobs and the desktop run) goes through+ `lb_rpi_watch`: the "now" bits and `LB_RPI_HOT` always count; a sticky bit or the alarm already set when+ the run starts may predate the run, so it counts only once it has been seen clear and then set again (with+ the 2 s clearing this happens within one window; on a kernel that never clears them, an event from before+ the run is never blamed on it). In a peak test, frequency capped, throttled, soft limit or the 80 °C limit+ stops the run as `throttled`, like the x86 counters; in the sustained test the first one is recorded as+ `throttleAtS`/`throttleTempC`. Under-voltage is never a stop: it is recorded on its own. The result gets+ `piFirmware` on a Pi: `{flags, voltageAlarm, underVoltage, capped, throttled, softLimit, tempLimit,+ tempLimitC}`, where `flags`/`voltageAlarm` say what was readable, `underVoltage` is present only when one of+ them was, and `capped`/`throttled`/`softLimit` only with `flags` (unknown is left out, never `false`).+ `before`/`after` keep the raw `rpiThrottled` bits and add `rpiUnderVoltageAlarm`. System Information →+ Performance: the Stability verdict warns "The board reports throttling" (capped, throttled, soft limit),+ "It reached 80 °C, where the board's firmware starts slowing the processor down", and "The board reports low+ supply voltage" from `piFirmware` (older results keep using the end's bits), and Conditions gets a "Board+ firmware" row listing what happened, or what was watched when nothing did. Machines that are not a Pi get no+ `piFirmware` and behave as before. Not verified on a real Pi yet: that the alarm reads `1` during an actual+ under-voltage, and how fast the Pi 5 reaches 80 °C without a cooler in the peak tests.- **Helper-sandbox self-test** (`sec.helper-sandbox`, repeated inside `lord-bench`, `sandbox_tries` in`bench/lbmain.c`): right after `sandbox_apply_helper` and before any work, in every mode, `lord-bench` tries sixthings that must fail: the Sandbox Probe's helper tries (`app/probe.c`) with its own versions of the data-folder@@ -400,7 +444,8 @@ video decoding H.264 1080p 258 fps, HEVC 1080p 246, VP9 1080p 204, AV1 1080p 159encoders H.264 75 fps and VP8 55 fps. A Quick run took 34 s. On this kernel the firmware's `get_throttled` file anda cpufreq cooling device are not exposed, so firmware throttling can't be seen during a run (the stop onthrottling does not fire on the Pi; the `rpi_volt` under-voltage alarm is read); the sustained curve and the-temperature are the evidence that it did not throttle.+temperature are the evidence that it did not throttle. (Since then the alarm is watched during the whole run and+the firmware's documented 80 °C limit counts as throttling on a Pi: "The Raspberry Pi firmware's throttling" above.)Desktop impact:diff --git a/server/src/bench/lbcond.c b/server/src/bench/lbcond.cindex cbf03dd..a7991a4 100644--- a/server/src/bench/lbcond.c+++ b/server/src/bench/lbcond.c@@ -73,9 +73,13 @@ static void hwmon(const char *root, LbCond *c) {char p[96], name[24] = "";snprintf(p, sizeof p, "/sys/class/hwmon/%s/name", e->d_name);if (rd(root, p, name, sizeof name)) continue;- if (!strcmp(name, "rpi_volt")) { /* the Pi's under-voltage alarm */+ if (!strcmp(name, "rpi_volt")) {+ /* the Pi firmware's under-voltage alarm (drivers/hwmon/raspberrypi-hwmon.c): GET_THROTTLED's sticky+ * under-voltage bit, asked every 2 s with the sticky bits cleared each time; "0" or "1" only */+ char v[8];snprintf(p, sizeof p, "/sys/class/hwmon/%s/in0_lcrit_alarm", e->d_name);- if (rdl(root, p, 0) == 1) { if (c->rpi_throttled < 0) c->rpi_throttled = 0; c->rpi_throttled |= LB_RPI_UV; }+ c->rpi = 1;+ if (!rd(root, p, v, sizeof v) && (!strcmp(v, "0") || !strcmp(v, "1"))) c->rpi_uv_alarm = v[0] - '0';continue;}if (strcmp(name, "coretemp") && strcmp(name, "k10temp") && strcmp(name, "zenpower")) continue;@@ -125,27 +129,53 @@ static void cpus(const char *root, LbCond *c) {rd(root, "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", c->governor, sizeof c->governor);}-/* the Pi firmware's get_throttled, wherever the firmware node sits (soc:firmware, axi:firmware…) */+int lb_rpi_parse_throttled(const char *s) {+ if (!s) return -1;+ if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) s += 2;+ unsigned long v = 0;+ int n = 0;+ for (; *s && *s != '\n'; s++, n++) {+ int d = *s >= '0' && *s <= '9' ? *s - '0' : *s >= 'a' && *s <= 'f' ? *s - 'a' + 10 : *s >= 'A' && *s <= 'F' ? *s - 'A' + 10 : -1;+ if (d < 0 || n >= 8) return -1;+ v = v << 4 | (unsigned long)d;+ }+ if (!n || (*s == '\n' && s[1])) return -1;+ return (int)(v & (LB_RPI_NOW_MASK | LB_RPI_STICKY_MASK));+}++/* the Pi firmware's get_throttled (drivers/firmware/raspberrypi.c of older Raspberry Pi kernels; the rpi-6.18.y+ * one LordOS ships has no such file and reports through rpi_volt instead): directly under a platform node or in+ * its "<node>:firmware" child (soc/soc:firmware, axi/axi:firmware, soc@107c000000/soc@107c000000:firmware) */static void rpi(const char *root, LbCond *c) {char d[PATH_MAX];snprintf(d, sizeof d, "%s/sys/devices/platform", root);DIR *dir = opendir(d);- if (!dir) return;- struct dirent *e;- while ((e = readdir(dir))) {- if (e->d_name[0] == '.' || strlen(e->d_name) > 64) continue;- char p[256], b[32];- const char *sub[] = { "", "/soc:firmware", "/axi:firmware" };- for (int i = 0; i < 3; i++) {- snprintf(p, sizeof p, "/sys/devices/platform/%s%s/get_throttled", e->d_name, sub[i]);- if (!rd(root, p, b, sizeof b) && b[0]) {- char *end;- unsigned long v = strtoul(b, &end, 16);- if (end != b) { c->rpi_throttled = (c->rpi_throttled > 0 ? c->rpi_throttled : 0) | (int)(v & 0xf000f); closedir(dir); return; }+ if (dir) {+ struct dirent *e;+ while (c->rpi_throttled < 0 && (e = readdir(dir))) {+ if (e->d_name[0] == '.' || strlen(e->d_name) > 64) continue;+ char p[256], b[32];+ for (int i = 0; i < 2 && c->rpi_throttled < 0; i++) {+ if (i) snprintf(p, sizeof p, "/sys/devices/platform/%s/%s:firmware/get_throttled", e->d_name, e->d_name);+ else snprintf(p, sizeof p, "/sys/devices/platform/%s/get_throttled", e->d_name);+ if (!rd(root, p, b, sizeof b)) c->rpi_throttled = lb_rpi_parse_throttled(b);}}+ closedir(dir);}- closedir(dir);+ if (c->rpi_throttled >= 0) c->rpi = 1;+ if (c->rpi) return;+ /* the device tree's root compatible ("raspberrypi,5-model-b\0brcm,bcm2712\0"), so a Pi without the hwmon+ * module still gets LB_RPI_HOT */+ char p[PATH_MAX], b[256];+ snprintf(p, sizeof p, "%s/sys/firmware/devicetree/base/compatible", root);+ FILE *f = fopen(p, "re");+ if (!f) return;+ size_t n = fread(b, 1, sizeof b - 1, f);+ fclose(f);+ b[n] = 0;+ for (size_t i = 0; i < n; i += strlen(b + i) + 1)+ if (!strncmp(b + i, "raspberrypi,", 12)) { c->rpi = 1; break; }}static void power(const char *root, LbCond *c) {@@ -185,6 +215,7 @@ void lb_cond_read(const char *root, LbCond *c) {memset(c, 0, sizeof *c);c->temp_c = -273;c->rpi_throttled = -1;+ c->rpi_uv_alarm = -1;c->on_battery = -1;c->battery_pct = -1;thermal(root, c);@@ -260,14 +291,53 @@ const char *lb_storage_kind(const char *root, const char *path) {return "unknown";}-const char *lb_cond_stop(const LbCond *start, const LbCond *now, int peak) {+/* this sample's events: the "now" bits, sticky bits set again after being seen clear, the alarm likewise, and+ * LB_RPI_HOT; a sticky bit or the alarm seen clear leaves the base, so its next setting is new */+static unsigned rpi_events(LbRpiWatch *w, const LbCond *c) {+ unsigned ev = 0;+ if (c->rpi) w->rpi = 1;+ if (c->rpi_throttled >= 0) {+ unsigned v = (unsigned)c->rpi_throttled, st = (v & LB_RPI_STICKY_MASK) >> 16;+ w->bits = 1;+ ev |= v & LB_RPI_NOW_MASK;+ ev |= st & ~w->base & 0xfu;+ w->base &= ~(0xfu & ~st);+ }+ if (c->rpi_uv_alarm >= 0) {+ w->alarm = 1;+ if (c->rpi_uv_alarm == 1) { if (!(w->base & (LB_RPI_UV << 4))) ev |= LB_RPI_UV; }+ else w->base &= ~(unsigned)(LB_RPI_UV << 4);+ }+ if (c->rpi && c->temp_c >= LB_RPI_FW_TEMP_C) ev |= LB_RPI_HOT;+ return ev;+}++void lb_rpi_watch_start(LbRpiWatch *w, const LbCond *c0) {+ memset(w, 0, sizeof *w);+ w->rpi = c0->rpi;+ w->bits = c0->rpi_throttled >= 0;+ w->alarm = c0->rpi_uv_alarm >= 0;+ if (c0->rpi_throttled >= 0) w->base = ((unsigned)c0->rpi_throttled & LB_RPI_STICKY_MASK) >> 16;+ if (c0->rpi_uv_alarm == 1) w->base |= LB_RPI_UV << 4;+ /* what is happening at the start itself counts: the "now" bits and the temperature */+ if (c0->rpi_throttled >= 0) w->seen |= (unsigned)c0->rpi_throttled & LB_RPI_NOW_MASK;+ if (c0->rpi && c0->temp_c >= LB_RPI_FW_TEMP_C) w->seen |= LB_RPI_HOT;+}++unsigned lb_rpi_watch(LbRpiWatch *w, const LbCond *cn) {+ unsigned ev = rpi_events(w, cn);+ w->seen |= ev;+ return ev;+}++const char *lb_cond_stop(const LbCond *start, const LbCond *now, unsigned rpi_events, int peak) {if (now->temp_c > -270) {if (now->passive_c > 0 && now->temp_c >= now->passive_c - 2) return "thermal";if (now->passive_c <= 0 && now->critical_c > 0 && now->temp_c >= now->critical_c - 10) return "thermal";}if (peak) {if (start->throttle_known && now->throttle_events > start->throttle_events) return "throttled";- if (now->rpi_throttled > 0 && (now->rpi_throttled & (LB_RPI_THROTTLED | LB_RPI_CAPPED | LB_RPI_SOFTTEMP))) return "throttled";+ if (rpi_events & LB_RPI_SLOWED) return "throttled";}return NULL;}diff --git a/server/src/bench/lbcond.h b/server/src/bench/lbcond.hindex 6165f65..eab9673 100644--- a/server/src/bench/lbcond.h+++ b/server/src/bench/lbcond.h@@ -13,7 +13,11 @@ typedef struct {char zone[24]; /* the hottest zone's type ("x86_pkg_temp", "cpu-thermal", …) */unsigned long throttle_events; /* x86 core + package thermal throttle counters, summed */int throttle_known; /* 1 if those counters exist */- int rpi_throttled; /* the Pi firmware's get_throttled bits (-1: no such file) */+ int rpi; /* 1 on a Raspberry Pi: its firmware's hwmon or get_throttled, or the device tree */+ int rpi_throttled; /* get_throttled, masked to LB_RPI_NOW_MASK | LB_RPI_STICKY_MASK (-1: no such file,+ * or not a 1-8 digit hex number) */+ int rpi_uv_alarm; /* rpi_volt's in0_lcrit_alarm: 1 under-voltage in the firmware's last report,+ * 0 none, -1 no such sensor */double freq_mhz, freq_max_mhz; /* the average current and the highest maximum cpufreq, 0 unknown */char governor[24];char platform_profile[24]; /* /sys/firmware/acpi/platform_profile, "" without one */@@ -23,9 +27,31 @@ typedef struct {void lb_cond_read(const char *root, LbCond *c);-/* the Pi firmware's flags: 0 under-voltage now, 1 frequency capped now, 2 throttled now, 3 soft- * temperature limit now; bits 16-19 the same since boot */-enum { LB_RPI_UV = 1, LB_RPI_CAPPED = 2, LB_RPI_THROTTLED = 4, LB_RPI_SOFTTEMP = 8 };+/* The Pi firmware's GET_THROTTLED word (docs/BENCHMARK.md, "The Raspberry Pi firmware's throttling"): bit 0+ * under-voltage now, 1 ARM frequency capped now, 2 throttled now, 3 soft temperature limit now; bits 16-19 the+ * same four "has occurred", sticky until someone asks the firmware to clear them (the kernel's rpi_volt hwmon+ * does, every 2 s). LB_RPI_HOT is ours: on a Pi, the hottest zone at or above LB_RPI_FW_TEMP_C, where Raspberry+ * Pi's documentation says the firmware starts slowing the ARM cores down. */+enum { LB_RPI_UV = 1, LB_RPI_CAPPED = 2, LB_RPI_THROTTLED = 4, LB_RPI_SOFTTEMP = 8, LB_RPI_HOT = 16 };+#define LB_RPI_NOW_MASK 0x0000fu+#define LB_RPI_STICKY_MASK 0xf0000u+#define LB_RPI_SLOWED (LB_RPI_CAPPED | LB_RPI_THROTTLED | LB_RPI_SOFTTEMP | LB_RPI_HOT)+#define LB_RPI_FW_TEMP_C 80.0++/* get_throttled's text, strictly: 1-8 hex digits (an optional 0x), an optional newline, nothing else; the+ * value masked to the eight known bits, or -1 */+int lb_rpi_parse_throttled(const char *s);++/* What the Pi firmware reported during a run, sample by sample. A sticky bit (or the hwmon alarm) already set+ * at the start may predate the run, so it counts only once it was seen clear and then set again; the "now"+ * bits and LB_RPI_HOT always count. lb_rpi_watch returns this sample's LB_RPI_* events and adds them to seen. */+typedef struct {+ unsigned base; /* sticky bits (>> 16) and the alarm (LB_RPI_UV << 4) set at the start */+ unsigned seen; /* LB_RPI_* seen during the run */+ int rpi, bits, alarm; /* a Pi; get_throttled was readable; rpi_volt was there (at any sample) */+} LbRpiWatch;+void lb_rpi_watch_start(LbRpiWatch *w, const LbCond *c0);+unsigned lb_rpi_watch(LbRpiWatch *w, const LbCond *cn);/* CPU busy share between two reads of /proc/stat: lb_cpu_ticks fills busy and total */int lb_cpu_ticks(const char *root, unsigned long long *busy, unsigned long long *total);@@ -36,8 +62,9 @@ const char *lb_storage_kind(const char *root, const char *path);/* why a run must stop now, or NULL: "thermal" when the temperature is within 2 °C of the passive trip* point (or within 10 °C of the critical one when there's no passive), "throttled" when the throttle- * counters grew or the Pi says it throttles since `start` (only checked when peak = 1) */-const char *lb_cond_stop(const LbCond *start, const LbCond *now, int peak);+ * counters grew since `start` or `rpi_events` (lb_rpi_watch for `now`) has LB_RPI_SLOWED (only checked when+ * peak = 1). Under-voltage alone is recorded, never a stop. */+const char *lb_cond_stop(const LbCond *start, const LbCond *now, unsigned rpi_events, int peak);/* refused before starting: on battery below 30 % */int lb_cond_battery_low(const LbCond *c);diff --git a/server/src/bench/lbrun.c b/server/src/bench/lbrun.cindex 268ae13..f014d1a 100644--- a/server/src/bench/lbrun.c+++ b/server/src/bench/lbrun.c@@ -106,6 +106,7 @@ typedef struct {double sample_t[MAX_SAMPLES], sample_v[MAX_SAMPLES], sample_temp[MAX_SAMPLES];int nsamples;double throttle_at, throttle_temp;+ LbRpiWatch rpi; /* the Pi firmware's under-voltage and throttling during the run */double budget_ms, gap_max; /* desktop: the refresh period and the longest wait between frames */int sbx_have[LB_SBX_COUNT], sbx_refused[LB_SBX_COUNT], sbx_errno[LB_SBX_COUNT]; /* the helper-sandbox self-test */} Res;@@ -124,6 +125,7 @@ static void cond_json(HBuf *b, const LbCond *c) {if (c->critical_c > 0) hb_printf(b, "\"criticalC\":%.1f,", c->critical_c);if (c->throttle_known) hb_printf(b, "\"throttleEvents\":%lu,", c->throttle_events);if (c->rpi_throttled >= 0) hb_printf(b, "\"rpiThrottled\":%d,", c->rpi_throttled);+ if (c->rpi_uv_alarm >= 0) hb_printf(b, "\"rpiUnderVoltageAlarm\":%d,", c->rpi_uv_alarm);if (c->freq_mhz > 0) hb_printf(b, "\"freqMHz\":%.0f,", c->freq_mhz);if (c->freq_max_mhz > 0) hb_printf(b, "\"freqMaxMHz\":%.0f,", c->freq_max_mhz);if (c->governor[0]) { hb_printf(b, "\"governor\":"); hb_str(b, c->governor); hb_printf(b, ","); }@@ -152,6 +154,15 @@ static char *build_result(const Job *j, int st, const char *why, const Res *r, ccond_json(&b, c0);hb_printf(&b, ",\"after\":");cond_json(&b, c1);+ if (r->rpi.rpi) { /* a Raspberry Pi: what its firmware reported during the run (lbcond.h) */+ const LbRpiWatch *w = &r->rpi;+ hb_printf(&b, ",\"piFirmware\":{\"flags\":%s,\"voltageAlarm\":%s", w->bits ? "true" : "false", w->alarm ? "true" : "false");+ if (w->bits || w->alarm) hb_printf(&b, ",\"underVoltage\":%s", (w->seen & LB_RPI_UV) ? "true" : "false");+ if (w->bits)+ hb_printf(&b, ",\"capped\":%s,\"throttled\":%s,\"softLimit\":%s", (w->seen & LB_RPI_CAPPED) ? "true" : "false",+ (w->seen & LB_RPI_THROTTLED) ? "true" : "false", (w->seen & LB_RPI_SOFTTEMP) ? "true" : "false");+ hb_printf(&b, ",\"tempLimit\":%s,\"tempLimitC\":%.0f}", (w->seen & LB_RPI_HOT) ? "true" : "false", LB_RPI_FW_TEMP_C);+ }hb_printf(&b, ",\"storage\":{\"kind\":\"%s\",\"mb\":%u}", storage, storage_mb);hb_printf(&b, ",\"gpuKind\":\"%s\"", r->gpu_kind == 0 ? "hardware" : r->gpu_kind == 1 ? "virtual" : r->gpu_kind == 2 ? "software" : "");hb_printf(&b, ",\"sandbox\":%d", r->sandbox);@@ -299,10 +310,11 @@ static const char *guard(Guard *g) {g->next = bench_now_ms() + 1000;LbCond cn;lb_cond_read("", &cn);- const char *s = lb_cond_stop(&g->c0, &cn, !g->sustained);Res *r = g->r;+ unsigned ev = lb_rpi_watch(&r->rpi, &cn); /* the Pi firmware's reports, accumulated over the run */+ const char *s = lb_cond_stop(&g->c0, &cn, ev, !g->sustained);if (g->sustained && r->throttle_at < 0 &&- ((g->c0.throttle_known && cn.throttle_events > g->c0.throttle_events) || (cn.rpi_throttled > 0 && (cn.rpi_throttled & (LB_RPI_THROTTLED | LB_RPI_CAPPED | LB_RPI_SOFTTEMP))))) {+ ((g->c0.throttle_known && cn.throttle_events > g->c0.throttle_events) || (ev & LB_RPI_SLOWED))) {r->throttle_at = r->nsamples ? r->sample_t[r->nsamples - 1] : 0;r->throttle_temp = cn.temp_c;}@@ -396,6 +408,7 @@ static void *run(void *arg) {r->gpu_kind = -1;r->throttle_at = -1;lb_cond_read("", &c0);+ lb_rpi_watch_start(&r->rpi, &c0);c1 = c0;g.c0 = c0;g.r = r;@@ -571,6 +584,7 @@ finish:if (disk >= 0) close(disk);lb_cond_read("", &c1);if (r) {+ lb_rpi_watch(&r->rpi, &c1);if (!why && st == ST_FAILED) why = "helper";if (st == ST_FAILED && why && !strcmp(why, "battery")) st = ST_STOPPED;char *json = build_result(j, st, why, r, &c0, &c1, busy_pct, waited, quiet, threads, storage, storage_mb,diff --git a/server/tests/lordbench_test.c b/server/tests/lordbench_test.cindex 26463c2..ebbd27f 100644--- a/server/tests/lordbench_test.c+++ b/server/tests/lordbench_test.c@@ -273,16 +273,28 @@ int main(void) {CHECK(c0.freq_mhz == 2400 && c0.freq_max_mhz == 4200 && !strcmp(c0.governor, "powersave"), "cpufreq");CHECK(c0.on_battery == 1 && c0.battery_pct == 25, "battery %d %d (a mouse's battery ignored)", c0.on_battery, c0.battery_pct);CHECK(lb_cond_battery_low(&c0), "below 30 %% on battery: refused");- CHECK(c0.rpi_throttled == -1, "no Pi firmware");- CHECK(!lb_cond_stop(&c0, &c0, 1), "nothing to stop at 61 °C");+ CHECK(c0.rpi_throttled == -1 && c0.rpi_uv_alarm == -1 && !c0.rpi, "no Pi firmware");+ {+ LbRpiWatch pw;+ lb_rpi_watch_start(&pw, &c0);+ CHECK(!pw.rpi && !pw.seen && !lb_rpi_watch(&pw, &c0), "not a Pi: no firmware events");+ }+ CHECK(!lb_cond_stop(&c0, &c0, 0, 1), "nothing to stop at 61 °C");put("/sys/class/thermal/thermal_zone0/temp", "93500\n");lb_cond_read(root, &c1);- CHECK(lb_cond_stop(&c0, &c1, 0) && !strcmp(lb_cond_stop(&c0, &c1, 0), "thermal"), "within 2 °C of passive: thermal");+ CHECK(lb_cond_stop(&c0, &c1, 0, 0) && !strcmp(lb_cond_stop(&c0, &c1, 0, 0), "thermal"), "within 2 °C of passive: thermal");+ put("/sys/class/thermal/thermal_zone0/temp", "85000\n");+ lb_cond_read(root, &c1);+ {+ LbRpiWatch pw;+ lb_rpi_watch_start(&pw, &c0);+ CHECK(!lb_rpi_watch(&pw, &c1) && !lb_cond_stop(&c0, &c1, 0, 1), "not a Pi: 85 °C is no firmware limit");+ }put("/sys/class/thermal/thermal_zone0/temp", "70000\n");put("/sys/devices/system/cpu/cpu0/thermal_throttle/core_throttle_count", "5\n");lb_cond_read(root, &c1);- CHECK(lb_cond_stop(&c0, &c1, 1) && !strcmp(lb_cond_stop(&c0, &c1, 1), "throttled"), "throttle counters grew in a peak test");- CHECK(!lb_cond_stop(&c0, &c1, 0), "…recorded but not stopped in the sustained test");+ CHECK(lb_cond_stop(&c0, &c1, 0, 1) && !strcmp(lb_cond_stop(&c0, &c1, 0, 1), "throttled"), "throttle counters grew in a peak test");+ CHECK(!lb_cond_stop(&c0, &c1, 0, 0), "…recorded but not stopped in the sustained test");put("/sys/class/power_supply/AC/online", "1\n");put("/sys/class/power_supply/BAT0/status", "Charging\n");lb_cond_read(root, &c1);@@ -290,30 +302,125 @@ int main(void) {unsigned long long busy, total;CHECK(!lb_cpu_ticks(root, &busy, &total) && total == 1000 && busy == 150, "/proc/stat %llu/%llu", busy, total);- /* a Raspberry Pi 5: no passive trip, the firmware's flags, hwmon's under-voltage alarm */+ /* get_throttled's text, strictly */+ CHECK(lb_rpi_parse_throttled("0\n") == 0 && lb_rpi_parse_throttled("50005") == 0x50005 && lb_rpi_parse_throttled("0x8000A\n") == 0x8000a,+ "get_throttled: plain, 0x and upper-case hex");+ CHECK(lb_rpi_parse_throttled("fffffff0") == 0xf0000, "get_throttled: unknown bits dropped (%#x)", lb_rpi_parse_throttled("fffffff0"));+ CHECK(lb_rpi_parse_throttled("") < 0 && lb_rpi_parse_throttled("0x") < 0 && lb_rpi_parse_throttled("123456789") < 0 &&+ lb_rpi_parse_throttled(" 5") < 0 && lb_rpi_parse_throttled("5 ") < 0 && lb_rpi_parse_throttled("-1") < 0 &&+ lb_rpi_parse_throttled("g") < 0 && lb_rpi_parse_throttled("5\nx") < 0 && lb_rpi_parse_throttled(NULL) < 0,+ "get_throttled: empty, too long, spaces, signs, other letters and a second line refused");++ /* a Raspberry Pi 5 with the kernel LordOS ships (rpi-6.18.y): no get_throttled, only rpi_volt's alarm (cleared+ * by the driver every 2 s); no passive trip */+ LbRpiWatch pw;+ unsigned ev;+ snprintf(root, sizeof root, "/tmp/lordbench-pi5-XXXXXX");+ if (!mkdtemp(root)) return 1;+ put("/sys/class/thermal/thermal_zone0/type", "cpu-thermal\n");+ put("/sys/class/thermal/thermal_zone0/temp", "55000\n");+ put("/sys/class/thermal/thermal_zone0/trip_point_0_type", "critical\n");+ put("/sys/class/thermal/thermal_zone0/trip_point_0_temp", "110000\n");+ put("/sys/class/hwmon/hwmon0/name", "rp1_adc\n");+ put("/sys/class/hwmon/hwmon1/name", "rpi_volt\n");+ put("/sys/class/hwmon/hwmon1/in0_lcrit_alarm", "0\n");+ put("/sys/devices/platform/soc@107c000000/soc@107c000000:firmware/uevent", "DRIVER=raspberrypi-firmware\n");+ lb_cond_read(root, &c0);+ CHECK(c0.rpi && c0.rpi_throttled == -1 && c0.rpi_uv_alarm == 0, "Pi 5: rpi %d flags %d alarm %d", c0.rpi, c0.rpi_throttled, c0.rpi_uv_alarm);+ CHECK(c0.passive_c == 0 && c0.critical_c == 110 && c0.on_battery == -1 && c0.battery_pct == -1, "Pi 5: trips, no power_supply");+ lb_rpi_watch_start(&pw, &c0);+ CHECK(pw.rpi && !pw.bits && pw.alarm && !pw.seen, "Pi 5: watch started clean");+ put("/sys/class/hwmon/hwmon1/in0_lcrit_alarm", "1\n");+ lb_cond_read(root, &c1);+ ev = lb_rpi_watch(&pw, &c1);+ CHECK(ev == LB_RPI_UV && !lb_cond_stop(&c0, &c1, ev, 1), "Pi 5: under-voltage during the run: recorded, not a stop (%#x)", ev);+ put("/sys/class/hwmon/hwmon1/in0_lcrit_alarm", "0\n");+ lb_cond_read(root, &c1);+ CHECK(!lb_rpi_watch(&pw, &c1) && (pw.seen & LB_RPI_UV), "Pi 5: the alarm cleared, the under-voltage stays in the run's record");+ put("/sys/class/hwmon/hwmon1/in0_lcrit_alarm", "yes\n");+ lb_cond_read(root, &c1);+ CHECK(c1.rpi_uv_alarm == -1, "Pi 5: an alarm that isn't 0 or 1 is unknown");+ put("/sys/class/hwmon/hwmon1/in0_lcrit_alarm", "0\n");+ put("/sys/class/thermal/thermal_zone0/temp", "79900\n");+ lb_cond_read(root, &c1);+ ev = lb_rpi_watch(&pw, &c1);+ CHECK(!ev && !lb_cond_stop(&c0, &c1, ev, 1), "Pi 5: 79.9 °C, below the firmware's limit");+ put("/sys/class/thermal/thermal_zone0/temp", "81200\n");+ lb_cond_read(root, &c1);+ ev = lb_rpi_watch(&pw, &c1);+ CHECK(ev == LB_RPI_HOT && lb_cond_stop(&c0, &c1, ev, 1) && !strcmp(lb_cond_stop(&c0, &c1, ev, 1), "throttled"),+ "Pi 5: at 81.2 °C the firmware slows the cores: a peak test stops as throttled");+ CHECK(!lb_cond_stop(&c0, &c1, ev, 0), "Pi 5: …recorded but not stopped in the sustained test");+ CHECK(pw.seen == (LB_RPI_UV | LB_RPI_HOT), "Pi 5: the run's record %#x", pw.seen);+ /* an alarm already set when the run starts may predate it: it counts once seen clear and set again */+ put("/sys/class/thermal/thermal_zone0/temp", "60000\n");+ put("/sys/class/hwmon/hwmon1/in0_lcrit_alarm", "1\n");+ lb_cond_read(root, &c0);+ lb_rpi_watch_start(&pw, &c0);+ CHECK(!pw.seen && !lb_rpi_watch(&pw, &c0), "Pi 5: an alarm set at the start isn't the run's");+ put("/sys/class/hwmon/hwmon1/in0_lcrit_alarm", "0\n");+ lb_cond_read(root, &c1);+ lb_rpi_watch(&pw, &c1);+ put("/sys/class/hwmon/hwmon1/in0_lcrit_alarm", "1\n");+ lb_cond_read(root, &c1);+ CHECK(lb_rpi_watch(&pw, &c1) == LB_RPI_UV, "Pi 5: …but it is once cleared and set again");++ /* a Pi without the hwmon module: the device tree still says it's a Pi, so the firmware's temperature limit holds */+ snprintf(root, sizeof root, "/tmp/lordbench-pidt-XXXXXX");+ if (!mkdtemp(root)) return 1;+ put("/sys/class/thermal/thermal_zone0/type", "cpu-thermal\n");+ put("/sys/class/thermal/thermal_zone0/temp", "82000\n");+ {+ char p[512];+ snprintf(p, sizeof p, "%s/sys/firmware/devicetree/base/compatible", root);+ put("/sys/firmware/devicetree/base/compatible", "");+ FILE *f = fopen(p, "w");+ static const char dt[] = "raspberrypi,5-model-b\0brcm,bcm2712\0";+ if (f) { fwrite(dt, 1, sizeof dt - 1, f); fclose(f); }+ }+ lb_cond_read(root, &c0);+ lb_rpi_watch_start(&pw, &c0);+ CHECK(c0.rpi && c0.rpi_uv_alarm == -1 && pw.seen == LB_RPI_HOT, "Pi from the device tree: hot at the start (%#x)", pw.seen);+ put("/sys/firmware/devicetree/base/compatible", "brcm,bcm2712\n");+ lb_cond_read(root, &c0);+ CHECK(!c0.rpi, "another bcm2712 board isn't a Pi");++ /* an older Raspberry Pi kernel with get_throttled (and rpi_volt clearing the sticky bits every 2 s) */snprintf(root, sizeof root, "/tmp/lordbench-pi-XXXXXX");if (!mkdtemp(root)) return 1;put("/sys/class/thermal/thermal_zone0/type", "cpu-thermal\n");put("/sys/class/thermal/thermal_zone0/temp", "55000\n");put("/sys/class/thermal/thermal_zone0/trip_point_0_type", "critical\n");put("/sys/class/thermal/thermal_zone0/trip_point_0_temp", "110000\n");- put("/sys/devices/platform/soc/soc:firmware/get_throttled", "0\n");+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "20000\n"); /* capped in the 2 s before the run */lb_cond_read(root, &c0);- CHECK(c0.rpi_throttled == 0 && c0.passive_c == 0 && c0.critical_c == 110, "Pi: flags %d trips %f %f", c0.rpi_throttled, c0.passive_c, c0.critical_c);- CHECK(c0.on_battery == -1 && c0.battery_pct == -1, "Pi: no power_supply");+ lb_rpi_watch_start(&pw, &c0);+ CHECK(c0.rpi && c0.rpi_throttled == 0x20000 && pw.bits && !pw.alarm && !pw.seen, "Pi: flags %#x, a sticky bit from before the run ignored",+ c0.rpi_throttled);put("/sys/class/thermal/thermal_zone0/temp", "101000\n");lb_cond_read(root, &c1);- CHECK(lb_cond_stop(&c0, &c1, 0) && !strcmp(lb_cond_stop(&c0, &c1, 0), "thermal"), "Pi: within 10 °C of critical");- put("/sys/class/thermal/thermal_zone0/temp", "80000\n");- put("/sys/devices/platform/soc/soc:firmware/get_throttled", "50005\n");+ ev = lb_rpi_watch(&pw, &c1);+ CHECK(lb_cond_stop(&c0, &c1, ev, 0) && !strcmp(lb_cond_stop(&c0, &c1, ev, 0), "thermal"), "Pi: within 10 °C of critical");+ put("/sys/class/thermal/thermal_zone0/temp", "70000\n");+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "2\n"); /* capped now */+ lb_cond_read(root, &c1);+ ev = lb_rpi_watch(&pw, &c1);+ CHECK(ev == LB_RPI_CAPPED && !strcmp(lb_cond_stop(&c0, &c1, ev, 1), "throttled"), "Pi: frequency capped now: throttled (%#x)", ev);+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "0\n");+ lb_cond_read(root, &c1);+ lb_rpi_watch(&pw, &c1);+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "c0000\n"); /* throttled and soft limit, between two reads */+ lb_cond_read(root, &c1);+ ev = lb_rpi_watch(&pw, &c1);+ CHECK(ev == (LB_RPI_THROTTLED | LB_RPI_SOFTTEMP) && lb_cond_stop(&c0, &c1, ev, 1), "Pi: sticky bits set during the run count (%#x)", ev);+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "10000\n"); /* under-voltage only */lb_cond_read(root, &c1);- CHECK(c1.rpi_throttled == 0x50005, "Pi flags %#x", c1.rpi_throttled);- CHECK(lb_cond_stop(&c0, &c1, 1) && !strcmp(lb_cond_stop(&c0, &c1, 1), "throttled"), "Pi: throttled now");- put("/sys/devices/platform/soc/soc:firmware/get_throttled", "50000\n"); /* only "since boot" bits */- put("/sys/class/hwmon/hwmon0/name", "rpi_volt\n");- put("/sys/class/hwmon/hwmon0/in0_lcrit_alarm", "1\n");+ ev = lb_rpi_watch(&pw, &c1);+ CHECK(ev == LB_RPI_UV && !lb_cond_stop(&c0, &c1, ev, 1), "Pi: under-voltage alone is no stop (%#x)", ev);+ CHECK(pw.seen == (LB_RPI_UV | LB_RPI_CAPPED | LB_RPI_THROTTLED | LB_RPI_SOFTTEMP | LB_RPI_HOT), "Pi: the run's record (101 °C was hot too) %#x", pw.seen);+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "50005 junk\n");lb_cond_read(root, &c1);- CHECK(!lb_cond_stop(&c0, &c1, 1) && (c1.rpi_throttled & LB_RPI_UV), "Pi: past events and under-voltage recorded, not a stop (%#x)", c1.rpi_throttled);+ CHECK(c1.rpi_throttled == -1 && !lb_rpi_watch(&pw, &c1), "Pi: a malformed get_throttled is unknown, not an event");/* ---- boot history ---- */char bt[] = "/tmp/lordbench-boots-XXXXXX";diff --git a/server/tests/sysinfo_perf_test.mjs b/server/tests/sysinfo_perf_test.mjsindex 130d990..22fb7ff 100644--- a/server/tests/sysinfo_perf_test.mjs+++ b/server/tests/sysinfo_perf_test.mjs@@ -1,7 +1,7 @@// sysinfo_perf_test.mjs — LordBench's model (apps/sysinfo/perf.js, 0.8.6): ratios against the reference// machines, category means, the stability and compatibility verdicts, comparisons with the previous// result and the conditions that differ. Run by tests/run_suites.sh (needs node).-import { CATEGORIES, DESKTOP_CATEGORIES, SANDBOX_TRIES, ENGINE_IDS, desktopVerdict, REFERENCES, ratio, categoryRatios, comparableReferences, stability, compatibilityVerdict, conditionDiffs, changes, sustainedSeries, refreshBudget, fileName } from '../../apps/sysinfo/perf.js';+import { CATEGORIES, DESKTOP_CATEGORIES, SANDBOX_TRIES, ENGINE_IDS, desktopVerdict, REFERENCES, ratio, categoryRatios, comparableReferences, stability, compatibilityVerdict, conditionDiffs, changes, sustainedSeries, refreshBudget, fileName, piFirmware } from '../../apps/sysinfo/perf.js';let n = 0, bad = 0;const eq = (what, got, want) => {@@ -48,6 +48,17 @@ eq('thermal stop', stability(res({ status: 'stopped', stopReason: 'thermal' })).eq('throttle counters grew', stability(res({ before: { throttleEvents: 2 }, after: { throttleEvents: 5 } })).notes, [{ id: 'throttleSeen', vars: { count: 3 } }]);eq('Pi throttling and under-voltage', stability(res({ after: { rpiThrottled: 0x50005 } })).notes.map((x) => x.id), ['piThrottled', 'underVoltage']);eq('Pi: only past events', stability(res({ after: { rpiThrottled: 0x50000 } })).state, 'pass');+// the Pi firmware during the run (piFirmware), which replaces the end's bits when present+const pi5 = (over) => ({ flags: false, voltageAlarm: true, underVoltage: false, tempLimit: false, tempLimitC: 80, ...over });+eq('Pi 5: nothing during the run', stability(res({ piFirmware: pi5({}) })), { state: 'pass', notes: [] });+eq('Pi 5: under-voltage during the run', stability(res({ piFirmware: pi5({ underVoltage: true }) })).notes.map((x) => x.id), ['underVoltage']);+eq('Pi 5: the firmware temperature limit', stability(res({ piFirmware: pi5({ tempLimit: true }) })).notes, [{ id: 'piTempLimit', vars: { temp: 80 } }]);+eq('Pi: capped with flags, limit not said twice', stability(res({ piFirmware: { flags: true, voltageAlarm: false, underVoltage: true, capped: true, throttled: false, softLimit: false, tempLimit: true, tempLimitC: 80 } })).notes.map((x) => x.id),+ ['piThrottled', 'underVoltage']);+eq('Pi: piFirmware wins over the end\'s bits', stability(res({ after: { rpiThrottled: 0x5 }, piFirmware: pi5({}) })).state, 'pass');+eq('piFirmware events', piFirmware(res({ piFirmware: { flags: true, voltageAlarm: true, underVoltage: true, capped: false, throttled: 'yes', softLimit: true, tempLimit: false, tempLimitC: 80 } })),+ { flags: true, voltageAlarm: true, tempLimitC: 80, events: ['underVoltage', 'softLimit'] });+eq('piFirmware: not a Pi', piFirmware(res()), null);eq('sustained dropped 20 %', stability(res({ results: { 'sustained.start': { value: 50 }, 'sustained.end': { value: 40 } } })).notes, [{ id: 'sustainedDrop', vars: { pct: 20 } }]);eq('not quiet', stability(res({ quiet: { quiet: false, busyPct: 37.4 } })).notes, [{ id: 'notQuiet', vars: { pct: 37 } }]);// the helper-sandbox self-test