From patchwork Tue May 29 21:17:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10437087 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 00026602BF for ; Tue, 29 May 2018 21:17:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E59B028991 for ; Tue, 29 May 2018 21:17:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA9932899C; Tue, 29 May 2018 21:17:55 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 705BD28991 for ; Tue, 29 May 2018 21:17:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EAF56B0269; Tue, 29 May 2018 17:17:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 96FB96B026A; Tue, 29 May 2018 17:17:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C3C26B026B; Tue, 29 May 2018 17:17:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f198.google.com (mail-qt0-f198.google.com [209.85.216.198]) by kanga.kvack.org (Postfix) with ESMTP id 4F7FA6B0269 for ; Tue, 29 May 2018 17:17:40 -0400 (EDT) Received: by mail-qt0-f198.google.com with SMTP id f1-v6so14624946qth.2 for ; Tue, 29 May 2018 14:17:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=EjicLf9K/6JSWhW15jDjpVP8/botVJtyocgCDzgGgxk=; b=TPKRpWSAAyfrBMtSqcsQh9pK0X/0NgKFWMvzAZvXlOGjb5rxNpBBGwUdswQ2D828hW CmWeyW5ASSegxUkvLFDx+HlHKlOPTyOj8aOFw22j/0gGUS2Z0b+zhs3vDf2qtbyAxOWK ayXFWvt4MkDXohOqeEmuTruclN4RtYIGfFo/QOMnNvdUYT6rkkHMnuVwGy+K1O/YyBZ6 LI7Q5vBsHjP5KDb8KdNOVoBxkOBKtMo0CbXAk0N58ynIxwBbsZ9MR7q4RpbixJSO7UI3 7hRKaGUntgqEyMZJ1dPql1IzP2knXHgNphP3wBBAyFeZD8LDnZEAv7SgOe1aux+Fn72Y Nlpg== X-Gm-Message-State: APt69E0x7uMG0YxDp1G7q90ATDtDuVUuYZmhqOme74ErmU1iSzcZqBit w3Xs2rscVQDXYnWoltaonmfC/iv14BA3DozEITUvhB1Vnbm27YIjL7gt+YY0SDPmicpR4xcyVYF 3QM5Nww55JeQaO8+Ryzq3c8e07CE6TfqCRrqXhvxNxmQw6Ak8+c7vsSjuJ7Y1OeWy79J22BcS0d 3JqYzROO69q0dC6KzZe53WCOLXJXF16ZLf70Rkw69OSGxrqAc2wZidEHmiQWAWxPNVivm1IT3tk uMnBiQIBi0S9uMoE9RVuMAG2/ExCHq9+vNK/M5btDMzCy55eJTNN0IR40pp/GvnWR6DvutasUuw /VYx3xk7yCDm/HjXpdCXfOolMVUmRbFsoIP9dA3Q8NMx8QnMhF5IxNXT7iVySBxuXIhVPLLd9Sf u X-Received: by 2002:aed:2b63:: with SMTP id p90-v6mr81236qtd.342.1527628660109; Tue, 29 May 2018 14:17:40 -0700 (PDT) X-Received: by 2002:aed:2b63:: with SMTP id p90-v6mr81206qtd.342.1527628659533; Tue, 29 May 2018 14:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527628659; cv=none; d=google.com; s=arc-20160816; b=AJ1DVkXsLaANM6CZiOtCdM0D/O6ml9dohkW/6UF2+aGM1qzEhjQrfBsP1jgZwXXJQ1 EpxH3b/wJhQGqDBwb78ICDrdIIDsSXERwHDkdLC16dc9YWbsi/Hy+HLQaxqdvDlOwvgJ xewjMbKqR5/Nrkqwc2p5bK+87JjUyTE2IkMexsa9VZC58E3F91LxtwcKPFUbXsPaVhb+ fTmQjUQKXzQ7YY9mLidjGZjSu//UiceedMsjX/1FUsC9UM/EMIZ3LO948m4y6B+uhcmo gsSJRS6SOZZBH7BMpPAVz0ZTCpMTOGffFhhmkHE1y+GfYXpGFicTB3Ss8Yt9yWvH8wKn 46lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=EjicLf9K/6JSWhW15jDjpVP8/botVJtyocgCDzgGgxk=; b=lca7f7drZ8Qv5blkbd4l+6XSvRGOtznKzwxRN8/CqXcGeLYSbjIXd7nd4YR3rnMSf/ ttWPHEqDFuk0mNRnWv/5u8FpW4iQr/QGZX21NOlH9EALF8/CLf1VA112xqJF3YIoiAHj qzD6PI0RH9rUHiKIvHhlsCq29FHdWm1Bsrw8k3YnVTbXk6FJhZBlbK3ascGawK7fFzWj PZAmaVKqGZmnj8LlAZ6sXNH8UvvwInSk1JCqlMxHZiLx6iuAL0jCRWYIB8KxguWNDVwQ EDWeV3tXEp7xQHKYrlPVdNKEhAaZYX0+qJw2532BxdC2QgbeZ6nBrb36ktOsU95qEHJu 6dLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=bN8pg7b9; spf=neutral (google.com: 209.85.220.41 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id l3-v6sor7597846qkh.86.2018.05.29.14.17.39 for (Google Transport Security); Tue, 29 May 2018 14:17:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.41 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=bN8pg7b9; spf=neutral (google.com: 209.85.220.41 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EjicLf9K/6JSWhW15jDjpVP8/botVJtyocgCDzgGgxk=; b=bN8pg7b9rtKRkGuNtbwJm8FG6BBZ+lV9zQpRW9SLzTnJgFiYV//e5L1cQFFCLyXAPH wds2s+vcLyM3tzylg1+fkpsOdMl63V7YO6yWPBJQXwHfZAW4ee7ApBUoG148kSqlIy8j +g/gtY2nkDdX4xnt5WmrOn5j40LBJv5fG8TXMoTlrqjKVwT/fcgedILrezLEqnPIlwWJ aDJsqBTU2hWz1GJrDaBZpiQFiIC90yIf2lmqgEcz0Ajb+WDGpUZRiTCXqAuPcbJgLauP c+bTOHyZCj9UO3GYVNFTjZiZYWgpJ0zi3P3Ri4eG/GKzhlAytHL5KZnY6hAwfYHzZhqN /+Ww== X-Google-Smtp-Source: ADUXVKITArJXRT3Qo92f7LJYsUrATqDc1orwCDTVfRZYk7bv/XNnvkR6PAHSZKbbTfNrKx+nEX1SEA== X-Received: by 2002:a37:488d:: with SMTP id v135-v6mr45453qka.353.1527628659281; Tue, 29 May 2018 14:17:39 -0700 (PDT) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id n37-v6sm6437445qkh.71.2018.05.29.14.17.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 14:17:38 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, tj@kernel.org, linux-fsdevel@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 08/13] blk-stat: export helpers for modifying blk_rq_stat Date: Tue, 29 May 2018 17:17:19 -0400 Message-Id: <20180529211724.4531-9-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529211724.4531-1-josef@toxicpanda.com> References: <20180529211724.4531-1-josef@toxicpanda.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Bacik We need to use blk_rq_stat in the blkcg qos stuff, so export some of these helpers so they can be used by other things. Signed-off-by: Josef Bacik Acked-by: Tejun Heo --- block/blk-stat.c | 16 ++++++++-------- block/blk-stat.h | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/block/blk-stat.c b/block/blk-stat.c index 175c143ac5b9..7587b1c3caaf 100644 --- a/block/blk-stat.c +++ b/block/blk-stat.c @@ -17,7 +17,7 @@ struct blk_queue_stats { bool enable_accounting; }; -static void blk_stat_init(struct blk_rq_stat *stat) +void blk_rq_stat_init(struct blk_rq_stat *stat) { stat->min = -1ULL; stat->max = stat->nr_samples = stat->mean = 0; @@ -25,7 +25,7 @@ static void blk_stat_init(struct blk_rq_stat *stat) } /* src is a per-cpu stat, mean isn't initialized */ -static void blk_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src) +void blk_rq_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src) { if (!src->nr_samples) return; @@ -39,7 +39,7 @@ static void blk_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src) dst->nr_samples += src->nr_samples; } -static void __blk_stat_add(struct blk_rq_stat *stat, u64 value) +void blk_rq_stat_add(struct blk_rq_stat *stat, u64 value) { stat->min = min(stat->min, value); stat->max = max(stat->max, value); @@ -69,7 +69,7 @@ void blk_stat_add(struct request *rq, u64 now) continue; stat = &get_cpu_ptr(cb->cpu_stat)[bucket]; - __blk_stat_add(stat, value); + blk_rq_stat_add(stat, value); put_cpu_ptr(cb->cpu_stat); } rcu_read_unlock(); @@ -82,15 +82,15 @@ static void blk_stat_timer_fn(struct timer_list *t) int cpu; for (bucket = 0; bucket < cb->buckets; bucket++) - blk_stat_init(&cb->stat[bucket]); + blk_rq_stat_init(&cb->stat[bucket]); for_each_online_cpu(cpu) { struct blk_rq_stat *cpu_stat; cpu_stat = per_cpu_ptr(cb->cpu_stat, cpu); for (bucket = 0; bucket < cb->buckets; bucket++) { - blk_stat_sum(&cb->stat[bucket], &cpu_stat[bucket]); - blk_stat_init(&cpu_stat[bucket]); + blk_rq_stat_sum(&cb->stat[bucket], &cpu_stat[bucket]); + blk_rq_stat_init(&cpu_stat[bucket]); } } @@ -143,7 +143,7 @@ void blk_stat_add_callback(struct request_queue *q, cpu_stat = per_cpu_ptr(cb->cpu_stat, cpu); for (bucket = 0; bucket < cb->buckets; bucket++) - blk_stat_init(&cpu_stat[bucket]); + blk_rq_stat_init(&cpu_stat[bucket]); } spin_lock(&q->stats->lock); diff --git a/block/blk-stat.h b/block/blk-stat.h index 78399cdde9c9..f4a1568e81a4 100644 --- a/block/blk-stat.h +++ b/block/blk-stat.h @@ -159,4 +159,8 @@ static inline void blk_stat_activate_msecs(struct blk_stat_callback *cb, mod_timer(&cb->timer, jiffies + msecs_to_jiffies(msecs)); } +void blk_rq_stat_add(struct blk_rq_stat *, u64); +void blk_rq_stat_sum(struct blk_rq_stat *, struct blk_rq_stat *); +void blk_rq_stat_init(struct blk_rq_stat *); + #endif