Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1229691imm; Tue, 5 Jun 2018 11:02:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ1heKrUEM7wxGpdfkdgpFDXyVjMdsBydR/+cgDhro40cXMboMlp5/2+paUL2p2yD8Zs0mP X-Received: by 2002:aa7:864d:: with SMTP id a13-v6mr10669986pfo.247.1528221747186; Tue, 05 Jun 2018 11:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528221747; cv=none; d=google.com; s=arc-20160816; b=y+AN+e9HESZHqnOk2akezjQDcOTN9AKyco7jdz+6R/iM448UzUR7054salEvS+7Eq9 nyCieSSgrv8BFnS4omcXRomp16jvC1rMEYH0cD089y28xLpgIW68o5NOui9rIdiqKt62 psovTLFUC6J2TsWNMqOUDLxDB/7OBnYcbw2mSls1AfN5rCNILdhOdIywJnUr8Uu1DkzA fNE1tBespd0fYYqMV8PMdqkCGvrJO/zUUNAn4YHVlY5gbpDJwOI1He66LQ/qYvJXFYIB 4EuIpAFgRRp/v8pwCTv4UpALW+IcSyGvNrG3oae9f9bljPGBVjWIPglZA7syJ6UJJtM3 c4cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=yG9Y22eElUPWmH5ZNO74/ShKrIwGX0Khqmfi2iyA0Po=; b=ZrA2Y0BY35QCDm/vfjDBulSYz7IznOzL0Kde7KfOFghskVmOCOozraQ86A9UaN8mLk Tm5TKy+++XBncAcoW1zWY9k85iABd2NwqjQ1aqtxo49FqTwh+/G+mMc+cQWFyQWm/2G3 nyKV3jbK7YnYu2x7O9FsTvfh8idvQb2bGZ4w9/TOvimMhc596+/hLBhA42Q5yNI3LrS/ 5XxwyucwJHHnr06vRXTVUXpIfRjEH7KvtUbODu+mo9pxPA+lYgQAHqHkuDHPEBCTJUXW 6M4RrvJsgady3sY8kT8cjIw/V83MzpGQsDCTOzpWMtifnxVnhBGPCba44eETt1MKM8S0 gcrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VZbjTKiv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16-v6si33131842plo.186.2018.06.05.11.02.12; Tue, 05 Jun 2018 11:02:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VZbjTKiv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753033AbeFESBt (ORCPT + 99 others); Tue, 5 Jun 2018 14:01:49 -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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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]; -- 2.9.5