Skip to content

Commit b4ff6e9

Browse files
leitaoaxboe
authored andcommitted
elevator: do not request_module if elevator exists
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 1e3fc20 commit b4ff6e9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

block/elevator.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,21 @@ int elv_iosched_load_module(struct gendisk *disk, const char *buf,
709709
size_t count)
710710
{
711711
char elevator_name[ELV_NAME_MAX];
712+
struct elevator_type *found;
713+
const char *name;
712714

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

716718
strscpy(elevator_name, buf, sizeof(elevator_name));
719+
name = strstrip(elevator_name);
717720

718-
request_module("%s-iosched", strstrip(elevator_name));
721+
spin_lock(&elv_list_lock);
722+
found = __elevator_find(name);
723+
spin_unlock(&elv_list_lock);
724+
725+
if (!found)
726+
request_module("%s-iosched", name);
719727

720728
return 0;
721729
}

0 commit comments

Comments
 (0)