Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1589855
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] blkcg: allocate struct blkcg_gq outside request queue spinlock |
| Date | 2017-03-01 00:00 +0100 |
| Message-ID | <tfYUq-2fP-21@gated-at.bofh.it> (permalink) |
| References | <tfIFX-8oQ-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hello,
Overall, the approach looks good to me but please see below.
On Mon, Feb 27, 2017 at 06:49:57PM -0800, Tahsin Erdogan wrote:
> @@ -806,44 +807,99 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
> if (!disk)
> return -ENODEV;
> if (part) {
> - owner = disk->fops->owner;
> - put_disk(disk);
> - module_put(owner);
> - return -ENODEV;
> + ret = -ENODEV;
> + goto fail;
> + }
> +
> + q = disk->queue;
> +
> + if (!blkcg_policy_enabled(q, pol)) {
> + ret = -EOPNOTSUPP;
> + goto fail;
Pulling this out of the queue_lock doesn't seem safe to me. This
function may end up calling into callbacks of disabled policies this
way.
> + /*
> + * Create blkgs walking down from blkcg_root to @blkcg, so that all
> + * non-root blkgs have access to their parents.
> + */
> + while (true) {
> + struct blkcg *pos = blkcg;
> + struct blkcg *parent;
> + struct blkcg_gq *new_blkg;
> +
> + parent = blkcg_parent(blkcg);
> + while (parent && !__blkg_lookup(parent, q, false)) {
> + pos = parent;
> + parent = blkcg_parent(parent);
> + }
Hmm... how about adding @new_blkg to blkg_lookup_create() and calling
it with non-NULL @new_blkg until it succeeds? Wouldn't that be
simpler?
> +
> + new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
> + if (unlikely(!new_blkg)) {
> + ret = -ENOMEM;
> + goto fail;
> + }
> +
> + rcu_read_lock();
> + spin_lock_irq(q->queue_lock);
> +
> + /* Lookup again since we dropped the lock for blkg_alloc(). */
> + blkg = __blkg_lookup(pos, q, false);
> + if (blkg) {
> + blkg_free(new_blkg);
> + } else {
> + blkg = blkg_create(pos, q, new_blkg);
> + if (unlikely(IS_ERR(blkg))) {
> + ret = PTR_ERR(blkg);
> + goto fail_unlock;
> + }
than duplicating the same logic here?
Thanks.
--
tejun
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-02-28 06:40 +0100
Re: [PATCH] blkcg: allocate struct blkcg_gq outside request queue spinlock Tejun Heo <tj@kernel.org> - 2017-03-01 00:00 +0100
Re: [PATCH] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-01 01:10 +0100
Re: [PATCH] blkcg: allocate struct blkcg_gq outside request queue spinlock Tejun Heo <tj@kernel.org> - 2017-03-01 18:00 +0100
Re: [PATCH v2] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-02 01:20 +0100
[PATCH v2] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-02 04:00 +0100
Re: [PATCH v2] blkcg: allocate struct blkcg_gq outside request queue spinlock Tejun Heo <tj@kernel.org> - 2017-03-02 20:50 +0100
Re: [PATCH v2] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-02 23:50 +0100
Re: [PATCH v2] blkcg: allocate struct blkcg_gq outside request queue spinlock Tejun Heo <tj@kernel.org> - 2017-03-03 20:30 +0100
[PATCH v3] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-04 02:50 +0100
Re: [PATCH v3] blkcg: allocate struct blkcg_gq outside request queue spinlock Tejun Heo <tj@kernel.org> - 2017-03-04 20:30 +0100
Re: [PATCH v4] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-05 15:30 +0100
[PATCH v4] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-05 15:30 +0100
Re: [PATCH v4] blkcg: allocate struct blkcg_gq outside request queue spinlock Tejun Heo <tj@kernel.org> - 2017-03-06 21:10 +0100
[PATCH v5] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-09 09:10 +0100
Re: [PATCH v5] blkcg: allocate struct blkcg_gq outside request queue spinlock Tejun Heo <tj@kernel.org> - 2017-03-09 19:30 +0100
Re: [PATCH v5] blkcg: allocate struct blkcg_gq outside request queue spinlock Jens Axboe <axboe@kernel.dk> - 2017-03-11 23:50 +0100
Re: [PATCH v5] blkcg: allocate struct blkcg_gq outside request queue spinlock Jens Axboe <axboe@kernel.dk> - 2017-03-12 00:00 +0100
Re: [PATCH v5] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-12 05:40 +0100
Re: [PATCH v5] blkcg: allocate struct blkcg_gq outside request queue spinlock Jens Axboe <axboe@kernel.dk> - 2017-03-13 15:40 +0100
Re: [PATCH v5] blkcg: allocate struct blkcg_gq outside request queue spinlock Tahsin Erdogan <tahsin@google.com> - 2017-03-13 17:20 +0100
Re: [lkp-robot] [blkcg] ad63af3cb7: BUG:sleeping_function_called_from_invalid_context_at_mm/slab.h Tahsin Erdogan <tahsin@google.com> - 2017-03-09 09:10 +0100
csiph-web