From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756029Ab2IQLgJ (ORCPT ); Mon, 17 Sep 2012 07:36:09 -0400 Received: from ozlabs.org ([203.10.76.45]:33407 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755889Ab2IQLgG (ORCPT ); Mon, 17 Sep 2012 07:36:06 -0400 From: Rusty Russell To: Lucas De Marchi Cc: LKML , Jon Masters , linux-modules , Lucas De Marchi Subject: Re: [PATCH 2/2] module: wait when loading a module which is currently initializing. In-Reply-To: References: <87obl9rsg2.fsf@rustcorp.com.au> <87ligdrscn.fsf@rustcorp.com.au> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Mon, 17 Sep 2012 14:06:16 +0930 Message-ID: <878vc9s1tr.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lucas De Marchi writes: >> - if (find_module(mod->name)) { >> + if ((old = find_module(mod->name)) != NULL) { >> + if (old->state == MODULE_STATE_COMING) { >> + /* Wait in case it fails to load. */ >> + mutex_unlock(&module_mutex); >> + err = wait_event_interruptible(module_wq, >> + finished_loading(mod->name)); >> + if (err) >> + goto free_arch_cleanup; >> + goto again; > > I wonder if we should indeed retry in case the module failed to load > or if we should just skip straight to returning the error code. We > don't have the return code for the failed load, but maybe we can > fabricate one here. > > Thoughts? Could have different cmdline parameters, or other randomness like out-of-memory. I think this is safest. Cheers, Rusty.