From: Jens Axboe <axboe@kernel.dk>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Waiman Long <longman@redhat.com>, Yu Kuai <yukuai3@huawei.com>,
Tejun Heo <tj@kernel.org>, Josef Bacik <josef@toxicpanda.com>,
cgroups@vger.kernel.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2] blk_iocost: remove some duplicate irq disable/enables
Date: Thu, 3 Oct 2024 08:38:48 -0600 [thread overview]
Message-ID: <c26e5b36-d369-4353-a5a8-9c9b381ce239@kernel.dk> (raw)
In-Reply-To: <68f3e5f8-895e-416b-88cf-284a263bd954@stanley.mountain>
On 10/3/24 8:31 AM, Dan Carpenter wrote:
> On Thu, Oct 03, 2024 at 07:21:25AM -0600, Jens Axboe wrote:
>> On 10/3/24 6:03 AM, Dan Carpenter wrote:
>>> 3117 ioc_now(iocg->ioc, &now);
>>> 3118 weight_updated(iocg, &now);
>>> 3119 spin_unlock(&iocg->ioc->lock);
>>> 3120 }
>>> 3121 }
>>> 3122 spin_unlock_irq(&blkcg->lock);
>>> 3123
>>> 3124 return nbytes;
>>> 3125 }
>>> 3126
>>> 3127 blkg_conf_init(&ctx, buf);
>>> 3128
>>> 3129 ret = blkg_conf_prep(blkcg, &blkcg_policy_iocost, &ctx);
>>> 3130 if (ret)
>>> 3131 goto err;
>>> 3132
>>> 3133 iocg = blkg_to_iocg(ctx.blkg);
>>> 3134
>>> 3135 if (!strncmp(ctx.body, "default", 7)) {
>>> 3136 v = 0;
>>> 3137 } else {
>>> 3138 if (!sscanf(ctx.body, "%u", &v))
>>> 3139 goto einval;
>>> 3140 if (v < CGROUP_WEIGHT_MIN || v > CGROUP_WEIGHT_MAX)
>>> 3141 goto einval;
>>> 3142 }
>>> 3143
>>> 3144 spin_lock(&iocg->ioc->lock);
>>>
>>> But why is this not spin_lock_irq()? I haven't analyzed this so maybe it's
>>> fine.
>>
>> That's a bug.
>>
>
> I could obviously write this patch but I feel stupid writing the
> commit message. My level of understanding is Monkey See Monkey do.
> Could you take care of this?
Sure - or let's add Tejun who knows this code better. Ah he's already
added. Tejun?
> So somewhere we're taking a lock in the IRQ handler and this can lead
> to a deadlock? I thought this would have been caught by lockdep?
It's nested inside blkcg->lock which is IRQ safe, that is enough. But
doing a quick scan of the file, the usage is definitely (widly)
inconsistent. Most times ioc->lock is grabbed disabling interrupts, but
there are also uses that doesn't disable interrupts, coming from things
like seq_file show paths which certainly look like they need it. lockdep
should certainly warn about this, only explanation I have is that nobody
bothered to do that :-)
--
Jens Axboe
next prev parent reply other threads:[~2024-10-03 14:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 10:47 [PATCH v2] blk_iocost: remove some duplicate irq disable/enables Dan Carpenter
2024-10-02 13:17 ` Jens Axboe
2024-10-02 17:49 ` Waiman Long
2024-10-02 18:10 ` Dan Carpenter
2024-10-02 18:40 ` Waiman Long
2024-10-03 12:03 ` Dan Carpenter
2024-10-03 13:21 ` Jens Axboe
2024-10-03 14:31 ` Dan Carpenter
2024-10-03 14:38 ` Jens Axboe [this message]
2024-10-03 15:49 ` Waiman Long
2024-10-03 16:24 ` Jens Axboe
2024-10-03 21:22 ` Tejun Heo
2024-10-03 21:30 ` Tejun Heo
2024-10-03 22:06 ` Jens Axboe
2024-10-04 10:53 ` Dan Carpenter
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=c26e5b36-d369-4353-a5a8-9c9b381ce239@kernel.dk \
--to=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=tj@kernel.org \
--cc=yukuai3@huawei.com \
/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