Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4012976imm; Mon, 25 Jun 2018 08:18:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJm1KgxfRq6lcruXkg974257nIBoiIvB/Ta4zRw6LvQR0veYQJXkhTiCMuFld7SacBDvDDE X-Received: by 2002:a63:2b15:: with SMTP id r21-v6mr11292436pgr.262.1529939906310; Mon, 25 Jun 2018 08:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529939906; cv=none; d=google.com; s=arc-20160816; b=GkYPAXtgArBWjdhr2OU9qnxsqrL6cU9OU9FqyOHKO4w5PIpV8GhocB6qysei4D0xKR OslvwcWjAxgmoQE/ILDTaf3ibSa81MNa8ARPBCxqqvFSo6A0tOWgokaJjcDppRv5UKnl Dd4+EMIgB6lv2JvWCTCiFZKfsjggb30FFP0ec1oCuxJdaIsHURZC8fca3Kx7sW/XaR6H gMqPqpQ5Sn/Nr+upv7CGGRWjDwACZs0ogt9VoJTlhFhKHRF6xu0JjI+XPuChYZRPEwr/ V6Q5ev6tS4XnEcieEjmnlZi+1czmrnTEbMUAZJpIzvgqZdObvdDLdBnjVg8OSc31oFe5 exRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=a9+UtxgxIpUvzBRIeHZNXw5T1d8Q+T1w06fzA+96JXU=; b=GwW7CT0Hko4/7je3adHvEbdR6cL9u3+QaIC7RcWhRnjlATvULSTfwkE+4mJUcocHfY jQO9kAGtA72qQgZN2aX1yB08bD4TIsgwe/txDDiBmwIi/ha5Qts6V9QvyjdjfEXNRejT GUPDx/FDAnVvhOD+P6Wav6r1FOkgYaVKrnv7S5SeZecVzmLMbEG96XB3+D9c8R4KnwYJ 97jNsxP+Jpw3NXQL2nyGDmHuSa6zg/NyqgSA8Dcat9GX8pYmpVPpHeAdponLc6/UH5Qy EY6GzhL6Q/Fj9GZWrCODToKykO1/P1r0LWaUQfgyyAp8ay/cGyz4rkcmAwGkkhdLNMm1 VaVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=f0i75apv; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j15-v6si3006554pgs.260.2018.06.25.08.18.08; Mon, 25 Jun 2018 08:18:26 -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=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=f0i75apv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935044AbeFYPP7 (ORCPT + 99 others); Mon, 25 Jun 2018 11:15:59 -0400 Received: from mail-qt0-f169.google.com ([209.85.216.169]:43630 "EHLO mail-qt0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934829AbeFYPM6 (ORCPT ); Mon, 25 Jun 2018 11:12:58 -0400 Received: by mail-qt0-f169.google.com with SMTP id y89-v6so12221006qtd.10 for ; Mon, 25 Jun 2018 08:12:58 -0700 (PDT) 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=a9+UtxgxIpUvzBRIeHZNXw5T1d8Q+T1w06fzA+96JXU=; b=f0i75apv5CcC6A4NtbZFOuDX8mNvy+JkhnvR8z2395GXbvdsJBA/eE+pPzKibDgmIP nwttLkF0cV1m81a5GPoQRXehdRW06JUXNfPkIDbrQQ/K06/3q2r2XnN+Z5ZKSRlDEc04 Oy4MnqCREBmQOlZ+UrSswGJRwpsKUyaCaa8p9BrFXLcM2n/X8RLASNgiVHyGnaW1yTZG soar7GtkJClJnitoCtpECLTTGBURRn6B66sIss9+M64b+WJLwsQn81ptNJZxisn7fzoQ KqPIEffYhjkeK4L2aqFhnsrY8UaW94ms2b57y6vOTSU1HycdjEomMjaZyDb7WXSTMhZo cDLw== 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=a9+UtxgxIpUvzBRIeHZNXw5T1d8Q+T1w06fzA+96JXU=; b=gRm5agnR7orUnDLCx5b27+BUtXo9HF++SfbgIAKtJoiyroX00AhmlGUx+j91AUOm0m 1m65RjH9/BH0pRQVs1k/ljHUlEIWjfgYhfWxGRN8DO6Wjs5Tdv9giyYGOOW2xOkUYAm+ gFWR/bt3+gtQPzFDbNXhvk5axGqh8NFfwIHMiCNVlgO5G6hmm1/TnbFr91KvAtyvtLVm siYT7dlwkW6G9ibVhoFmiAjGQpiGjAX7XB+04Fe/zrGRbTqmpquNzZ9NLCFfjLEPk5Xp NSfIxfs9B2w+1DitWRA7GRyz3uaai7xCPNavY3zf0AoL8yrC0riDYfZ59tfGufwoX1aO kxcg== X-Gm-Message-State: APt69E1SkInIJKwklt6BFpHoj1CszKfcA9+dXBzw+BpJo2M59JZmdO/g xGx8OdGRhyLyenqPdGIVNuYAJA== X-Received: by 2002:ac8:329c:: with SMTP id z28-v6mr5126618qta.330.1529939577655; Mon, 25 Jun 2018 08:12:57 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id 20-v6sm4214320qts.28.2018.06.25.08.12.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 08:12:57 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, linux-block@vger.kernel.org, kernel-team@fb.com, akpm@linux-foundation.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, tj@kernel.org, linux-fsdevel@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 08/15] blk-stat: export helpers for modifying blk_rq_stat Date: Mon, 25 Jun 2018 11:12:36 -0400 Message-Id: <20180625151243.2132-9-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180625151243.2132-1-josef@toxicpanda.com> References: <20180625151243.2132-1-josef@toxicpanda.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.14.3