From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752308AbXDQHeY (ORCPT ); Tue, 17 Apr 2007 03:34:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752314AbXDQHeY (ORCPT ); Tue, 17 Apr 2007 03:34:24 -0400 Received: from mtagate8.de.ibm.com ([195.212.29.157]:41821 "EHLO mtagate8.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259AbXDQHeW (ORCPT ); Tue, 17 Apr 2007 03:34:22 -0400 Date: Tue, 17 Apr 2007 09:36:52 +0200 From: Cornelia Huck To: Alan Stern Cc: Dmitry Torokhov , linux-kernel , Greg K-H , Tejun Heo , Rusty Russell Subject: Re: [Patch -mm 0/3] RFC: module unloading vs. release function Message-ID: <20070417093652.05030383@gondolin.boeblingen.de.ibm.com> In-Reply-To: References: Organization: IBM Deutschland Entwicklung GmbH X-Mailer: Claws Mail 2.8.0 (GTK+ 2.8.20; i486-pc-linux-gnu) X-Legal: IBM Deutschland Entwicklung GmbH Vorsitzender des Aufsichtsrats: Johann Weihen =?ISO-8859-15?Q?Gesch=E4ftsf=FChrung:?= Herbert Kircher Sitz der Gesellschaft: =?ISO-8859-15?Q?B=F6blingen?= Registergericht: Amtsgericht Stuttgart, HRB 243294 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Apr 2007 15:38:52 -0400 (EDT), Alan Stern wrote: > On Mon, 16 Apr 2007, Dmitry Torokhov wrote: > > Unfortunately all this "wait for refcount in module's exit" schemas > > lead to the following deadlock: > > > > rmmod my_module < /path/to/some/file/incrementing/my/refcount > > (Note that this problem will be a lot harder to provoke once Tejun's > changes to sysfs are in place. But it will still be possible, unless we > make similar changes to all the other filesystems as well.) > > There are three possible approaches to this problem: > > 1. Ignore it, as we do now. If someone actually tries running your > example above, an oops will result when the kobject's release > method is called after my_module has been unloaded from memory. > > 2. Do what Cornelia suggested, and allow the example to deadlock. > > 3. Change the module code so that rmmod can return _before_ the > module is actually unloaded from memory (but after the module's > exit routine has completed). This will lead to more problems. > For example, what if someone tries to modprobe my_module back > again before it has finished unloading? > > My feeling is that either a deadlock or more complications with modprobe > would be preferable to an oops. Your opinion may differ. My current preference is 2. (obviously :)). I don't like 3. too much (too complicated code), but I think it would still be better than 1. (And I agree, this will be harder to trigger with Tejun's patches.) > > (Also, doing this might be a good way to expose a lot of hidden > refcounting bugs. They will become very obvious when rmmod hangs.) Good point.