From patchwork Fri Aug 4 15:04:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9881493 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 88E3D6031B for ; Fri, 4 Aug 2017 15:04:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79FA6289D3 for ; Fri, 4 Aug 2017 15:04:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E860289E2; Fri, 4 Aug 2017 15:04:31 +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=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 F3915289D3 for ; Fri, 4 Aug 2017 15:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752131AbdHDPEa (ORCPT ); Fri, 4 Aug 2017 11:04:30 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:38584 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752070AbdHDPE3 (ORCPT ); Fri, 4 Aug 2017 11:04:29 -0400 Received: by mail-io0-f170.google.com with SMTP id g71so6831540ioe.5 for ; Fri, 04 Aug 2017 08:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U3tssGF94tBkLywerNBCzohTr2RYeSO0G2t3e8nOSWs=; b=I2H7FKgqFv7cVepl7Z4YA2ZEmkMI1cXoGHCAyTHbjBBIja7yb0mHi0C2+iMJJ2n/Fb 1aDqRN/UFPbzzbwtgWcO5rNxlbJpEzLc80yXNwzkHLlZC59s346jT3v0M2xoWb7FTK6p kytZpwscrYQYOictqo3LBvTt7yTVjFGileoFYfE82LzVrbSNM5BtUK+70tvocoW5pQLb DwMkrXX4nrU7dmgfiogK2KcNuqcQIy7PFsuQ+J91Bnr+pZ3n17TIRYa/LlKYKI8YzJKI jOVSBiiZ7Ii5VybyjRDG8AzKYs4djFXzFH6oB/xAgmQfe+4gKXUJJTc9R5V78A242KTc qvGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U3tssGF94tBkLywerNBCzohTr2RYeSO0G2t3e8nOSWs=; b=HrfBMLXVQP7kRASU00nlBRCGFmgBJiPCGvg7TDlpoIU/UsPMzFuw2TM4f8/4/9buhZ a/Hstf+wXkWVGsyDYesPN2qdJ0uRvnzh8t0lBsrQpURd7bbL4NMQAAqOz7kTuqV95IYG M5NYRwgN7Geepagu5QwRW3EaU5lsfn5emHzgDU5BImzZ1qv3TMbgaE3WSiAKPwQSGzup wxz+ZivE+pqqDR4SprpgZSIOvwZiOS+S3WXYfNkqJMm9IcXGWJyEs7GECLnWHzC8bmMl ee9w0qmXE3XxfkcJ9BSDH6CGv4LFcPOlAVNDK/RjBfwL2OEIqUi03EoJyfk2yUGwhg6z nvVQ== X-Gm-Message-State: AHYfb5gzvw7vEU0hMJ4VDDspJkXV/lyLc7wjAY0JkxI5H9OQJLXJe3zU diP06oIDgeYgDm5Kpdt7/Q== X-Received: by 10.107.189.194 with SMTP id n185mr3234573iof.36.1501859068336; Fri, 04 Aug 2017 08:04:28 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id w207sm763245itc.34.2017.08.04.08.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Aug 2017 08:04:27 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org Cc: brking@linux.vnet.ibm.com, bart.vanassche@wdc.com, Jens Axboe Subject: [PATCH 3/6] block: make part_in_flight() take an array of two ints Date: Fri, 4 Aug 2017 09:04:19 -0600 Message-Id: <1501859062-11120-4-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501859062-11120-1-git-send-email-axboe@kernel.dk> References: <1501859062-11120-1-git-send-email-axboe@kernel.dk> 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 Instead of returning the count that matches the partition, pass in an array of two ints. Index 0 will be filled with the inflight count for the partition in question, and index 1 will filled with the root infligh count, if the partition passed in is not the root. This is in preparation for being able to calculate both in one go. Signed-off-by: Jens Axboe Reviewed-by: Bart Van Assche Reviewed-by: Omar Sandoval --- block/blk-core.c | 8 ++++---- block/genhd.c | 4 +++- block/partition-generic.c | 4 +++- include/linux/genhd.h | 12 +++++++++--- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 8ee954c12e9d..6ad2b8602c1d 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1472,15 +1472,15 @@ static void add_acct_request(struct request_queue *q, struct request *rq, static void part_round_stats_single(struct request_queue *q, int cpu, struct hd_struct *part, unsigned long now) { - int inflight; + int inflight[2]; if (now == part->stamp) return; - inflight = part_in_flight(q, part); - if (inflight) { + part_in_flight(q, part, inflight); + if (inflight[0]) { __part_stat_add(cpu, part, time_in_queue, - inflight * (now - part->stamp)); + inflight[0] * (now - part->stamp)); __part_stat_add(cpu, part, io_ticks, (now - part->stamp)); } part->stamp = now; diff --git a/block/genhd.c b/block/genhd.c index f735af67a0c9..822f65f95e2a 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1204,6 +1204,7 @@ static int diskstats_show(struct seq_file *seqf, void *v) struct disk_part_iter piter; struct hd_struct *hd; char buf[BDEVNAME_SIZE]; + unsigned int inflight[2]; int cpu; /* @@ -1219,6 +1220,7 @@ static int diskstats_show(struct seq_file *seqf, void *v) cpu = part_stat_lock(); part_round_stats(gp->queue, cpu, hd); part_stat_unlock(); + part_in_flight(gp->queue, hd, inflight); seq_printf(seqf, "%4d %7d %s %lu %lu %lu " "%u %lu %lu %lu %u %u %u %u\n", MAJOR(part_devt(hd)), MINOR(part_devt(hd)), @@ -1231,7 +1233,7 @@ static int diskstats_show(struct seq_file *seqf, void *v) part_stat_read(hd, merges[WRITE]), part_stat_read(hd, sectors[WRITE]), jiffies_to_msecs(part_stat_read(hd, ticks[WRITE])), - part_in_flight(gp->queue, hd), + inflight[0], jiffies_to_msecs(part_stat_read(hd, io_ticks)), jiffies_to_msecs(part_stat_read(hd, time_in_queue)) ); diff --git a/block/partition-generic.c b/block/partition-generic.c index d1bdd61e1d71..fa5049a4d99b 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -113,11 +113,13 @@ ssize_t part_stat_show(struct device *dev, { struct hd_struct *p = dev_to_part(dev); struct request_queue *q = dev_to_disk(dev)->queue; + unsigned int inflight[2]; int cpu; cpu = part_stat_lock(); part_round_stats(q, cpu, p); part_stat_unlock(); + part_in_flight(q, p, inflight); return sprintf(buf, "%8lu %8lu %8llu %8u " "%8lu %8lu %8llu %8u " @@ -131,7 +133,7 @@ ssize_t part_stat_show(struct device *dev, part_stat_read(p, merges[WRITE]), (unsigned long long)part_stat_read(p, sectors[WRITE]), jiffies_to_msecs(part_stat_read(p, ticks[WRITE])), - part_in_flight(q, p), + inflight[0], jiffies_to_msecs(part_stat_read(p, io_ticks)), jiffies_to_msecs(part_stat_read(p, time_in_queue))); } diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 7f7427e00f9c..a9c8ea632fdc 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -378,11 +378,17 @@ static inline void part_dec_in_flight(struct request_queue *q, atomic_dec(&part_to_disk(part)->part0.in_flight[rw]); } -static inline int part_in_flight(struct request_queue *q, - struct hd_struct *part) +static inline void part_in_flight(struct request_queue *q, + struct hd_struct *part, + unsigned int inflight[2]) { - return atomic_read(&part->in_flight[0]) + + inflight[0] = atomic_read(&part->in_flight[0]) + atomic_read(&part->in_flight[1]); + if (part->partno) { + part = &part_to_disk(part)->part0; + inflight[1] = atomic_read(&part->in_flight[0]) + + atomic_read(&part->in_flight[1]); + } } static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk)