cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Yu Kuai <yukuai1-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org>
Cc: hch-jcswGhMUV9g@public.gmane.org,
	josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org,
	axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
	yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	yi.zhang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org
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-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org>

On Fri, Nov 04, 2022 at 10:39:37AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> 
> 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 3/5] blk-iocost: don't allow to configure bio based device Yu Kuai
     [not found] ` <20221104023938.2346986-1-yukuai1-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org>
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 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
     [not found]     ` <20221104023938.2346986-5-yukuai1-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org>
2022-11-14 22:07       ` Tejun Heo [this message]
2022-11-15  1:16         ` Yu Kuai
     [not found]         ` <Y3K8MSFWw8eTnxtm-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
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
     [not found]                   ` <Y31sYFdA2lHIvjt3-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2022-11-23 10:22                     ` Yu Kuai
     [not found]                       ` <ec3754a6-3249-51ab-b659-fd795884e346-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org>
2022-12-05  9:39                         ` Yu Kuai
     [not found]                           ` <f227e4bd-c74b-a02e-2a02-11a1376ee4f9-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org>
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
     [not found]     ` <20221104023938.2346986-6-yukuai1-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org>
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-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hch-jcswGhMUV9g@public.gmane.org \
    --cc=josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org \
    --cc=linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=yi.zhang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=yukuai1-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org \
    --cc=yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).