Re: [PATCH] module, async: async_synchronize_full() on module initiff async is used

From: Ming Lei
Date: Tue Jan 15 2013 - 22:30:34 EST


On Wed, Jan 16, 2013 at 10:52 AM, Tejun Heo <tj@xxxxxxxxxx> 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 <tj@xxxxxxxxxx>
> Reported-by: Alex Riesen <raa.lkml@xxxxxxxxx>
> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> ---

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 <ming.lei@xxxxxxxxxxxxx>

Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/