From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian King Date: Mon, 12 Apr 2004 15:25:49 +0000 Subject: Re: [PATCH] call_usermodehelper hang Message-Id: <407AB4FD.4070905@us.ibm.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------050409000605020104040001" List-Id: References: <4072F2B7.2070605@us.ibm.com> <20040406172903.186dd5f1.akpm@osdl.org> <20040407061146.GA10413@kroah.com> <407487A6.8020904@us.ibm.com> <20040408224713.GD15125@kroah.com> <40770AD0.4000402@us.ibm.com> <20040409205344.GA5236@kroah.com> <20040409141511.4e372554.akpm@osdl.org> <20040410165322.GG1317@kroah.com> <20040410131137.0eff0ae2.akpm@osdl.org> To: Andrew Morton Cc: Greg KH , linux-kernel@vger.kernel.org, linux-hotplug-devel@lists.sourceforge.net This is a multi-part message in MIME format. --------------050409000605020104040001 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Andrew Morton wrote: > Greg KH wrote: > >>>The deadlock opportunity occurs during the call_usermodehelper() handoff to >> >> > keventd, which is synchronous. >> > >> > 2-3 years back I did have a call_usermodehelper() which was fully async. >> > It was pretty unpleasant because of the need to atomically allocate >> > arbitrary amounts of memory to hold the argv[] and endp[] arrays, to pass >> > them between a couple of threads and to then correctly free it all up >> > again. >> >> Ok, you've convinced me of the mess that would cause. So what should we >> do to help fix this? Serialize call_usermodehelper()? > > > May as well bring back call_usermodehelper_async() I guess. > > > There are two patches here, and they are totally untested... I loaded the patches on my ppc64 box and they worked fine after I fixed a compile bug. The attached patch fixes the compile bug and changes the call_usermodehelper call in kset_hotplug to call_usermodehelper_async. -Brian -- Brian King eServer Storage I/O IBM Linux Technology Center --------------050409000605020104040001 Content-Type: text/plain; name="call_usermodehelper_kobject.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="call_usermodehelper_kobject.patch" Fixes a compile error in call_usermodehelper_async and changes kset_hotplug to use call_usermodehelper_async, since it is called with a semaphore held, which can result in a deadlock. --- diff -puN kernel/kmod.c~call_usermodehelper_kobject kernel/kmod.c --- linux-2.6.5/kernel/kmod.c~call_usermodehelper_kobject Mon Apr 12 08:27:20 2004 +++ linux-2.6.5-bjking1/kernel/kmod.c Mon Apr 12 08:27:44 2004 @@ -296,7 +296,7 @@ int call_usermodehelper_async(char *path { struct subprocess_info *sub_info; - if (system_state != SYSTEM_RUNNING) + if (!system_running) return -EBUSY; if (path[0] == '\0') goto out; diff -puN lib/kobject.c~call_usermodehelper_kobject lib/kobject.c --- linux-2.6.5/lib/kobject.c~call_usermodehelper_kobject Mon Apr 12 08:28:07 2004 +++ linux-2.6.5-bjking1/lib/kobject.c Mon Apr 12 08:28:28 2004 @@ -187,7 +187,7 @@ static void kset_hotplug(const char *act pr_debug ("%s: %s %s %s %s %s %s %s\n", __FUNCTION__, argv[0], argv[1], envp[0], envp[1], envp[2], envp[3], envp[4]); - retval = call_usermodehelper (argv[0], argv, envp, 0); + retval = call_usermodehelper_async (argv[0], argv, envp, GFP_KERNEL); if (retval) pr_debug ("%s - call_usermodehelper returned %d\n", __FUNCTION__, retval); _ --------------050409000605020104040001-- ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel