From: Ming Lei <ming.lei@redhat.com>
To: "jianchao.wang" <jianchao.w.wang@oracle.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org
Subject: Re: [PATCH 1/2] blk-mq: not embed .mq_kobj and ctx->kobj into queue instance
Date: Fri, 16 Nov 2018 15:52:06 +0800 [thread overview]
Message-ID: <20181116075205.GC5520@ming.t460p> (raw)
In-Reply-To: <64abb411-f4af-a169-e878-2119f7c792d5@oracle.com>
On Fri, Nov 16, 2018 at 02:11:07PM +0800, jianchao.wang wrote:
>
>
> On 11/16/18 11:28 AM, Ming Lei wrote:
> ...
> >
> > +struct blk_mq_kobj {
> > + struct kobject kobj;
> > +};
> > +
> > static void blk_mq_sysfs_release(struct kobject *kobj)
> > {
> > + struct blk_mq_kobj *mq_kobj = container_of(kobj, struct blk_mq_kobj,
> > + kobj);
> > + kfree(mq_kobj);
> > +}
> > +
> ...
> >
> > -void blk_mq_sysfs_init(struct request_queue *q)
> > +int blk_mq_sysfs_init(struct request_queue *q)
> > {
> > struct blk_mq_ctx *ctx;
> > int cpu;
> > + struct blk_mq_kobj *mq_kobj;
> > +
> > + mq_kobj = kzalloc(sizeof(struct blk_mq_kobj), GFP_KERNEL);
> > + if (!mq_kobj)
> > + return -ENOMEM;
> >
> > - kobject_init(&q->mq_kobj, &blk_mq_ktype);
> > + kobject_init(&mq_kobj->kobj, &blk_mq_ktype);
> >
> > for_each_possible_cpu(cpu) {
> > - ctx = per_cpu_ptr(q->queue_ctx, cpu);
> > + ctx = kzalloc_node(sizeof(*ctx), GFP_KERNEL, cpu_to_node(cpu));
> > + if (!ctx)
> > + goto fail;
> > + *per_cpu_ptr(q->queue_ctx, cpu) = ctx;
> > kobject_init(&ctx->kobj, &blk_mq_ctx_ktype);
> > }
> > + q->mq_kobj = &mq_kobj->kobj;
> > + return 0;
> > +
> > + fail:
> > + for_each_possible_cpu(cpu) {
> > + ctx = *per_cpu_ptr(q->queue_ctx, cpu);
> > + if (ctx)
> > + kobject_put(&ctx->kobj);
> > + }
> > + kobject_put(&mq_kobj->kobj);
> > + return -ENOMEM;
> > }
>
>
> blk_mq_kobj looks meaningless, why do we need it, or do I miss something ?
Right, it should have been allocated directly.
> And maybe we should allocate ctx in blk_mq_init_allocated_queue.
Looks either way is fine.
Thanks,
Ming
next prev parent reply other threads:[~2018-11-16 7:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-16 3:28 [PATCH 0/2] blk-mq: fix kobject lifetime issue Ming Lei
2018-11-16 3:28 ` [PATCH 1/2] blk-mq: not embed .mq_kobj and ctx->kobj into queue instance Ming Lei
2018-11-16 6:11 ` jianchao.wang
2018-11-16 7:52 ` Ming Lei [this message]
2018-11-16 6:52 ` Sasha Levin
2018-11-16 7:49 ` Ming Lei
2018-11-16 16:07 ` Sasha Levin
2018-11-16 3:28 ` [PATCH 2/2] blk-mq: alloc q->queue_ctx as normal array Ming Lei
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=20181116075205.GC5520@ming.t460p \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=jianchao.w.wang@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux@roeck-us.net \
--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.