From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
"jianchao.wang" <jianchao.w.wang@oracle.com>,
Guenter Roeck <linux@roeck-us.net>,
stable@vger.kernel.org
Subject: Re: [PATCH 4.21 V3] blk-mq: not embed .mq_kobj and ctx->kobj into queue instance
Date: Tue, 20 Nov 2018 08:51:50 +0100 [thread overview]
Message-ID: <20181120075150.GF15276@kroah.com> (raw)
In-Reply-To: <20181120014435.3339-1-ming.lei@redhat.com>
On Tue, Nov 20, 2018 at 09:44:35AM +0800, Ming Lei wrote:
> Even though .mq_kobj, ctx->kobj and q->kobj share same lifetime
> from block layer's view, actually they don't because userspace may
> grab one kobject anytime via sysfs.
>
> This patch fixes the issue by the following approach:
>
> 1) introduce 'struct blk_mq_ctxs' for holding .mq_kobj and managing
> all ctxs
>
> 2) free all allocated ctxs and the 'blk_mq_ctxs' instance in release
> handler of .mq_kobj
>
> 3) grab one ref of .mq_kobj before initializing each ctx->kobj, so that
> .mq_kobj is always released after all ctxs are freed.
>
> This patch fixes kernel panic issue during booting when DEBUG_KOBJECT_RELEASE
> is enabled.
>
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Cc: "jianchao.wang" <jianchao.w.wang@oracle.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> V3:
> - keep to allocate q->queue_ctx via percpu allocator, so one extra
> pointer reference can be saved for getting ctx
> V2:
> - allocate 'blk_mq_ctx' inside blk_mq_init_allocated_queue()
> - allocate q->mq_kobj directly
Not tested, but seems sane from a kobject point-of-view:
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
next prev parent reply other threads:[~2018-11-20 7:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 1:44 [PATCH 4.21 V3] blk-mq: not embed .mq_kobj and ctx->kobj into queue instance Ming Lei
2018-11-20 7:51 ` Greg Kroah-Hartman [this message]
2018-11-20 16:45 ` Guenter Roeck
2018-11-20 17:35 ` Jens Axboe
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=20181120075150.GF15276@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=axboe@kernel.dk \
--cc=jianchao.w.wang@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=ming.lei@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.