public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: hch@lst.de, josef@toxicpanda.com, axboe@kernel.dk,
	yukuai3@huawei.com, cgroups@vger.kernel.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	yi.zhang@huawei.com
Subject: Re: [PATCH v2 4/5] blk-iocost: fix sleeping in atomic context warnning
Date: Mon, 14 Nov 2022 12:07:45 -1000	[thread overview]
Message-ID: <Y3K8MSFWw8eTnxtm@slm.duckdns.org> (raw)
In-Reply-To: <20221104023938.2346986-5-yukuai1@huaweicloud.com>

On Fri, Nov 04, 2022 at 10:39:37AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> match_u64() is called inside ioc->lock, which causes smatch static
> checker warnings:
> 
> block/blk-iocost.c:3211 ioc_qos_write() warn: sleeping in atomic context
> block/blk-iocost.c:3240 ioc_qos_write() warn: sleeping in atomic context
> block/blk-iocost.c:3407 ioc_cost_model_write() warn: sleeping in atomic
> context
> 
> Fix the problem by introducing a mutex and using it while prasing input
> params.

It bothers me that parsing an u64 string requires a GFP_KERNEL memory
allocation.

> @@ -2801,9 +2806,11 @@ static void ioc_rqos_queue_depth_changed(struct rq_qos *rqos)
>  {
>  	struct ioc *ioc = rqos_to_ioc(rqos);
>  
> +	mutex_lock(&ioc->params_mutex);
>  	spin_lock_irq(&ioc->lock);
>  	ioc_refresh_params(ioc, false);
>  	spin_unlock_irq(&ioc->lock);
> +	mutex_unlock(&ioc->params_mutex);
>  }

Aren't the params still protected by ioc->lock? Why do we need to grab both?

Any chance I can persuade you into updating match_NUMBER() helpers to not
use match_strdup()? They can easily disable irq/preemption and use percpu
buffers and we won't need most of this patchset.

Thanks.

-- 
tejun

  parent reply	other threads:[~2022-11-14 22:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04  2:39 [PATCH v2 0/5] blk-iocost: random patches to improve configuration Yu Kuai
2022-11-04  2:39 ` [PATCH v2 1/5] blk-iocost: cleanup ioc_qos_write() and ioc_cost_model_write() Yu Kuai
2022-11-04  2:39 ` [PATCH v2 2/5] blk-iocost: improve hanlder of match_u64() Yu Kuai
2022-11-04  2:39 ` [PATCH v2 3/5] blk-iocost: don't allow to configure bio based device Yu Kuai
2022-11-04  2:39 ` [PATCH v2 4/5] blk-iocost: fix sleeping in atomic context warnning Yu Kuai
2022-11-04  5:17   ` Christoph Hellwig
2022-11-07  5:56   ` Christoph Hellwig
2022-11-14 22:07   ` Tejun Heo [this message]
2022-11-15  1:16     ` Yu Kuai
2022-11-17 11:28     ` Yu Kuai
2022-11-22 21:10       ` Tejun Heo
2022-11-23  0:14         ` Jens Axboe
2022-11-23  0:42           ` Tejun Heo
2022-11-23 10:22             ` Yu Kuai
2022-12-05  9:39               ` Yu Kuai
2022-12-08 15:59                 ` Tejun Heo
2022-11-04  2:39 ` [PATCH v2 5/5] blk-iocost: read params inside lock in sysfs apis Yu Kuai
2022-11-04  5:17   ` Christoph Hellwig
2022-11-07  5:56   ` Christoph Hellwig
2022-11-12  6:13 ` [PATCH v2 0/5] blk-iocost: random patches to improve configuration Yu Kuai

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=Y3K8MSFWw8eTnxtm@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai1@huaweicloud.com \
    --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