From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ming Lei Subject: Re: [PATCH -next v3 1/2] blk-throttle: fix that io throttle can only work for single bio Date: Thu, 19 May 2022 18:42:41 +0800 Message-ID: References: <20220519085811.879097-1-yukuai3@huawei.com> <20220519085811.879097-2-yukuai3@huawei.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652956976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kvMeEsiv+LVL0/x98g8vYJ8UrLJ8yrZkVIlvlaQ/zNw=; b=M3nLtp7fz3MDK2B1lltioVWjI/5VHoTA/yBhWCmfBuCb4nbfVklxaoP6bzNAJqRNQhKXfF AN8793dqu7SPTXr6liNBEFdNBtZV0zWxX2w39kp5t1Q3F1hKwcZAxENiCdGzYxAeYPAVl7 EhTvJUWrzeZ5ykPoMSKYObCKtaqf+4A= Content-Disposition: inline In-Reply-To: <20220519085811.879097-2-yukuai3@huawei.com> List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Yu Kuai Cc: tj@kernel.org, axboe@kernel.dk, geert@linux-m68k.org, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com On Thu, May 19, 2022 at 04:58:10PM +0800, Yu Kuai wrote: > commit 9f5ede3c01f9 ("block: throttle split bio in case of iops limit") > introduce a new problem, for example: > > [root@localhost ~]# echo "8:0 1024" > /sys/fs/cgroup/blkio/blkio.throttle.write_bps_device > [root@localhost ~]# echo $$ > /sys/fs/cgroup/blkio/cgroup.procs > [root@localhost ~]# dd if=/dev/zero of=/dev/sda bs=10k count=1 oflag=direct & > [1] 620 > [root@localhost ~]# dd if=/dev/zero of=/dev/sda bs=10k count=1 oflag=direct & > [2] 626 > [root@localhost ~]# 1+0 records in > 1+0 records out > 10240 bytes (10 kB, 10 KiB) copied, 10.0038 s, 1.0 kB/s1+0 records in > 1+0 records out > > 10240 bytes (10 kB, 10 KiB) copied, 9.23076 s, 1.1 kB/s > -> the second bio is issued after 10s instead of 20s. > > This is because if some bios are already queued, current bio is queued > directly and the flag 'BIO_THROTTLED' is set. And later, when former > bios are dispatched, this bio will be dispatched without waiting at all, > this is due to tg_with_in_bps_limit() return 0 for this bio. > > In order to fix the problem, don't skip flaged bio in > tg_with_in_bps_limit(), and for the problem that split bio can be > double accounted, compensate the over-accounting in __blk_throtl_bio(). > > Fixes: 9f5ede3c01f9 ("block: throttle split bio in case of iops limit") > Signed-off-by: Yu Kuai > --- Reviewed-by: Ming Lei Thanks, Ming