modules: insert mods sorted
PATCH 1/1 modules: insert mods sorted
While there isn't a big difference between typing 'lsmod' and 'lsmod | sort', the module listing in Oopses isn't so easily sorted. Attempting to search these quickly by eye for particular modules while rapidly triaging bugs can be a pain. Sort the list and reduce the pain.
--- kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
kernel/module.c +8 -2
@@ -3146,7 +3146,7 @@ static int may_init_module(void)static int add_unformed_module (struct module *mod) {int err; -struct module *old; +struct module *old, *m; mod->state =MODULE_STATE_UNFORMED ;
@@ -3166,7 +3166,13 @@ again: err = -EEXIST ; goto out; } -list_add_rcu (&mod->list, &modules); +if (!list_empty (&modules)) { +list_for_each_entry (m, &modules, list) +if (strcmp (mod->name, m->name) <0 ) +break ; +list_add_tail_rcu (&mod->list, &m->list); + }else +list_add_rcu (&mod->list, &modules); err =0 ; out:
Signature · 1 line
1.8.1.4
Quoted 41 lines · Andrew Jones
While there isn't a big difference between typing 'lsmod' and 'lsmod | sort', the module listing in Oopses isn't so easily sorted. Attempting to search these quickly by eye for particular modules while rapidly triaging bugs can be a pain. Sort the list and reduce the pain.
Signed-off-by Andrew Jones <[email protected]>--- kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)kernel/module.c +8
-2@@ -3146,7 +3146,7 @@ static int may_init_module(void)static int add_unformed_module (struct module *mod) {int err; -struct module *old; +struct module *old, *m; mod->state =MODULE_STATE_UNFORMED ;@@ -3166,7 +3166,13 @@ again: err = -EEXIST ; goto out; } -list_add_rcu (&mod->list, &modules); +if (!list_empty (&modules)) { +list_for_each_entry (m, &modules, list) +if (strcmp (mod->name, m->name) <0 ) +break ; +list_add_tail_rcu (&mod->list, &m->list); + }else +list_add_rcu (&mod->list, &modules); err =0 ; out:Signature · 1 line
1.8.1.4
self-nacking. Tons of docs and tools exist expecting this list in reverse load order. I'll blame the momentary insanity the drove me to post this patch on having to triage too many bugs...
drew
Quoted 6 lines · Andrew Jones
While there isn't a big difference between typing 'lsmod' and 'lsmod | sort', the module listing in Oopses isn't so easily sorted. Attempting to search these quickly by eye for particular modules while rapidly triaging bugs can be a pain. Sort the list and reduce the pain.
Signed-off-by Andrew Jones <[email protected]>
Hi Andrew,
ISTR the story of young Fleming being fired as bottlewasher for
a major lab because the head researcher felt he was wasting his talents.[1]
Please take my rejection of this patch as similar endorsement of
your future prospects.
Cheers,
Rusty.
[1] Google can't find any trace of this story, so may be my imagination...
Quoted 34 lines
--- kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)kernel/module.c +8
-2@@ -3146,7 +3146,7 @@ static int may_init_module(void)static int add_unformed_module (struct module *mod) {int err; -struct module *old; +struct module *old, *m; mod->state =MODULE_STATE_UNFORMED ;@@ -3166,7 +3166,13 @@ again: err = -EEXIST ; goto out; } -list_add_rcu (&mod->list, &modules); +if (!list_empty (&modules)) { +list_for_each_entry (m, &modules, list) +if (strcmp (mod->name, m->name) <0 ) +break ; +list_add_tail_rcu (&mod->list, &m->list); + }else +list_add_rcu (&mod->list, &modules); err =0 ; out:Signature · 1 line
1.8.1.4