From patchwork Tue Jun 5 18:01:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10449021 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 9844E60375 for ; Tue, 5 Jun 2018 18:01:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85EF729AF3 for ; Tue, 5 Jun 2018 18:01:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AB1129B04; Tue, 5 Jun 2018 18:01:51 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 F319A29AF3 for ; Tue, 5 Jun 2018 18:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752842AbeFESBs (ORCPT ); Tue, 5 Jun 2018 14:01:48 -0400 Received: from mail-yb0-f193.google.com ([209.85.213.193]:46483 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752969AbeFESBl (ORCPT ); Tue, 5 Jun 2018 14:01:41 -0400 Received: by mail-yb0-f193.google.com with SMTP id p22-v6so1073739yba.13; Tue, 05 Jun 2018 11:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=yG9Y22eElUPWmH5ZNO74/ShKrIwGX0Khqmfi2iyA0Po=; b=VZbjTKiv1svc+zKgQbZq33f30+y90EiX/IQ9B83FfWDBsNQYuQVOXVUUAr2Fnararu B19FMdB4NBA2HGjqYsqCceUmE9VnxTf9FvxkVJepcICVtNjcnpHKmQFT9fc0JlzXdrmB aWQbzTB1p7Jt7Rf/kge7QViQ9Q4A+e6zQ6jKXWwG+6kYdxxsB5jtRoG0bzavrKd7h1av fcJKZ/IzFqQaHporv2GxRtqGMRv6ugYTacq/IuMDGwM0V4hP+Pv1Dblri1IXpMGcmCD7 Y7Uqz36gEuLRmZaAq5TFmySqEApfB9dfikGaHAhsmjTY4mb2nRC+627P5VgRFHJGnWIQ YPSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=yG9Y22eElUPWmH5ZNO74/ShKrIwGX0Khqmfi2iyA0Po=; b=KaB+l88VCyG14XAdCoy79pMrO+vewBRRXlUzRvLAUc+HfurIAvTe9iMbYSgiuXHikm IdtZuczpLl3G8BtQO08d3XrSf4KOGrFiDxbCWC0VJq4vhA6bSU9deGlvVuRa7zQuLu3K uGQUjMAUXp9xyztfcg65RN451dY/3YtyxZsjUxFx4yQH7BCfshSlIxiN+mZbm2zpPfZf bdCRNqpv7qV0N8Xt44qxeLfLgNNd88OZe0yz5zn/cFuebVEmi94EbHwkLbz/g3J1KC0T 9BUoSwFF1rjdX0ZdIzdDXw7LmcWArU2HkoSi+2tSXjYrSMAm/98UpZD3dhErkph2IBCk stVw== X-Gm-Message-State: ALKqPweO9PYNASasZsEFnG5jipPmAAMJ01jbgTIFy4nxoi5gHDwQZnAj gwE0z0/p2saE1pY1vOC8QA8= X-Google-Smtp-Source: ADUXVKKdqvVekonHLzIlcwvMK8SkE3xNuL6KHcBwJ5zGvCjPiCDB+H7v1rQAHvCLR0J+CFj4xNtwfw== X-Received: by 2002:a25:4003:: with SMTP id n3-v6mr14106220yba.487.1528221700615; Tue, 05 Jun 2018 11:01:40 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::1:f697]) by smtp.gmail.com with ESMTPSA id i205-v6sm834003ywc.103.2018.06.05.11.01.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 11:01:39 -0700 (PDT) From: Tejun Heo To: axboe@kernel.dk Cc: michaelcallahan@fb.com, newella@fb.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Tejun Heo Subject: [PATCH 6/6] blkcg: Track DISCARD statistics and output them in cgroup io.stat Date: Tue, 5 Jun 2018 11:01:20 -0700 Message-Id: <20180605180120.2726113-7-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180605180120.2726113-1-tj@kernel.org> References: <20180605180120.2726113-1-tj@kernel.org> 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 Add tracking of REQ_OP_DISCARD ios to the per-cgroup io.stat. Two fields, dbytes and dios, to respectively count the total bytes and number of discards are added. Signed-off-by: Tejun Heo Cc: Andy Newell Cc: Michael Callahan --- Documentation/admin-guide/cgroup-v2.rst | 10 ++++++---- block/blk-cgroup.c | 14 ++++++++++---- include/linux/blk-cgroup.h | 5 ++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 74cdeae..7f7a161 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1263,17 +1263,19 @@ IO Interface Files Lines are keyed by $MAJ:$MIN device numbers and not ordered. The following nested keys are defined. - ====== =================== + ====== ===================== rbytes Bytes read wbytes Bytes written rios Number of read IOs wios Number of write IOs - ====== =================== + dbytes Bytes discarded + dios Number of discard IOs + ====== ===================== An example read output follows: - 8:16 rbytes=1459200 wbytes=314773504 rios=192 wios=353 - 8:0 rbytes=90430464 wbytes=299008000 rios=8950 wios=1252 + 8:16 rbytes=1459200 wbytes=314773504 rios=192 wios=353 dbytes=0 dios=0 + 8:0 rbytes=90430464 wbytes=299008000 rios=8950 wios=1252 dbytes=50331648 dios=3021 io.weight A read-write flat-keyed file which exists on non-root cgroups. diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index eb85cb8..513d1ea 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -564,6 +564,7 @@ u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, [BLKG_RWSTAT_WRITE] = "Write", [BLKG_RWSTAT_SYNC] = "Sync", [BLKG_RWSTAT_ASYNC] = "Async", + [BLKG_RWSTAT_DISCARD] = "Discard", }; const char *dname = blkg_dev_name(pd->blkg); u64 v; @@ -577,7 +578,8 @@ u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, (unsigned long long)atomic64_read(&rwstat->aux_cnt[i])); v = atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_READ]) + - atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_WRITE]); + atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_WRITE]) + + atomic64_read(&rwstat->aux_cnt[BLKG_RWSTAT_DISCARD]); seq_printf(sf, "%s Total %llu\n", dname, (unsigned long long)v); return v; } @@ -955,7 +957,7 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) { const char *dname; struct blkg_rwstat rwstat; - u64 rbytes, wbytes, rios, wios; + u64 rbytes, wbytes, rios, wios, dbytes, dios; dname = blkg_dev_name(blkg); if (!dname) @@ -967,17 +969,21 @@ static int blkcg_print_stat(struct seq_file *sf, void *v) offsetof(struct blkcg_gq, stat_bytes)); rbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_READ]); wbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_WRITE]); + dbytes = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_DISCARD]); rwstat = blkg_rwstat_recursive_sum(blkg, NULL, offsetof(struct blkcg_gq, stat_ios)); rios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_READ]); wios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_WRITE]); + dios = atomic64_read(&rwstat.aux_cnt[BLKG_RWSTAT_DISCARD]); spin_unlock_irq(blkg->q->queue_lock); if (rbytes || wbytes || rios || wios) - seq_printf(sf, "%s rbytes=%llu wbytes=%llu rios=%llu wios=%llu\n", - dname, rbytes, wbytes, rios, wios); + seq_printf(sf, "%s rbytes=%llu wbytes=%llu " + "rios=%llu wios=%llu dbytes=%llu dios=%llu\n", + dname, rbytes, wbytes, rios, wios, + dbytes, dios); } rcu_read_unlock(); diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index 6c666fd..bdb5c58d 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -35,6 +35,7 @@ enum blkg_rwstat_type { BLKG_RWSTAT_WRITE, BLKG_RWSTAT_SYNC, BLKG_RWSTAT_ASYNC, + BLKG_RWSTAT_DISCARD, BLKG_RWSTAT_NR, BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR, @@ -589,7 +590,9 @@ static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat, { struct percpu_counter *cnt; - if (op_is_write(op)) + if (op_is_discard(op)) + cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_DISCARD]; + else if (op_is_write(op)) cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_WRITE]; else cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_READ];