From patchwork Tue Nov 14 18:05:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 10058069 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 57C7F602A7 for ; Tue, 14 Nov 2017 18:06:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AA0E28D9F for ; Tue, 14 Nov 2017 18:06:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F163298AA; Tue, 14 Nov 2017 18:06:18 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 ACCA628464 for ; Tue, 14 Nov 2017 18:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753462AbdKNSGR (ORCPT ); Tue, 14 Nov 2017 13:06:17 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:42122 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753105AbdKNSGQ (ORCPT ); Tue, 14 Nov 2017 13:06:16 -0500 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAEI20D8007772 for ; Tue, 14 Nov 2017 10:06:16 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=/pFrZlg2AnHYwkTJaz6dUjy4F5EQKkLvfPR/LWcC/9o=; b=awrGcvrHTSpxEpc4ZzBk6XFOMsmlSS1jmxWDxdqq4SX+dTog5HU6/w5ENJ9KVEgSAb4I dOLThHMP5syQP3cu7yXYeczlh/XTKgSoufKlrf0FZFLFHJwh5qcydivGuV2d3t7NK9jw 7qkJsWI2PNVQqDHUHbtJG8on3YExpoijNOA= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 2e85cc018n-9 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Nov 2017 10:06:15 -0800 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB14.TheFacebook.com (192.168.16.24) with Microsoft SMTP Server id 14.3.361.1; Tue, 14 Nov 2017 10:05:08 -0800 Received: by devbig638.prn2.facebook.com (Postfix, from userid 11222) id D67E84240692; Tue, 14 Nov 2017 10:05:07 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Shaohua Li Smtp-Origin-Hostname: devbig638.prn2.facebook.com To: CC: Jens Axboe , , Tejun Heo Smtp-Origin-Cluster: prn2c22 Subject: [PATCH] blkcg: correctly update stat Date: Tue, 14 Nov 2017 10:05:07 -0800 Message-ID: <2fefc7364715a5c7d928fd02e4edeb7f80633c7f.1510682654.git.shli@fb.com> X-Mailer: git-send-email 2.9.5 X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-14_09:, , signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe 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 blkcg_bio_issue_check() checks throtl for stat update, which isn't good because the bio could be splitted into small bios, the samll bios go into blkcg_bio_issue_check again and we update stat for the small bios, so we the stat is double charged. To fix this, we only update stat if the bio doesn't have BIO_THROTTLED flag. The fix will update stat ahead of bio skips from blk-throttle, but eventually the stat is correct. This patch is on top of patch: https://marc.info/?l=linux-block&m=151060860608914&w=2 Cc: Tejun Heo Signed-off-by: Shaohua Li Acked-by: Tejun Heo --- include/linux/blk-cgroup.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index 58f3d25..6fbd9ea 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -690,7 +690,8 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q, { struct blkcg *blkcg; struct blkcg_gq *blkg; - bool throtl = false; + bool throtl; + bool charged; rcu_read_lock(); blkcg = bio_blkcg(bio); @@ -707,9 +708,10 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q, spin_unlock_irq(q->queue_lock); } + charged = bio_flagged(bio, BIO_THROTTLED); throtl = blk_throtl_bio(q, blkg, bio); - if (!throtl) { + if (!charged) { blkg = blkg ?: q->root_blkg; blkg_rwstat_add(&blkg->stat_bytes, bio->bi_opf, bio->bi_iter.bi_size);