]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/efivars: read EFI variables using one read(), not two (#38864)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 18 Sep 2025 03:03:30 +0000 (12:03 +0900)
committerGitHub <noreply@github.com>
Thu, 18 Sep 2025 03:03:30 +0000 (12:03 +0900)
commit6f1bc004e9f96704e34e6f45da34821fe1469d54
treea4257d47c30e011db3726f0e7b43a6b80f3eb8d2
parent46869e32cd63c200a97087c00078748de6725e1f
parent4125e0c3db9fd8a2102781674db7aae263714aec
basic/efivars: read EFI variables using one read(), not two (#38864)

In https://github.com/systemd/systemd/issues/38842 it is reported that
we're again having trouble accessing EFI variables:
```
  [  292.212415] H (udev-worker)[253]: Reading EFI variable /sys/firmware/efi/efivars/LoaderDevicePartUUID-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f.
  ...
  [  344.397961] H (udev-worker)[253]: Detected slow EFI variable read access on LoaderDevicePartUUID-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f: 52.185510s
```

We don't know what causes the slowdown, but it seems reasonable to avoid
unnecessary read() calls. We would read the 4-byte attr first, and then
the actual value later. But our code always reads the value (and
discards the attr in all cases except one, when _writing_ the variable),
so let's optimize for the case where we read the value and read the
whole contents in one read().