From patchwork Tue May 17 21:56:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Callahan X-Patchwork-Id: 9115371 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C19B09F1C1 for ; Tue, 17 May 2016 21:56:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82B552022A for ; Tue, 17 May 2016 21:56:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7C6C20148 for ; Tue, 17 May 2016 21:56:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751191AbcEQV4t (ORCPT ); Tue, 17 May 2016 17:56:49 -0400 Received: from mail-lb0-f196.google.com ([209.85.217.196]:32940 "EHLO mail-lb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054AbcEQV4s (ORCPT ); Tue, 17 May 2016 17:56:48 -0400 Received: by mail-lb0-f196.google.com with SMTP id qf3so1754596lbb.0 for ; Tue, 17 May 2016 14:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc; bh=zL7EHKgHaLReVU18borgNKLu+ds/R2Sl2ulI0kPEOWg=; b=oeKmhBiZhTp11H6ihNlTxwtmqoCEZyXKBlT4A5G536cKUFtzuMX2IkvkH8P1qAkL0b qe/b9B6bcmH6uqV7x4ySa1DNhp8lQKAZw5FLe87lC0kMUDMAmAXcpYMxdy1HtGYGasnE mhkvaLHRPlDTAEuhEHZ2+W5mSgcqezE34hex9/o5bJ+pzpD/BM4i/Q+YlHUwny1ZJ1Ro XeiKlY5PrV4Abpoz5KkwP0BWcHGnPvqTJyITzTaR9ffDQBU0uDO46pL2KC/xpGLc0vAK xiITx7OFwrgwMQPn8UTjHdT6b1QRAVJlWpVZwTd8yCHxppGj6CE8PffN+LFODQ59VFyP frfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=zL7EHKgHaLReVU18borgNKLu+ds/R2Sl2ulI0kPEOWg=; b=Pm0v0g7GeMwej3zFEH+T/0KBua87eZoZk8NvOA3PcxQnD5gN5JHZZC3U80DWdjSmF3 sS7v7Sj1Ap4OfyXQdBkCKMRwXg8yAVwfTG0LrW8tXlDYIazIMN9TpYQ3lZtQBWJLftI5 ZW4vUhET3kfEqRfM6jI5rUxpnZFJC1bQQuLHPhTpdoku3JdhK25apkVuab4b4dHJyVfJ YB0OEQTJv2x20n/OVRdnU+E4K2dKsb5ygbmxRks7UChDLvBzfnX1pzx7BqtfNBPOyPYW 0X5nF3dsjcJLE54divqsmpiuUSUM7bPRnGZ4OqiMean+R0pTnjeUnsSPqhfXy+QyRTbz e47w== X-Gm-Message-State: AOPr4FWdgCwVnqg37upbA0n+mRA++oAgcvxJvjNjO/b6PFH4s5v2vNmXGOE6CkwvzhIg4G7G2PB0LI/q/sV22A== MIME-Version: 1.0 X-Received: by 10.112.199.198 with SMTP id jm6mr1442615lbc.80.1463522206827; Tue, 17 May 2016 14:56:46 -0700 (PDT) Received: by 10.25.148.69 with HTTP; Tue, 17 May 2016 14:56:46 -0700 (PDT) Date: Tue, 17 May 2016 15:56:46 -0600 Message-ID: Subject: [PATCH v2 4/4] block: Track DISCARD statistics and output them in stat and diskstat. From: Michael Callahan To: linux-block@vger.kernel.org Cc: Michael Callahan , Jens Axboe Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add tracking of REQ_DISCARD ios to the partition statistics and append them to the various stat files in /sys as well as /proc/diskstats. These are tracked with the same four stats as reads and writes: Number of discard ios completed. Number of discard ios merged Number of discard sectors completed Milliseconds spent on discard requests This is done via adding a new STAT_DISCARD define to genhd.h and then using it to index that stat field for discard requests. Signed-off-by: Michael Callahan --- }; @@ -386,7 +387,8 @@ static inline void free_part_stats(struct hd_struct *part) #define part_stat_read_accum(part, field) \ (part_stat_read(part, field[STAT_READ]) + \ - part_stat_read(part, field[STAT_WRITE])) + part_stat_read(part, field[STAT_WRITE]) + \ + part_stat_read(part, field[STAT_DISCARD])) #define part_stat_add(cpu, part, field, addnd) do { \ __part_stat_add((cpu), (part), field, addnd); \ @@ -436,6 +438,8 @@ static inline void free_part_info(struct hd_struct *part) static inline int rw_stat_group(unsigned int rw_flags) { + if (rw_flags & REQ_DISCARD) + return STAT_DISCARD; return (rw_flags & REQ_WRITE) != 0; } -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/ABI/testing/procfs-diskstats b/Documentation/ABI/testing/procfs-diskstats index f91a973..0a5c005 100644 --- a/Documentation/ABI/testing/procfs-diskstats +++ b/Documentation/ABI/testing/procfs-diskstats @@ -5,6 +5,7 @@ Description: The /proc/diskstats file displays the I/O statistics of block devices. Each line contains the following 14 fields: + 1 - major number 2 - minor mumber 3 - device name @@ -19,4 +20,13 @@ Description: 12 - I/Os currently in progress 13 - time spent doing I/Os (ms) 14 - weighted time spent doing I/Os (ms) + + Kernel 4.7 appends four more fields for discard tracking + putting the total at 18: + + 15 - discards completed successfully + 16 - discards merged + 17 - sectors discarded + 18 - time spent discarding + For more details refer to Documentation/iostats.txt diff --git a/Documentation/block/stat.txt b/Documentation/block/stat.txt index 0dbc946..0aace9c 100644 --- a/Documentation/block/stat.txt +++ b/Documentation/block/stat.txt @@ -31,28 +31,32 @@ write ticks milliseconds total wait time for write requests in_flight requests number of I/Os currently in flight io_ticks milliseconds total time this block device has been active time_in_queue milliseconds total wait time for all requests +discard I/Os requests number of discard I/Os processed +discard merges requests number of discard I/Os merged with in-queue I/O +discard sectors sectors number of sectors discarded +discard ticks milliseconds total wait time for discard requests -read I/Os, write I/Os -===================== +read I/Os, write I/Os, discard I/0s +=================================== These values increment when an I/O request completes. -read merges, write merges -========================= +read merges, write merges, discard merges +========================================= These values increment when an I/O request is merged with an already-queued I/O request. -read sectors, write sectors -=========================== +read sectors, write sectors, discard_sectors +============================================ -These values count the number of sectors read from or written to this -block device. The "sectors" in question are the standard UNIX 512-byte -sectors, not any device- or filesystem-specific block size. The -counters are incremented when the I/O completes. +These values count the number of sectors read from, written to, or +discarded from this block device. The "sectors" in question are the +standard UNIX 512-byte sectors, not any device- or filesystem-specific +block size. The counters are incremented when the I/O completes. -read ticks, write ticks -======================= +read ticks, write ticks, discard ticks +====================================== These values count the number of milliseconds that I/O requests have waited on this block device. If there are multiple I/O requests waiting, diff --git a/Documentation/iostats.txt b/Documentation/iostats.txt index 65f694f..7b9609e 100644 --- a/Documentation/iostats.txt +++ b/Documentation/iostats.txt @@ -22,7 +22,6 @@ Here are examples of these different formats: 3 0 39082680 hda 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 3376340 23705160 3 1 9221278 hda1 35486 0 35496 38030 0 0 0 0 0 38030 38030 - 2.6 sysfs: 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 3376340 23705160 35486 38030 38030 38030 @@ -31,6 +30,9 @@ Here are examples of these different formats: 3 0 hda 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 3376340 23705160 3 1 hda1 35486 38030 38030 38030 +4.7 diskstats: + 3 0 hda 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 3376340 23705160 0 0 0 0 + On 2.4 you might execute "grep 'hda ' /proc/partitions". On 2.6, you have a choice of "cat /sys/block/hda/stat" or "grep 'hda ' /proc/diskstats". The advantage of one over the other is that the sysfs choice works well @@ -90,6 +92,17 @@ Field 11 -- weighted # of milliseconds spent doing I/Os last update of this field. This can provide an easy measure of both I/O completion time and the backlog that may be accumulating. +In 4.7 appends the following four fields for discard tracking: + +Field 12 -- # of discards completed + This is the total number of discards completed successfully. +Field 13 -- # of discards merged + See the description of field 2 +Field 14 -- # of sectors discarded + This is the total number of sectors discarded successfully. +Field 15 -- # of milliseconds spent discarding + This is the total number of milliseconds spent by all discards (as + measured from __make_request() to end_that_request_last()). To avoid introducing performance bottlenecks, no locks are held while modifying these counters. This implies that minor inaccuracies may be diff --git a/block/genhd.c b/block/genhd.c index b6f1dee..1b558dc 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1195,8 +1195,12 @@ static int diskstats_show(struct seq_file *seqf, void *v) cpu = part_stat_lock(); part_round_stats(cpu, hd); part_stat_unlock(); - seq_printf(seqf, "%4d %7d %s %lu %lu %lu " - "%u %lu %lu %lu %u %u %u %u\n", + seq_printf(seqf, "%4d %7d %s " + "%lu %lu %lu %u " + "%lu %lu %lu %u " + "%u %u %u " + "%lu %lu %lu %u" + "\n", MAJOR(part_devt(hd)), MINOR(part_devt(hd)), disk_name(gp, hd->partno, buf), part_stat_read(hd, ios[STAT_READ]), @@ -1209,7 +1213,11 @@ static int diskstats_show(struct seq_file *seqf, void *v) jiffies_to_msecs(part_stat_read(hd, ticks[STAT_WRITE])), part_in_flight(hd), jiffies_to_msecs(part_stat_read(hd, io_ticks)), - jiffies_to_msecs(part_stat_read(hd, time_in_queue)) + jiffies_to_msecs(part_stat_read(hd, time_in_queue)), + part_stat_read(hd, ios[STAT_DISCARD]), + part_stat_read(hd, merges[STAT_DISCARD]), + part_stat_read(hd, sectors[STAT_DISCARD]), + jiffies_to_msecs(part_stat_read(hd, ticks[STAT_DISCARD])) ); } disk_part_iter_exit(&piter); diff --git a/block/partition-generic.c b/block/partition-generic.c index 15bf298..0f18368 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -121,7 +121,8 @@ ssize_t part_stat_show(struct device *dev, return sprintf(buf, "%8lu %8lu %8llu %8u " "%8lu %8lu %8llu %8u " - "%8u %8u %8u" + "%8u %8u %8u " + "%8lu %8lu %8llu %8u" "\n", part_stat_read(p, ios[STAT_READ]), part_stat_read(p, merges[STAT_READ]), @@ -133,7 +134,11 @@ ssize_t part_stat_show(struct device *dev, jiffies_to_msecs(part_stat_read(p, ticks[STAT_WRITE])), part_in_flight(p), jiffies_to_msecs(part_stat_read(p, io_ticks)), - jiffies_to_msecs(part_stat_read(p, time_in_queue))); + jiffies_to_msecs(part_stat_read(p, time_in_queue)), + part_stat_read(p, ios[STAT_DISCARD]), + part_stat_read(p, merges[STAT_DISCARD]), + (unsigned long long)part_stat_read(p, sectors[STAT_DISCARD]), + jiffies_to_msecs(part_stat_read(p, ticks[STAT_DISCARD]))); } ssize_t part_inflight_show(struct device *dev, diff --git a/include/linux/genhd.h b/include/linux/genhd.h index db96322..ac2afe5 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -61,6 +61,7 @@ enum { #define STAT_READ 0 #define STAT_WRITE 1 +#define STAT_DISCARD 2 #include #include @@ -83,10 +84,10 @@ struct partition { } __attribute__((packed)); struct disk_stats { - unsigned long sectors[2]; /* STAT_READs and STAT_WRITEs */ - unsigned long ios[2]; - unsigned long merges[2]; - unsigned long ticks[2]; + unsigned long sectors[3]; /* STAT_READ, STAT_WRITE, STAT_DISCARD */ + unsigned long ios[3]; + unsigned long merges[3]; + unsigned long ticks[3]; unsigned long io_ticks; unsigned long time_in_queue;