From patchwork Mon Aug 29 15:12:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiale Li X-Patchwork-Id: 9304087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD74F60756 for ; Mon, 29 Aug 2016 15:27:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEC4D28589 for ; Mon, 29 Aug 2016 15:27:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B28C5285C0; Mon, 29 Aug 2016 15:27:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 806872858C for ; Mon, 29 Aug 2016 15:27:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757731AbcH2P14 (ORCPT ); Mon, 29 Aug 2016 11:27:56 -0400 Received: from m13-38.163.com ([220.181.13.38]:57222 "EHLO m13-38.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757672AbcH2P1z (ORCPT ); Mon, 29 Aug 2016 11:27:55 -0400 X-Greylist: delayed 908 seconds by postgrey-1.27 at vger.kernel.org; Mon, 29 Aug 2016 11:27:54 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=dXXS8 TWXvR/eMVnQ70k6+/NmPSNegLt+Ai0hCMYMW4E=; b=NfsldaffuvJjqKq6g7D6u vF2/wAPB43Do1+wnhkBzIJltxF/w39vGtEizu/SQvW84EbIa+bv4MNLKzELpR0zX Sp61ekINr7eSXghhSrbWxYWjB0wgAfQiweUD/phQVddGm3QtFy7ZodFU+gLpVhnG g8jwtSVgRRFiJGDkl3h50k= Received: from aaronlee0817$163.com ( [106.36.219.19] ) by ajax-webmail-wmsvr38 (Coremail) ; Mon, 29 Aug 2016 23:12:08 +0800 (CST) X-Originating-IP: [106.36.219.19] Date: Mon, 29 Aug 2016 23:12:08 +0800 (CST) From: aaronlee0817 To: tg , "jens axboe" , "ming lin" Cc: cgroup , linux-block , "linux kernel mailing list" , "shaohua li" , "yanzi.zhang" , "zhen1.zhang" , "jiale0817.li" Subject: [AFC] cgroup: Fix block throttle bio more than once X-Priority: 3 X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 20160420(83524.8626) Copyright (c) 2002-2016 www.mailtech.cn 163com MIME-Version: 1.0 Message-ID: <335a26a9.11bb7.156d6db9097.Coremail.aaronlee0817@163.com> X-Coremail-Locale: zh_CN X-CM-TRANSID: JsGowAA3l4LJUMRX9QEKAA--.22801W X-CM-SenderInfo: pddu00hohhimirx6il2tof0z/xtbB0APUQlUL9Nb30AABsf X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Tejun, Few months ago, we send an email to tell the problem of blkio throttle the split bio more than once, which leads to the actual bandwidth is smaller than we have set. And we try to fix this by adding a flag bit BIO_SPLIT in bio flag field. And these days we did some enhance test, and found that the last patch we sent to you causes another problem of iops throttle which throttle the iops much than what we set. Because split bio should be count more than once of iops, not only once. After our testing, we propose this patch to fix both bps and iops throttle problem and want to ask for your comment. Thanks. From eb1b1c754d4b267405b5a0d62f8b3f7f7b85df8d Mon Sep 17 00:00:00 2001 From: Jiale Li Date: Mon, 29 Aug 2016 10:25:47 -0400 Subject: [PATCH] Fix block throttle bio more than once Signed-off-by: Jiale Li --- block/blk-merge.c | 1 + block/blk-throttle.c | 9 ++++++++- include/linux/blk-cgroup.h | 6 ++++-- include/linux/blk_types.h | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) 1.9.1 diff --git a/block/blk-merge.c b/block/blk-merge.c index 7b17a65..074f2bd 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -190,7 +190,7 @@ void blk_queue_split(struct request_queue *q, struct bio **bio, bio_chain(split, *bio); trace_block_split(q, split, (*bio)->bi_iter.bi_sector); + bio_set_flag(*bio, BIO_SPLIT); generic_make_request(*bio); *bio = split; } diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 4ffde95..53a7d67 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -721,6 +721,12 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio, u64 bytes_allowed, extra_bytes, tmp; unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; + if (bio_flagged(bio, BIO_SPLIT)) { + if (wait) + *wait = 0; + return true; + } + jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw]; /* Slice has just started. Consider one slice interval */ @@ -817,7 +823,8 @@ static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio) bool rw = bio_data_dir(bio); /* Charge the bio to the group */ - tg->bytes_disp[rw] += bio->bi_iter.bi_size; + if (!bio_flagged(bio, BIO_SPLIT)) + tg->bytes_disp[rw] += bio->bi_iter.bi_size; tg->io_disp[rw]++; /* diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index c02e669..24dc09b 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -19,6 +19,7 @@ #include #include #include +#include /* percpu_counter batch for blkg_[rw]stats, per-cpu drift doesn't matter */ #define BLKG_STAT_CPU_BATCH (INT_MAX / 2) @@ -713,8 +714,9 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q, if (!throtl) { blkg = blkg ?: q->root_blkg; - blkg_rwstat_add(&blkg->stat_bytes, bio->bi_rw, - bio->bi_iter.bi_size); + if (!bio_flagged(bio, BIO_SPLIT)) + blkg_rwstat_add(&blkg->stat_bytes, bio->bi_rw, + bio->bi_iter.bi_size); blkg_rwstat_add(&blkg->stat_ios, bio->bi_rw, 1); } diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index b294780..e0e418f 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -120,7 +120,7 @@ struct bio { #define BIO_QUIET 6 /* Make BIO Quiet */ #define BIO_CHAIN 7 /* chained bio, ->bi_remaining in effect */ #define BIO_REFFED 8 /* bio has elevated ->bi_cnt */ +#define BIO_SPLIT 9 /* bio has been splited */ /* * Flags starting here get preserved by bio_reset() - this includes --