From: Tejun Heo <tj@kernel.org>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC 1/1] kernfs: keep kernfs node alive for __kernfs_remove()
Date: Wed, 17 Apr 2019 12:26:56 -0700 [thread overview]
Message-ID: <20190417192656.GE374014@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <0469256f-7af9-c9cb-1c64-5d4bebfad095@virtuozzo.com>
Hello,
On Wed, Apr 17, 2019 at 04:12:29PM +0000, Konstantin Khorenko wrote:
> i don't know the full scenario unfortunately, but the idea is the following:
>
> __kernfs_remove() is called under kernfs_mutex and if
> !(!kn || (kn->parent && RB_EMPTY_NODE(&kn->rb)))
>
> it assumes that nothing can change while we hold the mutex and
> for each kernfs descendant should have kn->count > 0.
>
> =====
> /* deactivate and unlink the subtree node-by-node */
> do {
> pos = kernfs_leftmost_descendant(kn);
>
> /*
> * kernfs_drain() drops kernfs_mutex temporarily and @pos's
> * base ref could have been put by someone else by the time
> * the function returns. Make sure it doesn't go away
> * underneath us.
> */
> kernfs_get(pos);
> =====
>
> At the same time kernfs_notify_workfn() can do a kernfs_put() out of kernfs_mutex
> which probably can be the last put and dec kn->count to 0 any moment.
Yeah, but the caller of __kernfs_remove() should be holding the ref,
so I don't see how it'd reach zero. Also, just putting that one
kernfs_put() inside mutex can't possibly be the right solution given
that the function is allowed to be called from any context. I think
we need to understand what's going on better before making changes.
Thanks.
--
tejun
prev parent reply other threads:[~2019-04-17 19:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 15:53 [PATCH RFC 0/1] kernfs: hit a warning in kernfs_get() Konstantin Khorenko
2019-04-16 15:53 ` [PATCH RFC 1/1] kernfs: keep kernfs node alive for __kernfs_remove() Konstantin Khorenko
2019-04-16 19:17 ` Tejun Heo
2019-04-17 16:12 ` Konstantin Khorenko
2019-04-17 19:26 ` Tejun Heo [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=20190417192656.GE374014@devbig004.ftw2.facebook.com \
--to=tj@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=khorenko@virtuozzo.com \
--cc=linux-kernel@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