public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: jack@suse.cz, tj@kernel.org, josef@toxicpanda.com,
	axboe@kernel.dk, paolo.valente@unimore.it,
	mauro.andreolini@unimore.it, avanzini.arianna@gmail.com,
	cgroups@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, yukuai3@huawei.com,
	yi.zhang@huawei.com, yangerkun@huawei.com
Subject: Re: [PATCH for-6.12 3/4] block, bfq: don't break merge chain in bfq_split_bfqq()
Date: Wed, 4 Sep 2024 14:20:43 +0200	[thread overview]
Message-ID: <20240904122043.nyaouj7qt2fyp6xa@quack3> (raw)
In-Reply-To: <20240902130329.3787024-4-yukuai1@huaweicloud.com>

On Mon 02-09-24 21:03:28, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> Consider the following scenario:
> 
>     Process 1       Process 2       Process 3       Process 4
>      (BIC1)          (BIC2)          (BIC3)          (BIC4)
>       Λ               |               |                |
>        \-------------\ \-------------\ \--------------\|
>                       V               V                V
>       bfqq1--------->bfqq2---------->bfqq3----------->bfqq4
> ref    0              1               2                4
> 
> If Process 1 issue a new IO and bfqq2 is found, and then bfq_init_rq()
> decide to spilt bfqq2 by bfq_split_bfqq(). Howerver, procress reference
> of bfqq2 is 1 and bfq_split_bfqq() just clear the coop flag, which will
> break the merge chain.
> 
> Expected result: caller will allocate a new bfqq for BIC1
> 
>     Process 1       Process 2       Process 3       Process 4
>      (BIC1)          (BIC2)          (BIC3)          (BIC4)
>                       |               |                |
>                        \-------------\ \--------------\|
>                                       V                V
>       bfqq1--------->bfqq2---------->bfqq3----------->bfqq4
> ref    0              0               1                3
> 
> Since the condition is only used for the last bfqq4 when the previous
> bfqq2 and bfqq3 are already splited. Fix the problem by checking if
> bfqq is the last one in the merge chain as well.
> 
> Fixes: 36eca8948323 ("block, bfq: add Early Queue Merge (EQM)")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  block/bfq-iosched.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index ffaa0d56328a..ca766b7d5560 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -6727,7 +6727,7 @@ bfq_split_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq)
>  {
>  	bfq_log_bfqq(bfqq->bfqd, bfqq, "splitting queue");
>  
> -	if (bfqq_process_refs(bfqq) == 1) {
> +	if (bfqq_process_refs(bfqq) == 1 && !bfqq->new_bfqq) {
>  		bfqq->pid = current->pid;
>  		bfq_clear_bfqq_coop(bfqq);
>  		bfq_clear_bfqq_split_coop(bfqq);
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2024-09-04 12:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02 13:03 [PATCH for-6.12 0/4] block, bfq: fix corner cases related to bfqq merging Yu Kuai
2024-09-02 13:03 ` [PATCH for-6.12 1/4] block, bfq: fix possible UAF for bfqq->bic with merge chain Yu Kuai
2024-09-04 11:51   ` Jan Kara
2024-09-02 13:03 ` [PATCH for-6.12 2/4] block, bfq: choose the last bfqq from merge chain in bfq_setup_cooperator() Yu Kuai
2024-09-04 12:17   ` Jan Kara
2024-09-02 13:03 ` [PATCH for-6.12 3/4] block, bfq: don't break merge chain in bfq_split_bfqq() Yu Kuai
2024-09-04 12:20   ` Jan Kara [this message]
2024-09-02 13:03 ` [PATCH for-6.12 4/4] block, bfq: use bfq_reassign_last_bfqq() in bfq_bfqq_move() Yu Kuai
2024-09-04 12:22   ` Jan Kara
2024-09-03 15:51 ` [PATCH for-6.12 0/4] block, bfq: fix corner cases related to bfqq merging Jens Axboe
2024-09-04  1:32   ` Yu Kuai
2024-09-04  2:28     ` Bart Van Assche
2024-09-04  2:45       ` Yu Kuai
2024-09-04 13:55         ` Jens Axboe
2024-09-04 17:17         ` Bart Van Assche
2024-09-05  1:48           ` Yu Kuai
2024-09-04  4:38     ` Ming Lei
2024-09-04 12:29     ` Jan Kara
2024-09-04 13:49       ` Jens Axboe
2024-09-04 13:53     ` Jens Axboe
2024-09-03 15:56 ` Jens Axboe

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=20240904122043.nyaouj7qt2fyp6xa@quack3 \
    --to=jack@suse.cz \
    --cc=avanzini.arianna@gmail.com \
    --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=mauro.andreolini@unimore.it \
    --cc=paolo.valente@unimore.it \
    --cc=tj@kernel.org \
    --cc=yangerkun@huawei.com \
    --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