From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758214Ab3APDav (ORCPT ); Tue, 15 Jan 2013 22:30:51 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:60886 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756830Ab3APDat (ORCPT ); Tue, 15 Jan 2013 22:30:49 -0500 MIME-Version: 1.0 In-Reply-To: <20130116025251.GM2668@htj.dyndns.org> References: <20130115183204.GE2668@htj.dyndns.org> <20130115235043.GJ2668@htj.dyndns.org> <20130116025251.GM2668@htj.dyndns.org> Date: Wed, 16 Jan 2013 11:30:46 +0800 Message-ID: Subject: Re: [PATCH] module, async: async_synchronize_full() on module init iff async is used From: Ming Lei To: Tejun Heo Cc: Linus Torvalds , Alex Riesen , Alan Stern , Jens Axboe , USB list , Linux Kernel Mailing List , Arjan van de Ven , Rusty Russell Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 16, 2013 at 10:52 AM, Tejun Heo wrote: > If the default iosched is built as module, the kernel may deadlock > while trying to load the iosched module on device probe if the probing > was running off async. This is because async_synchronize_full() at > the end of module init ends up waiting for the async job which > initiated the module loading. > > async A modprobe > > 1. finds a device > 2. registers the block device > 3. request_module(default iosched) > 4. modprobe in userland > 5. load and init module > 6. async_synchronize_full() > > Async A waits for modprobe to finish in request_module() and modprobe > waits for async A to finish in async_synchronize_full(). > > Because there's no easy to track dependency once control goes out to > userland, implementing properly nested flushing is difficult. For > now, make module init perform async_synchronize_full() iff module init > has queued async jobs as suggested by Linus. > > This avoids the described deadlock because iosched module doesn't use > async and thus wouldn't invoke async_synchronize_full(). This is > hacky and incomplete. It will deadlock if async module loading nests; > however, this works around the known problem case and seems to be the > best of bad options. > > For more details, please refer to the following thread. > > http://thread.gmane.org/gmane.linux.kernel/1420814 > > Signed-off-by: Tejun Heo > Reported-by: Alex Riesen > Cc: Linus Torvalds > --- Looks it does fix the deadlock problem on my Pandaboard, also the scsi disk device node(/dev/sdX) comes just after loading module of 'sd_mod'. Tested-by: Ming Lei Thanks, -- Ming Lei