Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1231937imm; Tue, 5 Jun 2018 11:04:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKwqX9X2IKYwpwpfBq6u7R08Y25R70wyMEjAY8XchKfMFsTC4qZlypUMN2pTlwAMd0yfmJC X-Received: by 2002:a63:721d:: with SMTP id n29-v6mr9467104pgc.194.1528221861328; Tue, 05 Jun 2018 11:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528221861; cv=none; d=google.com; s=arc-20160816; b=DI6+eezQ4OGhTlqG8He/1NPeDduQMfT/WEEMA/iW35s1WNPgeKU1dax+oV4Gn12Io7 Cz/KKwW9X0L3JgvIsBHGxRKIpqhBb8pjAOWOFnY2P/T0JJEJYKp/Qv3eXve/3XR29ouU I3AkPtzP3At+YrLvX0IyGWjPK9UO5JfpC+5VzIvic+94WW5+zcyAgFY5cLAefk0oQ6dg N9JBXTvbrF2KUSDXzZEH4t2aazB/38GzDOoft/CsNe4wFsHi9bM/jcv7e4TnBx7NKn9f SvEpzqPyEGbPzS4L3YegW42AzAg3T1cq3GeyTsUjP9W1+PIG3s3hker9XKfxQwMCbJnu 13CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PEmOMZeDK7rTy85osX4xQVlNZxs4RQ9XNIUjyZ8HIuE=; b=fhtpe0UGxyMK7QHsafCZvsZwk39hrcBiXh2xh6Z8mmqCycH966G5pNBzscdHZYSWUT lt+9i9H0xfvVPiZ3OfDmL5+UIFAy+psK38tgt9ReuTJySY/0+HSVbrnnPOgHCsQBOsAs F0QNowgTwuizkrdCNv6L/N+h2diyCA3lc3mruxiFmrWOhlyb+FgO+IVhUrGCwsRm0blx GlrWD5eO5aVoYkD8zq8DV7sVa7KAvYayz1YcRH+SCbfHqp5ifXlRam49B2l1bQvgP4SU ka6Z84J1bq4UyRyYErzarSO9rnWZLi60FqtfHguyWxWzm9ugRQZzs8BaZS7TcjQ2r3g8 DaUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t7YAwXSs; 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 q6-v6si14617803pls.21.2018.06.05.11.04.06; Tue, 05 Jun 2018 11:04:21 -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=t7YAwXSs; 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 S1752663AbeFESB3 (ORCPT + 99 others); Tue, 5 Jun 2018 14:01:29 -0400 Received: from mail-yb0-f196.google.com ([209.85.213.196]:36556 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751917AbeFESBZ (ORCPT ); Tue, 5 Jun 2018 14:01:25 -0400 Received: by mail-yb0-f196.google.com with SMTP id x128-v6so837504ybg.3; Tue, 05 Jun 2018 11:01:25 -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; bh=PEmOMZeDK7rTy85osX4xQVlNZxs4RQ9XNIUjyZ8HIuE=; b=t7YAwXSsMeoMxqVzWiKK/wG1F56lEK33473VfFvt0CqwpdCNmtpAhX2trbEQq3HwHP r4utuNDgHdtGPZUg4LnO4n34F5nZ9bKm3kdYgQBQIXtjjCzLbO9foHbRmz546X4GESJg jyUYuaZc+OpXvaNMvBVmSFRKXXFWrKMsGz25eM0oeJd17tocpxjr97U0kgOdBkB5Zu5s Qj3fZ1a+5LOeVXHN+KxfY3qwy9hJUporyOLHL+8KjA2FaRiEPCKJu8heUB6g/h3qToQb sg4Pqjs47tkFd8Duz5h6bUw7qobooncJl5ILka8ymU2XaE9Cx+e5AGiFfr9viNjwZj/1 rzhw== 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; bh=PEmOMZeDK7rTy85osX4xQVlNZxs4RQ9XNIUjyZ8HIuE=; b=ALegcYjq4D+ApN1BEBfEfq4wac0OSFc5esCsGuaLWKu/OC4aG2+FhITIx3r6DvdnRQ +FZlL+u3oNGm921apiQWBTd4YGNGo8yDjx3NG3DF1g40mJlBre39AmE84rffOtUiVg0z c8r7rIUXapgyZ85nMbynRwAB0yb8TMuTIn6FuqifJGbtqmmII670vIEk4f8ivsOrp4gt v1kGUvJ+oJa5AN3Edkrp0fAPF41XLlt01pZe+GyqLCPinvLYVIyOCK6zw4AybSzDm+7s 28n+gT9mFIjycFLV3x37I8FL1BXAeHNknaxGh4rEBVtZXFJ6nhBoIH56CRiov9WqPgn3 sQXg== X-Gm-Message-State: ALKqPwcbDENkDgkjlXyJPP8l/RVFdejA5aOWeYhiIp1badSPBNLCclNU BhyGh7bdvKCyJbMjKC2hXEiOsxp2 X-Received: by 2002:a25:2e48:: with SMTP id b8-v6mr13779087ybn.90.1528221684348; Tue, 05 Jun 2018 11:01:24 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::1:f697]) by smtp.gmail.com with ESMTPSA id j19-v6sm5975037ywb.107.2018.06.05.11.01.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 11:01:23 -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 Subject: [PATCHSET v2] block: Separating discards from writes in Linux IO statistics Date: Tue, 5 Jun 2018 11:01:14 -0700 Message-Id: <20180605180120.2726113-1-tj@kernel.org> X-Mailer: git-send-email 2.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patchset was originally posted by Michael Callahan. https://marc.info/?l=linux-block&m=146541910129172&w=2 The patchset is refreshed on top of the current git master v4.17-1306-g716a685 and a patch was added to add discard stats for cgroup io.stat. The original patchset description from Michael follows. This patch set separates block layer statistics for discards from writes. Discards are currently bundled with writes in the various /sys/block/*/stat files as well as in /proc/diskstats. However discards are nearly always used to mark storage that is no longer in use. There are many reasons having discard not counted with writes is useful: 1) For many non volatile memory devices it is just nice to know that discards are enabled and working properly. 2) Discards have different performance characteristics than writes. They are generally much faster and larger and bundling them makes performance statistics less meaningful. 3) Discards are not writes in terms of tracking device lifetime. If a device supports six device writes per day it is nice to know how many writes have actually been written to the device as discards do not count against that total. Separation of discard statistics is accomplished by expanding the struct diskstat arrays to 3 entries for STAT_READ, STAT_WRITE, and STAT_DISCARD. A new rw_stat_group function is then used to convert from rw_flags (cmd_flags from requests, bi_rw from bios) into the appropriate stat group which is then tracked as before. Lastly the new statistics are appended to the current /sys/bloc/*/stat and /proc/diskstats on output such that they are the last four entries of each. These are analogous to the four read and write statistics. * Number of discard ios completed * Number of discard ios merged * Number of discard sectors completed * Milliseconds spent on discard requests. [before ~]# cat sys/block/nvme0/stat 296550701 0 2372405688 67317193 19672752 0 7972237312 9375167 0 2787238 79718726 [after ~]# cat sys/block/nvme0/stat 296550701 0 2372405688 67317193 18034352 0 4616794112 9125902 0 2787238 79718726 1638400 0 3355443200 249265 Note that the discards have moved out of the write fields to the end and that the write fields are now smaller by the difference. Adding the new statistics to the end of /sys/block/*/stat and /proc/diskstats is backwards compatible with both iostat and vmstat which pick up just the old fields: [root@after ~]# iostat -x Linux 4.5.0_68319_ge5065f4-dirty (##hostname###) 05/17/2016 _x86_64_ (48 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.41 0.00 0.23 0.01 0.00 99.35 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util sda 0.01 7.50 0.20 3.61 16.65 708.41 190.03 0.09 22.53 1.16 0.44 nvme0n1 0.00 0.00 587.03 35.70 4696.25 9139.08 22.22 0.16 0.24 0.01 0.55 [root@after ~]# vmstat -d disk- ------------reads------------ ------------writes----------- -----IO------ total merged sectors ms total merged sectors ms cur sec ram0 0 0 0 0 0 0 0 0 0 0 ram1 0 0 0 0 0 0 0 0 0 0 ram2 0 0 0 0 0 0 0 0 0 0 ram3 0 0 0 0 0 0 0 0 0 0 ram4 0 0 0 0 0 0 0 0 0 0 ram5 0 0 0 0 0 0 0 0 0 0 ram6 0 0 0 0 0 0 0 0 0 0 ram7 0 0 0 0 0 0 0 0 0 0 ram8 0 0 0 0 0 0 0 0 0 0 ram9 0 0 0 0 0 0 0 0 0 0 ram10 0 0 0 0 0 0 0 0 0 0 ram11 0 0 0 0 0 0 0 0 0 0 ram12 0 0 0 0 0 0 0 0 0 0 ram13 0 0 0 0 0 0 0 0 0 0 ram14 0 0 0 0 0 0 0 0 0 0 ram15 0 0 0 0 0 0 0 0 0 0 sda 102903 5247 8408420 47424 1820306 3782041 357153613 43320121 0 2228 nvme0n1 145633279 0 1165066312 18981333 13107200 0 3355443200 6663655 0 1796 loop0 0 0 0 0 0 0 0 0 0 0 loop1 0 0 0 0 0 0 0 0 0 0 [chop rest of loop devices] [root@after ~]# cat /sys/fs/cgroup/user.slice/io.stat 8:0 rbytes=3534848 wbytes=4096 rios=723 wios=1 dbytes=20592091136 dios=16189 This patchset contains the following six patches. 0001-block-make-bdev_ops-rw_page-take-a-REQ_OP-instead-of.patch 0002-block-Add-part_stat_read_accum-to-read-across-field-.patch 0003-block-Define-and-use-STAT_READ-and-STAT_WRITE.patch 0004-block-Add-and-use-op_stat_group-for-indexing-disk_st.patch 0005-block-Track-DISCARD-statistics-and-output-them-in-st.patch 0006-blkcg-Track-DISCARD-statistics-and-output-them-in-cg.patch and also available in the following git branch. git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git block-discard-stat diffstat follows. Thanks. Documentation/ABI/testing/procfs-diskstats | 10 ++++++++++ Documentation/admin-guide/cgroup-v2.rst | 10 ++++++---- Documentation/block/stat.txt | 28 ++++++++++++++++------------ Documentation/iostats.txt | 15 +++++++++++++++ block/bio.c | 16 +++++++++------- block/blk-cgroup.c | 14 ++++++++++---- block/blk-core.c | 12 ++++++------ block/genhd.c | 29 ++++++++++++++++++----------- block/partition-generic.c | 25 +++++++++++++++---------- drivers/block/brd.c | 14 +++++++------- drivers/block/drbd/drbd_receiver.c | 3 +-- drivers/block/drbd/drbd_req.c | 4 ++-- drivers/block/drbd/drbd_worker.c | 4 +--- drivers/block/rsxx/dev.c | 6 +++--- drivers/block/zram/zram_drv.c | 19 +++++++++---------- drivers/lightnvm/pblk-cache.c | 5 +++-- drivers/lightnvm/pblk-read.c | 5 +++-- drivers/md/bcache/request.c | 13 +++++-------- drivers/md/dm.c | 6 ++++-- drivers/md/md.c | 8 ++++---- drivers/nvdimm/btt.c | 12 ++++++------ drivers/nvdimm/nd.h | 7 +++---- drivers/nvdimm/pmem.c | 13 ++++++------- fs/block_dev.c | 6 ++++-- fs/ext4/super.c | 5 +++-- fs/ext4/sysfs.c | 6 ++++-- fs/f2fs/f2fs.h | 2 +- fs/f2fs/super.c | 3 ++- fs/mpage.c | 4 ++-- include/linux/bio.h | 4 ++-- include/linux/blk-cgroup.h | 5 ++++- include/linux/blk_types.h | 20 ++++++++++++++++++++ include/linux/blkdev.h | 2 +- include/linux/genhd.h | 14 ++++++++++---- 34 files changed, 215 insertions(+), 134 deletions(-) -- tejun