Bug 2539078

Summary: thermald can start before Intel RAPL sysfs is available during boot
Product: [Fedora] Fedora Reporter: Dany <dnup>
Component: thermaldAssignee: Kate Hsuan <hpa>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 44CC: ali.koroglu, benjamin-fedora, besser82, hpa, lx, ngompa13
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: thermald-2.5.13-2.fc46 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2026-10-27 06:21:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dany 2026-09-23 01:31:18 UTC
## Summary

`thermald` can start before the Intel RAPL sysfs interface is available during boot.

On an Acer Nitro AN515-57 with an Intel Core i7-11800H, the availability of `/sys/class/powercap/intel-rapl/intel-rapl:0` is not deterministic during boot. In one boot, RAPL became available approximately 1.54 seconds after the `thermald` service startup sequence began; in another boot, it was already available almost immediately.

When `thermald` starts before RAPL is registered, it reports:

```
NO RAPL sysfs present
```

Delaying `thermald` until the RAPL sysfs directory exists prevents the problem.

## Hardware

* Laptop: Acer Nitro AN515-57
* CPU: Intel Core i7-11800H
* GPU: NVIDIA GeForce RTX 3050 Laptop GPU
* BIOS: InsydeH2O V1.17
* RAM: 16 GB DDR4
* SSD: WD PC SN530 NVMe

## Software

* Fedora Linux 44
* thermald: `2.5.12-3.fc44.x86_64`
* systemd: `259.9-1.fc44.x86_64`
* Kernel currently tested: `7.2.6-200.fc44.x86_64`
* Desktop: KDE Plasma 6.7.x
* Wayland

## Problem

The systemd unit for `thermald` does not appear to have an ordering dependency on the Intel RAPL sysfs interface.

The relevant RAPL path is:

```
/sys/class/powercap/intel-rapl/intel-rapl:0
```

During some boots, `thermald` reaches its startup before this path exists.

The result is that `thermald` can report:

```
NO RAPL sysfs present
```

This appears to be timing-dependent: the RAPL interface can become available at different points during boot.

## Reproduction / measurements

I added temporary instrumentation to the existing `thermald` `ExecStartPre` so that it recorded:

1. when the pre-start check began
2. when `/sys/class/powercap/intel-rapl/intel-rapl:0` became available

### Boot 1

The recorded timestamps were:

```
1790122559.417600942
1790122560.961810163
```

Difference:

```
~1.544 seconds
```

This means that during this boot, the RAPL sysfs interface appeared approximately 1.54 seconds after the `thermald` pre-start check began.

### Boot 2

The recorded timestamps were:

```
1790125437.686035300
1790125437.688092620
```

Difference:

```
~0.002 seconds
```

In this boot, RAPL was already available almost immediately.

### thermald startup during Boot 2

The corresponding `thermald` journal was:

```
[   5.598834] Nitro5 systemd[1]: Starting thermald.service - Thermal Daemon Service...
[   5.619320] Nitro5 thermald[893]: 27 CPUID levels; family:model:stepping 0x6:8d:1 (6:141:1)
[   6.008567] Nitro5 thermald[893]: 27 CPUID levels; family:model:stepping 0x6:8d:1 (6:141:1)
[   6.014196] Nitro5 thermald[893]: Polling mode is enabled: 4
[   6.015349] Nitro5 systemd[1]: Started thermald.service - Thermal Daemon Service.
```

In this boot there was no `NO RAPL sysfs present` message and `thermald` started successfully.

## Workaround

I currently use the following systemd drop-in:

```
/etc/systemd/system/thermald.service.d/20-startup.conf
```

with:

```
[Service]
TimeoutStartSec=15s
TimeoutStopSec=15s
ExecStartPre=/bin/sh -c 'for i in $(seq 1 300); do [ -e /sys/class/powercap/intel-rapl/intel-rapl:0 ] && exit 0; sleep 0.05; done; exit 1'
```

This waits for the Intel RAPL sysfs interface to become available before allowing `thermald` itself to start.

With this workaround, `thermald` starts normally and the `NO RAPL sysfs present` condition is avoided.

## Additional observations

The RAPL interface is fully functional once it has been registered. The directory contains the expected files, including:

```
constraint_0_max_power_uw
constraint_0_name
constraint_0_power_limit_uw
constraint_0_time_window_us
constraint_1_max_power_uw
constraint_1_name
constraint_1_power_limit_uw
constraint_1_time_window_us
enabled
energy_uj
name
power
```

The system also reports the expected RAPL power limits after boot.

The current `thermald.service` ordering does not explicitly wait for the RAPL sysfs interface. The service is ordered after system initialization, D-Bus, etc., but there does not appear to be an explicit dependency or ordering relationship with the registration of Intel RAPL.

## Expected behavior

`thermald` should either:

1. start only after the Intel RAPL sysfs interface required by its configuration is available, or
2. handle the temporary absence of RAPL gracefully and retry its initialization without failing or entering a problematic startup/stop state.

## Actual behavior

Depending on boot timing, `thermald` can start before:

```
/sys/class/powercap/intel-rapl/intel-rapl:0
```

exists, resulting in:

```
NO RAPL sysfs present
```

The timing is not deterministic between boots.

## Possible cause

This appears consistent with a boot-time race between the registration of Intel RAPL by the kernel and the startup of `thermald`.

I cannot determine from these observations whether the appropriate fix belongs in `thermald`, the systemd unit dependencies, or the kernel/RAPL initialization ordering.

The important observation is that delaying `thermald` until the RAPL sysfs interface exists reliably avoids the problem.

## Request

Could the `thermald` maintainers investigate whether the Fedora systemd unit should explicitly handle the availability of Intel RAPL, or whether `thermald` should tolerate RAPL appearing after the daemon starts?

I can provide additional boot logs, `systemd-analyze` output, or other diagnostic information if needed.


Reproducible: Sometimes

Steps to Reproduce:
1. Boot Fedora 44 on the affected system.
2. Start thermald during normal system boot.
3. Observe whether /sys/class/powercap/intel-rapl/intel-rapl:0 exists when thermald starts.
4. On affected boots, thermald can report "NO RAPL sysfs present".
5. Adding an ExecStartPre delay that waits for the RAPL sysfs path to exist prevents the issue.1.

Actual Results:
Depending on boot timing, thermald can start before the Intel RAPL sysfs interface exists and report "NO RAPL sysfs present".

The timing is not deterministic. In one measured boot, RAPL became available approximately 1.54 seconds after the thermald startup pre-check began. In another boot, it was available after approximately 2 milliseconds.

Expected Results:
thermald should either start after the Intel RAPL interface required by it is available, or gracefully wait/retry if RAPL has not yet been registered by the kernel.

Additional Information:
Hardware:
Acer Nitro AN515-57
Intel Core i7-11800H
BIOS InsydeH2O V1.17

Software:
Fedora Linux 44
thermald-2.5.12-3.fc44.x86_64
systemd-259.9-1.fc44.x86_64
Kernel 7.2.6-200.fc44.x86_64

The Intel RAPL sysfs interface is fully functional after boot.

Current workaround:
An ExecStartPre in /etc/systemd/system/thermald.service.d/20-startup.conf waits for /sys/class/powercap/intel-rapl/intel-rapl:0 before starting thermald.

This workaround consistently prevents the "NO RAPL sysfs present" condition.

Comment 1 Dany 2026-09-24 02:39:07 UTC
### Additional investigation / updated findings

I performed additional boot-time testing after filing this report.

The original observation of a race between Intel RAPL registration and thermald startup is reproducible. However, the subsequent testing also revealed that the systemd timeouts are an important part of the resulting failure.

On the affected system, the vendor/systemd configuration originally showed:

```text
TimeoutStartUSec=1s
TimeoutStopUSec=1s
```

When thermald starts before the Intel RAPL sysfs interface is available, it reports:

```text
NO RAPL sysfs present
```

The first thermald startup can then take longer than the 1-second systemd start timeout:

```text
thermald.service: start operation timed out. Terminating.
```

Thermald does not terminate within the following 1-second stop timeout either:

```text
thermald.service: State 'stop-sigterm' timed out. Aborting.
thermald.service: Killing process ... with signal SIGABRT.
```

This produces the observed thermald coredump.

The coredump from the current thermald version was consistent with the process being interrupted while handling the termination signal, rather than with an independent spontaneous crash.

I also measured the RAPL race directly with temporary systemd instrumentation.

In one boot, `/sys/class/powercap/intel-rapl/intel-rapl:0` appeared approximately 1.54 seconds after the pre-start check began.

In another boot, it was available approximately 2 ms after the check began.

In a further boot, the relevant monotonic timestamps were:

```text
[5.530708] systemd[1]: Starting thermald.service
[5.540698] thermald-race: RAPL available
[5.939576] systemd[1]: Started thermald.service
```

So RAPL became available approximately 10 ms after the thermald service startup sequence began in that boot.

This confirms that the issue is a genuine boot-time ordering/race condition, but that the timing varies significantly between boots.

As a workaround, I currently use:

```ini
[Service]
TimeoutStartSec=15s
TimeoutStopSec=15s
ExecStartPre=/bin/sh -c 'for i in $(seq 1 300); do [ -e /sys/class/powercap/intel-rapl/intel-rapl:0 ] && exit 0; sleep 0.05; done; exit 1'
```

This waits for the Intel RAPL sysfs interface before starting thermald.

I have tested this workaround across a real reboot. With the workaround enabled:

* thermald starts successfully;
* the `NO RAPL sysfs present` message is avoided;
* no thermald startup timeout occurs;
* no thermald coredump is generated.

Based on these additional observations, the problem appears to involve two related issues:

1. thermald can be started before the Intel RAPL sysfs interface required by its initialization is registered;
2. the Fedora systemd service has a 1-second startup/stop timeout, which is shorter than the observed initialization/termination time on this system.

I am not sure whether the preferred fix should be in thermald itself, the Fedora systemd unit, or the kernel/RAPL initialization ordering.

Possible fixes would be either:

* make thermald tolerate RAPL appearing after daemon startup and retry initialization; or
* add an appropriate systemd dependency/ordering mechanism for the required RAPL interface; and/or
* increase the thermald service startup/stop timeout so that a slow initialisation does not result in forced SIGABRT termination.

The important point is that waiting for `/sys/class/powercap/intel-rapl/intel-rapl:0` before starting thermald reliably eliminates the observed failure on this hardware.

Comment 2 Kate Hsuan 2026-10-06 05:46:11 UTC
Hi

Thank you for reporting the issue.

You can try
1. Add a new udev rules to tag rapl when it is loaded.

Add a new rule called 99-thermald-powercap.rules and place it in /etc/udev/rules.d

$cat <<EOF > /etc/udev/rules.d/99-thermald-powercap.rules
SUBSYSTEM=="powercap", TAG+="systemd"
EOF

2. add `After=sys-class-powercap.device` in the [Unit] section in /usr/lib/systemd/system/thermald.service

For example:
[Unit]
Description=Thermal Daemon Service
ConditionVirtualization=no
After=sys-class-powercap.device

3. reboot

If it works, I'll submit the fix to the upstream.

Comment 3 Dany 2026-10-08 19:12:39 UTC
Hi Kate,

I tested your proposed fix on my Acer Nitro 5 running Fedora 44, and it works successfully.

I added:

`/etc/udev/rules.d/99-thermald-powercap.rules`

```udev
SUBSYSTEM=="powercap", TAG+="systemd"
```

and used a systemd drop-in:

`/etc/systemd/system/thermald.service.d/10-powercap.conf`

```ini
[Unit]
After=sys-class-powercap.device
```

I removed my previous `ExecStartPre` workaround completely and tested the system with three consecutive reboots.

All three boots were successful:

* `thermald.service` started normally and remained `active (running)`.
* `/sys/class/powercap/intel-rapl/intel-rapl:0` was available on every boot.
* No RAPL/powercap startup errors appeared in the journal.
* The journal consistently showed `Started thermald.service`.
* The old polling workaround is no longer needed.

So, at least on my Nitro 5, your proposed udev + systemd dependency solution appears to fix the startup issue reliably.

Thanks for working on this and for providing the workaround!

Comment 4 Kate Hsuan 2026-10-12 03:17:10 UTC
Thank you for the test.

I'll submit the fix to the upstream and update the package with this solution shortly.

Comment 5 Fedora Update System 2026-10-27 06:18:28 UTC
FEDORA-2026-7912139c40 (thermald-2.5.13-2.fc46) has been submitted as an update to Fedora 46.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-7912139c40

Comment 6 Fedora Update System 2026-10-27 06:21:20 UTC
FEDORA-2026-7912139c40 (thermald-2.5.13-2.fc46) has been pushed to the Fedora 46 stable repository.
If problem still persists, please make note of it in this bug report.