All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Kemeng Shi <shikemeng@huawei.com>
Cc: josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 03/11] blk-throttle: ignore cgroup without io queued in blk_throtl_cancel_bios
Date: Wed, 23 Nov 2022 08:13:59 -1000	[thread overview]
Message-ID: <Y35i54BnLjKce3Kc@slm.duckdns.org> (raw)
In-Reply-To: <20221123060401.20392-4-shikemeng@huawei.com>

On Wed, Nov 23, 2022 at 02:03:53PM +0800, Kemeng Shi wrote:
> Ignore cgroup without io queued in blk_throtl_cancel_bios for two
> reasons:
> 1. Save cpu cycle for trying to dispatch cgroup which is no io queued.
> 2. Avoid non-consistent state that cgroup is inserted to service queue
> without THROTL_TG_PENDING set as tg_update_disptime will unconditional
> re-insert cgroup to service queue. If we are on the default hierarchy,
> IO dispatched from child in tg_dispatch_one_bio will trigger inserting
> cgroup to service queue without erase first and ruin the tree.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huawei.com>
> ---
>  block/blk-throttle.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index b33bcf53b36e..acfac916ed99 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -1728,7 +1728,12 @@ void blk_throtl_cancel_bios(struct gendisk *disk)
>  		 * Set the flag to make sure throtl_pending_timer_fn() won't
>  		 * stop until all throttled bios are dispatched.
>  		 */
> -		blkg_to_tg(blkg)->flags |= THROTL_TG_CANCELING;
> +		tg->flags |= THROTL_TG_CANCELING;
> +
> +		/* No need to dispatch cgroup without io queued */

It's probably more important to mention that putting this in without PENDING
set can corrupt the tree in the future through double insertion.

> +		if (!(tg->flags & THROTL_TG_PENDING))
> +			continue;
> +

Other than than the above comment,

  Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Kemeng Shi <shikemeng-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org,
	axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 03/11] blk-throttle: ignore cgroup without io queued in blk_throtl_cancel_bios
Date: Wed, 23 Nov 2022 08:13:59 -1000	[thread overview]
Message-ID: <Y35i54BnLjKce3Kc@slm.duckdns.org> (raw)
In-Reply-To: <20221123060401.20392-4-shikemeng-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

On Wed, Nov 23, 2022 at 02:03:53PM +0800, Kemeng Shi wrote:
> Ignore cgroup without io queued in blk_throtl_cancel_bios for two
> reasons:
> 1. Save cpu cycle for trying to dispatch cgroup which is no io queued.
> 2. Avoid non-consistent state that cgroup is inserted to service queue
> without THROTL_TG_PENDING set as tg_update_disptime will unconditional
> re-insert cgroup to service queue. If we are on the default hierarchy,
> IO dispatched from child in tg_dispatch_one_bio will trigger inserting
> cgroup to service queue without erase first and ruin the tree.
> 
> Signed-off-by: Kemeng Shi <shikemeng-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
>  block/blk-throttle.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
> index b33bcf53b36e..acfac916ed99 100644
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -1728,7 +1728,12 @@ void blk_throtl_cancel_bios(struct gendisk *disk)
>  		 * Set the flag to make sure throtl_pending_timer_fn() won't
>  		 * stop until all throttled bios are dispatched.
>  		 */
> -		blkg_to_tg(blkg)->flags |= THROTL_TG_CANCELING;
> +		tg->flags |= THROTL_TG_CANCELING;
> +
> +		/* No need to dispatch cgroup without io queued */

It's probably more important to mention that putting this in without PENDING
set can corrupt the tree in the future through double insertion.

> +		if (!(tg->flags & THROTL_TG_PENDING))
> +			continue;
> +

Other than than the above comment,

  Acked-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Thanks.

-- 
tejun

  reply	other threads:[~2022-11-23 18:16 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  6:03 [PATCH 00/11] A few bugfix and cleanup patches for blk-throttle Kemeng Shi
2022-11-23  6:03 ` Kemeng Shi
2022-11-23  6:03 ` [PATCH 01/11] blk-throttle: Limit whole system if root group is configured when on the default hierarchy Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 17:11   ` Tejun Heo
2022-11-24 11:47     ` Kemeng Shi
2022-11-24 11:47       ` Kemeng Shi
2022-11-23  6:03 ` [PATCH 02/11] blk-throttle: Fix that bps of child could exceed bps limited in parent Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 18:09   ` Tejun Heo
2022-11-23 18:09     ` Tejun Heo
2022-11-24 11:49     ` Kemeng Shi
2022-11-24 11:49       ` Kemeng Shi
2022-11-23  6:03 ` [PATCH 03/11] blk-throttle: ignore cgroup without io queued in blk_throtl_cancel_bios Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 18:13   ` Tejun Heo [this message]
2022-11-23 18:13     ` Tejun Heo
2022-11-23  6:03 ` [PATCH 04/11] blk-throttle: correct calculation of wait time in tg_may_dispatch Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 18:18   ` Tejun Heo
2022-11-24 12:10     ` Kemeng Shi
2022-11-24 12:10       ` Kemeng Shi
2022-11-23  6:03 ` [PATCH 05/11] blk-throttle: simpfy low limit reached check in throtl_tg_can_upgrade Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 18:26   ` Tejun Heo
2022-11-24 12:52     ` Kemeng Shi
2022-11-24 12:52       ` Kemeng Shi
2022-11-26  5:03   ` kernel test robot
2022-11-26  5:03     ` kernel test robot
2022-11-23  6:03 ` [PATCH 06/11] blk-throttle: fix typo in comment of throtl_adjusted_limit Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 18:26   ` Tejun Heo
2022-11-23 18:26     ` Tejun Heo
2022-11-23  6:03 ` [PATCH 07/11] blk-throttle: remove incorrect comment for tg_last_low_overflow_time Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 18:27   ` Tejun Heo
2022-11-23 18:27     ` Tejun Heo
2022-11-23  6:03 ` [PATCH 08/11] blk-throttle: remove repeat check of elapsed time from last upgrade in throtl_hierarchy_can_downgrade Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 18:28   ` Tejun Heo
2022-11-23 18:28     ` Tejun Heo
2022-11-24 12:58     ` Kemeng Shi
2022-11-24 12:58       ` Kemeng Shi
2022-11-26  8:15   ` kernel test robot
2022-11-26  8:15     ` kernel test robot
2022-11-23  6:03 ` [PATCH 09/11] blk-throttle: remove unnecessary check for validation of limit index Kemeng Shi
2022-11-23  6:03   ` Kemeng Shi
2022-11-23 18:31   ` Tejun Heo
2022-11-23 18:31     ` Tejun Heo
2022-11-24 12:58     ` Kemeng Shi
2022-11-24 12:58       ` Kemeng Shi
2022-11-23  6:04 ` [PATCH 10/11] blk-throttle: remove unused variable td in tg_update_has_rules Kemeng Shi
2022-11-23  6:04   ` Kemeng Shi
2022-11-23 18:30   ` Tejun Heo
2022-11-23 18:30     ` Tejun Heo
2022-11-23  6:04 ` [PATCH 11/11] blk-throttle: Use more siutable time_after check for update slice_start Kemeng Shi
2022-11-23  6:04   ` Kemeng Shi
2022-11-23 18:29   ` Tejun Heo
2022-11-23 18:29     ` Tejun Heo
2022-11-24 13:02     ` Kemeng Shi
2022-11-24 13:02       ` Kemeng Shi

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=Y35i54BnLjKce3Kc@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shikemeng@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 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.