LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Saravana Kannan <saravanak@google.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Android Kernel Team <kernel-team@android.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] driver core: Fix sleeping in invalid context during device link deletion
Date: Fri, 17 Jul 2020 10:31:13 -0700
Message-ID: <CAGETcx9quqtV9TeD8WEcLLijGeV+7hXqnyiMv7F8xo+vyF_7iw@mail.gmail.com> (raw)
In-Reply-To: <20200717163434.GA119309@roeck-us.net>

On Fri, Jul 17, 2020 at 9:34 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On Fri, Jul 17, 2020 at 12:13:04AM +0200, Marek Szyprowski wrote:
> > Hi Saravana,
> >
> > On 16.07.2020 23:45, Saravana Kannan wrote:
> > > Marek and Guenter reported that commit 287905e68dd2 ("driver core:
> > > Expose device link details in sysfs") caused sleeping/scheduling while
> > > atomic warnings.
> > >
> > > BUG: sleeping function called from invalid context at kernel/locking/mutex.c:935
> > > in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 12, name: kworker/0:1
> > > 2 locks held by kworker/0:1/12:
> > >    #0: ee8074a8 ((wq_completion)rcu_gp){+.+.}-{0:0}, at: process_one_work+0x174/0x7dc
> > >    #1: ee921f20 ((work_completion)(&sdp->work)){+.+.}-{0:0}, at: process_one_work+0x174/0x7dc
> > > Preemption disabled at:
> > > [<c01b10f0>] srcu_invoke_callbacks+0xc0/0x154
> > > ----- 8< ----- SNIP
> > > [<c064590c>] (device_del) from [<c0645c9c>] (device_unregister+0x24/0x64)
> > > [<c0645c9c>] (device_unregister) from [<c01b10fc>] (srcu_invoke_callbacks+0xcc/0x154)
> > > [<c01b10fc>] (srcu_invoke_callbacks) from [<c01493c4>] (process_one_work+0x234/0x7dc)
> > > [<c01493c4>] (process_one_work) from [<c01499b0>] (worker_thread+0x44/0x51c)
> > > [<c01499b0>] (worker_thread) from [<c0150bf4>] (kthread+0x158/0x1a0)
> > > [<c0150bf4>] (kthread) from [<c0100114>] (ret_from_fork+0x14/0x20)
> > > Exception stack(0xee921fb0 to 0xee921ff8)
> > >
> > > This was caused by the device link device being released in the context
> > > of srcu_invoke_callbacks().  There is no need to wait till the RCU
> > > callback to release the device link device.  So release the device
> > > earlier and move the call_srcu() into the device release code. That way,
> > > the memory will get freed only after the device is released AND the RCU
> > > callback is called.
> > >
> > > Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs")
> > > Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > > Reported-by: Guenter Roeck <linux@roeck-us.net>
> > > Signed-off-by: Saravana Kannan <saravanak@google.com>
> > > ---
> > >
> > > v1->v2:
> > > - Better fix
> > > - Changed subject
> > > - v1 is this patch https://lore.kernel.org/lkml/20200716050846.2047110-1-saravanak@google.com/
> > >
> > > Marek and Guenter,
> > >
> > > I reproduced the original issue and tested this fix. Seems to work for
> > > me. Can you confirm?
> >
> > Confirmed, this one fixes the issue! :)
> >
> Same here.
>
> Tested-by: Guenter Roeck <linux@roeck-us.net>
>
> Guenter
>
> > Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> >

Thanks both.

Greg, can you review this and pull this into driver-core-next too?

-Saravana

      reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200716214531eucas1p2c173df09a6e00ef15dfae43ce8f1f9cd@eucas1p2.samsung.com>
2020-07-16 21:45 ` Saravana Kannan
2020-07-16 22:13   ` Marek Szyprowski
2020-07-16 22:16     ` Saravana Kannan
2020-07-17 16:34     ` Guenter Roeck
2020-07-17 17:31       ` Saravana Kannan [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=CAGETcx9quqtV9TeD8WEcLLijGeV+7hXqnyiMv7F8xo+vyF_7iw@mail.gmail.com \
    --to=saravanak@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=m.szyprowski@samsung.com \
    --cc=rafael@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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git