* [PATCH v3] elevator: do not request_module if elevator exists
@ 2024-10-11 17:01 Breno Leitao
2024-10-11 17:11 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Breno Leitao @ 2024-10-11 17:01 UTC (permalink / raw)
To: hch, Jens Axboe, Damien Le Moal
Cc: kernel-team, open list:BLOCK LAYER, open list
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 e3accac1a976 ("block: Fix elv_iosched_local_module handling of "none" scheduler")
Fixes: 734e1a860312 ("block: Prevent deadlocks when switching elevators")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
Changelog:
v3:
* Remove the helper, since it is not used anywhere else (Jens)
v2:
* Protect __elevator_find() by elv_list_lock (Christoph Hellwig)
* https://lore.kernel.org/all/20241011154959.3198364-1-leitao@debian.org/
v1:
* https://lore.kernel.org/all/20241010141509.4028059-1-leitao@debian.org/
block/elevator.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/elevator.c b/block/elevator.c
index 565807f0b1c7..640fcc891b0d 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -708,13 +708,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;
}
--
2.43.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3] elevator: do not request_module if elevator exists
2024-10-11 17:01 [PATCH v3] elevator: do not request_module if elevator exists Breno Leitao
@ 2024-10-11 17:11 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-10-11 17:11 UTC (permalink / raw)
To: hch, Damien Le Moal, Breno Leitao; +Cc: kernel-team, linux-block, linux-kernel
On Fri, 11 Oct 2024 10:01:21 -0700, Breno Leitao wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] elevator: do not request_module if elevator exists
commit: b4ff6e93bfd0093ce3ffc7322e89fbaa8300488f
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-11 17:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-11 17:01 [PATCH v3] elevator: do not request_module if elevator exists Breno Leitao
2024-10-11 17:11 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®