mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-28 23:19:03 +02:00
util/nvmutil: usleep 1 on check_read_or_die
This prevents hogging the CPU in a tight loop, while waiting for access. I've also reduced the number of tries to 30, rather than 200. This is more conservative, while still being somewhat permissive. The addition of the usleep delay probably makes this more reliable than the previous behaviour of quickly spinning through 200 tries, but without hogging CPU resources. I *could* allow this loop to be infinite, but I regard infinite spin-lock as an error state. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -60,7 +60,7 @@ static void set_err(int);
|
||||
#define SIZE_16KB 0x4000
|
||||
#define SIZE_128KB 0x20000
|
||||
|
||||
#define MAX_RETRY_READ 200
|
||||
#define MAX_RETRY_READ 30
|
||||
|
||||
#define items(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
@@ -446,6 +446,9 @@ check_read_or_die(const char *rpath, ssize_t rval, size_t rsize,
|
||||
err(EINTR, "%s: max retries exceeded on file: %s",
|
||||
readtype, rpath);
|
||||
|
||||
/* Prevent CPU hog when on spin-locked reads. */
|
||||
usleep(1);
|
||||
|
||||
/*
|
||||
* Bad read, with errno EINTR (syscall interrupted).
|
||||
* Reset the error state and try again.
|
||||
|
||||
Reference in New Issue
Block a user