From patchwork Tue May 17 21:47:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Callahan X-Patchwork-Id: 9115291 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 114FCBF29F for ; Tue, 17 May 2016 21:47:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1C4E2022D for ; Tue, 17 May 2016 21:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0FC222022A for ; Tue, 17 May 2016 21:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751832AbcEQVrX (ORCPT ); Tue, 17 May 2016 17:47:23 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34440 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751597AbcEQVrX (ORCPT ); Tue, 17 May 2016 17:47:23 -0400 Received: by mail-lf0-f66.google.com with SMTP id m101so2046869lfi.1 for ; Tue, 17 May 2016 14:47:22 -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=o0nfLWhcpcys0S/fG5lIY6OygBd+amIaCMBSTHPairg=; b=xwlV1oFUDRXu0jZfAy4sMRneNaKkxu93RrApMYFfLHRmOWDGnV40giiqlJ+G0tg/6D ebWeLUKdZYrncMQmjCgVkYjHd2bn1RAH4HlBGiECFS5hQJSzpWsVo6x19CsqVg/CPQuB 7gB7qGmwCM3i2LmBkPb9q7PWrPctqAkX3FGOAwa3D0a3edPUGg1RM+yVyjJDITScYd4Z o/b2yhMyXJ1KmJN0o8b1voybiCsQ+YLLANUphPa7W/db5325sxJblvefwOmirgfChJHi VGNhPreIYvuuqcbEA2HO1yFV97CEHjTD8SrlXPnTj4sIjngdIhpI51nluBc3iw8eFkc7 9Fjw== 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=o0nfLWhcpcys0S/fG5lIY6OygBd+amIaCMBSTHPairg=; b=WndJgLRPJOng2JHbZFfR4/qh6hY9XOQNT/hPMfQg+fzzaRFiExEcIw3vL+qD/PiJtk QxguRqHOgwGQByuZJKam5pKofNY93eEeVLkJ1rnetsimPYK8bOssqk/ZXi/tggvAUD1a JHgVQFGms7tNfxTpNM+uNJqbeh+GpvcP4tOzDcyVS21IIQ7Oq3DuQ7cNnn8nrvrOLsjd oTkNFSOmTt3Os8Z8sR6nfNfcs4ikFjrC1nKSl9uMlcHkBvSOAUjX4fQKz+OCIt/spsPn J27oP0yhtGLrYRcFWlYXLuPRzN+zBCFi9vEmGvM4QEurbkN9cAktgBRZfb9TzlD/uaub cdBA== X-Gm-Message-State: AOPr4FVr+51ouU2HshoHpIGz9QhihugrOsCAqMiEu8S9lxix7KrOKguOWRCEETuON//dejnf5+oC56PeavYZnQ== MIME-Version: 1.0 X-Received: by 10.25.162.76 with SMTP id l73mr1369729lfe.45.1463521640942; Tue, 17 May 2016 14:47:20 -0700 (PDT) Received: by 10.25.148.69 with HTTP; Tue, 17 May 2016 14:47:20 -0700 (PDT) Date: Tue, 17 May 2016 15:47:20 -0600 Message-ID: Subject: [PATCH v2 1/4] block: Add part_stat_read_accum to read across field entries. 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 a part_stat_read_accum macro to genhd.h to read and sum across field entries. For example to sum up the number read and write sectors completed. In addition to being ar reasonable cleanup by itself this will make it easier to add new stat fields in the future. Signed-off-by: Michael Callahan drivers/block/drbd/drbd_receiver.c | 3 +-- drivers/block/drbd/drbd_worker.c | 4 +--- drivers/md/md.c | 3 +-- include/linux/genhd.h | 4 ++++ 4 files changed, 7 insertions(+), 7 deletions(-) --- -- 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/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 050aaa1..3d490a7 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -2504,8 +2504,7 @@ bool drbd_rs_c_min_rate_throttle(struct drbd_device *device) if (c_min_rate == 0) return false; - curr_events = (int)part_stat_read(&disk->part0, sectors[0]) + - (int)part_stat_read(&disk->part0, sectors[1]) - + curr_events = (int)part_stat_read_accum(&disk->part0, sectors) - atomic_read(&device->rs_sect_ev); if (atomic_read(&device->ap_actlog_cnt) diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index 4d87499..3e56209 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c @@ -1591,9 +1591,7 @@ void drbd_rs_controller_reset(struct drbd_device *device) atomic_set(&device->rs_sect_in, 0); atomic_set(&device->rs_sect_ev, 0); device->rs_in_flight = 0; - device->rs_last_events = - (int)part_stat_read(&disk->part0, sectors[0]) + - (int)part_stat_read(&disk->part0, sectors[1]); + device->rs_last_events = (int)part_stat_read_accum(&disk->part0, sectors); /* Updating the RCU protected object in place is necessary since this function gets called from atomic context. diff --git a/drivers/md/md.c b/drivers/md/md.c index 14d3b37..9fc8d1e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -7626,8 +7626,7 @@ static int is_mddev_idle(struct mddev *mddev, int init) rcu_read_lock(); rdev_for_each_rcu(rdev, mddev) { struct gendisk *disk = rdev->bdev->bd_contains->bd_disk; - curr_events = (int)part_stat_read(&disk->part0, sectors[0]) + - (int)part_stat_read(&disk->part0, sectors[1]) - + curr_events = (int)part_stat_read_accum(&disk->part0, sectors) - atomic_read(&disk->sync_io); /* sync IO will cause sync_io to increase before the disk_stats * as sync_io is counted when a request starts, and diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 5c70676..b73559a 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -381,6 +381,10 @@ static inline void free_part_stats(struct hd_struct *part) #endif /* CONFIG_SMP */ +#define part_stat_read_accum(part, field) \ + (part_stat_read(part, field[0]) + \ + part_stat_read(part, field[1])) + #define part_stat_add(cpu, part, field, addnd) do { \ __part_stat_add((cpu), (part), field, addnd); \ if ((part)->partno) \