public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Jiri Slaby <jslaby@suse.cz>
Cc: linux-kernel@vger.kernel.org, "v2 . 6 . 21+" <stable@vger.kernel.org>
Subject: Re: [PATCH] base: make module_create_drivers_dir race-free
Date: Fri, 10 Jun 2016 09:25:30 -0700	[thread overview]
Message-ID: <20160610162530.GA19159@kroah.com> (raw)
In-Reply-To: <20160610085432.17111-1-jslaby@suse.cz>

On Fri, Jun 10, 2016 at 10:54:32AM +0200, Jiri Slaby wrote:
> Modules which register drivers via standard path (driver_register) in
> parallel can cause a warning:
> WARNING: CPU: 2 PID: 3492 at ../fs/sysfs/dir.c:31 sysfs_warn_dup+0x62/0x80
> sysfs: cannot create duplicate filename '/module/saa7146/drivers'
> Modules linked in: hexium_gemini(+) mxb(+) ...
> ...
> Call Trace:
> ...
>  [<ffffffff812e63a2>] sysfs_warn_dup+0x62/0x80
>  [<ffffffff812e6487>] sysfs_create_dir_ns+0x77/0x90
>  [<ffffffff8140f2c4>] kobject_add_internal+0xb4/0x340
>  [<ffffffff8140f5b8>] kobject_add+0x68/0xb0
>  [<ffffffff8140f631>] kobject_create_and_add+0x31/0x70
>  [<ffffffff8157a703>] module_add_driver+0xc3/0xd0
>  [<ffffffff8155e5d4>] bus_add_driver+0x154/0x280
>  [<ffffffff815604c0>] driver_register+0x60/0xe0
>  [<ffffffff8145bed0>] __pci_register_driver+0x60/0x70
>  [<ffffffffa0273e14>] saa7146_register_extension+0x64/0x90 [saa7146]
>  [<ffffffffa0033011>] hexium_init_module+0x11/0x1000 [hexium_gemini]
> ...
> 
> As can be (mostly) seen, driver_register causes this call sequence:
>   -> bus_add_driver
>     -> module_add_driver
>       -> module_create_drivers_dir
> The last one creates "drivers" directory in /sys/module/<...>. When
> this is done in parallel, the directory is attempted to be created
> twice at the same time.
> 
> This can be easily reproduced by loading mxb and hexium_gemini in
> parallel:
> while :; do
>   modprobe mxb &
>   modprobe hexium_gemini
>   wait
>   rmmod mxb hexium_gemini saa7146_vv saa7146
> done
> 
> saa7146 calls pci_register_driver for both mxb and hexium_gemini,
> which means /sys/module/saa7146/drivers is to be created for both of
> them.

Wow, good catch, I would never have expected that.

I'll go queue this up soon, thanks.

greg k-h

      reply	other threads:[~2016-06-10 16:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-10  8:54 [PATCH] base: make module_create_drivers_dir race-free Jiri Slaby
2016-06-10 16:25 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160610162530.GA19159@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox