From: Zbigniew Jędrzejewski-Szmek Date: Sun, 31 May 2020 10:16:57 +0000 (+0200) Subject: basic/efivars: try re-reading efivars without delay first X-Git-Tag: v246-rc1~220 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eee9b30af41d2b3a265ad303234ac62bb46b7cd3;p=thirdparty%2Fsystemd.git basic/efivars: try re-reading efivars without delay first Quoting https://github.com/systemd/systemd/issues/14828#issuecomment-635212615: > [kernel uses] msleep_interruptible() and that means when the process receives > any kind of signal masked or not this will abort with EINTR. systemd-logind > gets signals from the TTY layer all the time though. > Here's what might be happening: while logind reads the EFI stuff it gets a > series of signals from the TTY layer, which causes the read() to be aborted > with EINTR, which means logind will wait 50ms and retry. Which will be > aborted again, and so on, until quite some time passed. If we'd not wait for > the 50ms otoh we wouldn't wait so long, as then on each signal we'd > immediately retry again. --- diff --git a/src/basic/efivars.c b/src/basic/efivars.c index 7cff8045448..3954bd62f5c 100644 --- a/src/basic/efivars.c +++ b/src/basic/efivars.c @@ -25,7 +25,8 @@ #if ENABLE_EFI /* Reads from efivarfs sometimes fail with EINTR. Retry that many times. */ -#define EFI_N_RETRIES 5 +#define EFI_N_RETRIES_NO_DELAY 20 +#define EFI_N_RETRIES_TOTAL 25 #define EFI_RETRY_DELAY (50 * USEC_PER_MSEC) char* efi_variable_path(sd_id128_t vendor, const char *name) { @@ -101,10 +102,11 @@ int efi_get_variable( log_debug_errno(errno, "Reading from \"%s\" failed: %m", p); if (errno != EINTR) return -errno; - if (try >= EFI_N_RETRIES) + if (try >= EFI_N_RETRIES_TOTAL) return -EBUSY; - (void) usleep(EFI_RETRY_DELAY); + if (try >= EFI_N_RETRIES_NO_DELAY) + (void) usleep(EFI_RETRY_DELAY); } if (n != sizeof(a))