Skip to content

Commit

Permalink
elevator: do not request_module if elevator exists
Browse files Browse the repository at this point in the history
Whenever an I/O elevator is changed, the system attempts to load a
module for the new elevator. This occurs regardless of whether the
elevator is already loaded or built directly into the kernel. This
behavior introduces unnecessary overhead and potential issues.

This makes the operation slower, and more error-prone. For instance,
making the problem fixed by [1] visible for users that doesn't even rely
on modules being available through modules.

Do not try to load the ioscheduler if it is already visible.

This change brings two main benefits: it improves the performance of
elevator changes, and it reduces the likelihood of errors occurring
during this process.

[1] Commit e3accac ("block: Fix elv_iosched_local_module handling of "none" scheduler")

Fixes: 734e1a8 ("block: Prevent deadlocks when switching elevators")
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://lore.kernel.org/r/20241011170122.3880087-1-leitao@debian.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
leitao authored and axboe committed Oct 11, 2024
1 parent 1e3fc20 commit b4ff6e9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,21 @@ int elv_iosched_load_module(struct gendisk *disk, const char *buf,
size_t count)
{
char elevator_name[ELV_NAME_MAX];
struct elevator_type *found;
const char *name;

if (!elv_support_iosched(disk->queue))
return -EOPNOTSUPP;

strscpy(elevator_name, buf, sizeof(elevator_name));
name = strstrip(elevator_name);

request_module("%s-iosched", strstrip(elevator_name));
spin_lock(&elv_list_lock);
found = __elevator_find(name);
spin_unlock(&elv_list_lock);

if (!found)
request_module("%s-iosched", name);

return 0;
}
Expand Down

0 comments on commit b4ff6e9

Please sign in to comment.