lib: Remove module auto-unloading which encourages inconsistent behaviour
Subsystems (2)
PATCH 2/2 lib: Remove module auto-unloading which encourages inconsistent behaviour
The module auto-unload might seem like a nice optimization, but it encourages inconsistent behaviour. And behaviour that is different from all other normal modules.
rbtree_test.c and percpu_test.c returns -EAGAIN from module_init() on successful completion. Normal module return 0 on success but returning -EAGAIN perform auto module unloading which seem like a nice optimization but it brings inconsistent behaviour as well.
I face the similar problem in my previous patch, "Paul Gortmaker" gives nice review comment on module auto-unloading brings inconsistent behaviour.
Imagine something as simple as this:
for i in $LIST ; do
modprobe $i
lsmod | grep -q $i
if [ $? != 0 ]; then echo Module $i is not present! ; fi
done
OK, not ideal code, ignoring the modprobe return -- but what it reports is true --rbtree_test.c and percpu_test.c test module (if it passed) will NOT be present.
All other modules from linux/lib/* follow the same semantics that module_init() returns 0 on successful completion & let external entity like rmmod do the module unloading task.
--- lib/percpu_test.c | 3 ++- lib/rbtree_test.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
lib/percpu_test.c +2 -1
@@ -123,7 +123,8 @@ static int __init percpu_test_init(void)preempt_enable ();pr_info ("percpu test done\n" ); -return -EAGAIN ;/* Fail will directly unload the module */ + +return 0 ; } static void __exit percpu_test_exit(void)
lib/rbtree_test.c +1 -1
@@ -394,7 +394,7 @@ static int __init rbtree_test_init(void)kfree (nodes); -return -EAGAIN ;/* Fail will directly unload the module */ +return 0 ; } static void __exit rbtree_test_exit(void)
Signature · 1 line
2.7.4
Quoted 21 lines · Pravin Shedge
The module auto-unload might seem like a nice optimization, but it encourages inconsistent behaviour. And behaviour that is different from all other normal modules.
rbtree_test.candpercpu_test.creturns-EAGAINfrommodule_init()on successful completion. Normal module return 0 on success but returning-EAGAINperform auto module unloading which seem like a nice optimization but it brings inconsistent behaviour as well.I face the similar problem in my previous patch, "Paul Gortmaker" gives nice review comment on module auto-unloading brings inconsistent behaviour.
Imagine something as simple as this:
for i in $LIST ; do
modprobe $i
lsmod | grep -q $i
if [ $? != 0 ]; then echo Module $i is not present! ; fi
done
Quoted 9 lines
OK, not ideal code, ignoring the modprobe return -- but what it reports is true --
rbtree_test.candpercpu_test.ctest module (if it passed) will NOT be present.All other modules from linux/lib/* follow the same semantics that
module_init()returns 0 on successful completion & let external entity like rmmod do the module unloading task.
Quoted 36 lines
Signed-off-by Pravin Shedge <[email protected]>--- lib/percpu_test.c | 3 ++- lib/rbtree_test.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)lib/percpu_test.c +2
-1@@ -123,7 +123,8 @@ static int __init percpu_test_init(void)preempt_enable ();pr_info ("percpu test done\n" ); -return -EAGAIN ;/* Fail will directly unload the module */ + +return 0 ; } static void __exit percpu_test_exit(void)lib/rbtree_test.c +1
-2@@ -394,7 +394,7 @@ static int __init rbtree_test_init(void)kfree (nodes); -return -EAGAIN ;/* Fail will directly unload the module */ +return 0 ; } static void __exit rbtree_test_exit(void) --2.7.4
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 28 lines · Andy Shevchenko
Quoted 26 lines · Pravin Shedge
The module auto-unload might seem like a nice optimization, but it encourages inconsistent behaviour. And behaviour that is different from all other normal modules.
rbtree_test.candpercpu_test.creturns-EAGAINfrommodule_init()on successful completion. Normal module return 0 on success but returning-EAGAINperform auto module unloading which seem like a nice optimization but it brings inconsistent behaviour as well.I face the similar problem in my previous patch, "Paul Gortmaker" gives nice review comment on module auto-unloading brings inconsistent behaviour.
Imagine something as simple as this:
for i in $LIST ; do
modprobe $i
lsmod | grep -q $i
if [ $? != 0 ]; then echo Module $i is not present! ; fi
doneOK, not ideal code, ignoring the modprobe return -- but what it reports is true --
rbtree_test.candpercpu_test.ctest module (if it passed) will NOT be present.
Quoted 6 lines
Quoted 4 lines
All other modules from linux/lib/* follow the same semantics that
module_init()returns 0 on successful completion & let external entity like rmmod do the module unloading task.Suggested-by Andrew ... ?
Hi Andy,
Please check the reference patch "[PATCH] lib: add module unload support to sort tests" this patch was added for lib/test_sort.c file. test_sort.c missing unloading feature so I added auto-unload feature for the same. But after reviewers comment I am agree on the part that module auto-unload feature will break the consistency from users point of view.
The reviewers for this patch are Andrew, Paul Gortmaker.
Thanks & Regards,
PraviN
Quoted 43 lines
Quoted 35 lines
Signed-off-by Pravin Shedge <[email protected]>--- lib/percpu_test.c | 3 ++- lib/rbtree_test.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)lib/percpu_test.c +2
-1@@ -123,7 +123,8 @@ static int __init percpu_test_init(void)preempt_enable ();pr_info ("percpu test done\n" ); -return -EAGAIN ;/* Fail will directly unload the module */ + +return 0 ; } static void __exit percpu_test_exit(void)lib/rbtree_test.c +1
-2@@ -394,7 +394,7 @@ static int __init rbtree_test_init(void)kfree (nodes); -return -EAGAIN ;/* Fail will directly unload the module */ +return 0 ; } static void __exit rbtree_test_exit(void) --Quoted 2 lines
2.7.4
--
With Best Regards,
Andy Shevchenko