]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/efivars: read EFI variables using one read(), not two
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 9 Sep 2025 09:39:35 +0000 (11:39 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 13 Oct 2025 08:04:47 +0000 (10:04 +0200)
commit1579c0717a7a0d157945e4ee74986d49d8dd345b
tree8c92b702270eccc0b21a3756b80262f915474b04
parentdfe0eec246ef6beea784ba8cb5c725d69e746571
basic/efivars: read EFI variables using one read(), not two

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 readv().

(cherry picked from commit 9db9d6806e398465a6366dfc5bdde2e24338ac29)
(cherry picked from commit 61e8972bfceba0090ce297d8e30a7eafa47db074)
src/basic/efivars.c