Skip to contentSkip to conversation

call_usermodehelper needs to wait longer

PATCH In review Srivatsa Vaddagiri 3 participants 4 messages Mar 9, 2004 – Mar 10, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 call_usermodehelper needs to wait longer

During my testing of call_usermodehelper, I noticed that if it is called from a workqueue function, it does really wait (when asked to) for the usermodehelper to exit.

Patch below should fix it. It has been tested against 2.6.4-rc2-mm1 on a 4-way x86 SMP box.

kmod.c 2004-03-09 18:52:38.000000000 +0530 renamed from kmod.c.org 2004-03-09 18:52:19.000000000 +0530 +6 -3
@@ -258,10 +258,13 @@
        if (current_is_keventd()) {
                /* We can't wait on keventd! */
                __call_usermodehelper(&sub_info);
-       } else {
+               if (!wait)
+                       goto out;
+       } else
                schedule_work(&work);
-               wait_for_completion(&done);
-       }
+
+       wait_for_completion(&done);
+
 out:
        return sub_info.retval;
 }
Signature · 5 lines
Thanks and Regards,
Srivatsa Vaddagiri,
Linux Technology Center,
IBM Software Labs,
Bangalore, INDIA - 560017
#1 lore raw
Quoted 17 lines · Srivatsa Vaddagiri

During my testing of call_usermodehelper, I noticed that if it is called from a workqueue function, it does really wait (when asked to) for the usermodehelper to exit.

Patch below should fix it. It has been tested against 2.6.4-rc2-mm1 on a 4-way x86 SMP box.

kmod.c 2004-03-09 18:52:38.000000000 +0530 renamed from kmod.c.org 2004-03-09 18:52:19.000000000 +0530 +2 -1
@@ -258,10 +258,13 @@
        if (current_is_keventd()) {
                /* We can't wait on keventd! */
                __call_usermodehelper(&sub_info);
-       } else {
+               if (!wait)
+                       goto out;

kmod.c 2004-03-09 18:52:38.000000000 +0530 line 270

Quoted 10 lines
kmod.c 2004-03-09 18:52:38.000000000 +0530 renamed from kmod.c.org 2004-03-09 18:52:19.000000000 +0530 +4 -2
+       } else
                schedule_work(&work);
-               wait_for_completion(&done);
-       }
+
+       wait_for_completion(&done);
+
 out:
        return sub_info.retval;
 }

I'm not so sure about this. There are deadlock potentials if the usermode application wants to perform some function which requires keventd services to complete - the application cannot complete because keventd is itself waiting for the application.

Can we think of any circumstances under which keventd _should_ synchronously wait for the userspace app?

btw: your patch had whitespace where the tabs should be (email client problem), and `patch -p1' format is (much) preferred.

#2 lore raw
Quoted 7 lines · Andrew Morton

I'm not so sure about this. There are deadlock potentials if the usermode application wants to perform some function which requires keventd services to complete - the application cannot complete because keventd is itself waiting for the application.

Can we think of any circumstances under which keventd _should_ synchronously wait for the userspace app?

Honestly I don't know ..Would it be reasonable for somebody to call request_module from a work function (in which case the above bug is exposed)? I agree it is not a nice thing if we block keventd waiting for the app to exit.

Quoted 3 lines

btw: your patch had whitespace where the tabs should be (email client problem), and `patch -p1' format is (much) preferred.

Sorry abt that! The whitespace was because of cut-n-paste ..I have also downloaded your patch scripts and will start using that for generating patches henceforth!

Signature · 5 lines
Thanks and Regards,
Srivatsa Vaddagiri,
Linux Technology Center,
IBM Software Labs,
Bangalore, INDIA - 560017
#3 lore raw
Quoted 6 lines · Srivatsa Vaddagiri
Quoted 5 lines · Andrew Morton

I'm not so sure about this. There are deadlock potentials if the usermode application wants to perform some function which requires keventd services to complete - the application cannot complete because keventd is itself waiting for the application.

Quoted 7 lines
Quoted 2 lines

Can we think of any circumstances under which keventd _should_ synchronously wait for the userspace app?

Honestly I don't know ..Would it be reasonable for somebody to call request_module from a work function (in which case the above bug is exposed)? I agree it is not a nice thing if we block keventd waiting for the app to exit.

I think a BUG_ON(wait) is arguably right here: anyone trying it will hit it immediately. Perhaps a "/* keventd shouldn't block */" comment above it would help.

Cheers,

Signature · 1 line
Anyone who quotes me in their signature is an idiot -- Rusty Russell