Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6786348imm; Wed, 27 Jun 2018 13:23:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKItIlJW43r7sbjf6m1W5Ss9gwlKkaawyHJsAlSWwsWYflDUpHMXEsm4/wYkTj6+L1ByXCNN X-Received: by 2002:a17:902:4d:: with SMTP id 71-v6mr7571712pla.317.1530131019756; Wed, 27 Jun 2018 13:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530131019; cv=none; d=google.com; s=arc-20160816; b=jAhqyIhczKQj35gNnLtegLGU7dIRIv7CTg1r3EJvJOHnN2au1rxtKMuDjJGUljH2Mg N1VRoEGIKnr1s7PjIfZPJ9XE0qk2V7qoDQ9xMH84/BsThSVFt8MM5/LxZ4CRFiIdJozI /jtDbyPnWIyRE5R74d82QSVvQ9q9xLUfWhKCUvkoiKU+pjf3L5c92mkvK+vguDuM+QD4 ngYBv0A98aV51AKU5/4JFsMA9BjEIcQsQynSg1Ln3NIyoSxLcGwUzJxEXGXkJRYqZQ8q 9E/60DA58HIzXgwd9YTVpDtVe86ZVOhNkk4LN7sPZI2PVXeL8t1tQ1vs8URl2gt12zsm 972A== 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=JYqsln3cxLC6V4YRycWi8KDoQjt5FK6hI2vvMLKY4zYz8n6w4sKvwr/cgrKsz6EZap QViPXAi+rour0O+YuFZPNlC8GJ6poOPxpfi/q9NPikDzBMHGnBy5ZHwC9MumBaz/ANLi edG4FKA/M6+N/5pUoDy63u2fFS634cBEHr370CpHSUVDpsqNDPPZKh0XxYU+4oTARcNt i7svhPFicOlYj89LQ0VGF5LtXee81lk2fstLcX0MnFs4CrV8gr6C8mJled+TTgGxfWTS nCqcQhXnUacnhrmulLnb6LlcC3MwmDhFmuocvn6e3BvS3LNtxbc6/LjPH8/T1g8AijrF DE9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=fdtD6CAa; 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 j189-v6si4917984pfg.351.2018.06.27.13.23.25; Wed, 27 Jun 2018 13:23:39 -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=fdtD6CAa; 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 S966268AbeF0TKF (ORCPT + 99 others); Wed, 27 Jun 2018 15:10:05 -0400 Received: from mail-qk0-f170.google.com ([209.85.220.170]:34896 "EHLO mail-qk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965600AbeF0TJ4 (ORCPT ); Wed, 27 Jun 2018 15:09:56 -0400 Received: by mail-qk0-f170.google.com with SMTP id u21-v6so1662603qku.2 for ; Wed, 27 Jun 2018 12:09:55 -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=fdtD6CAamSA0d3nx5genLB13qOR/4Gj5QrNv0eS4KJQh5smW40/mcbSZHU8SBjCV2o qkFG13rx2OpR0gno7KAfHfqldCxg+8j/w5vnapigVslu7xXYu0/VkG8LmK9z6vix03aR 5+rzCgY9KzGJu9dQpika0HQFITHyDYl9yQO0dFGsfR7goMO79Wl5p58gXr5m8ePNDRyf oRaRmTfCHv/DF2BpydGLJr01iHu7np+77atHxImGgRTXFvN0w5bwe/so/Ii7lMhzbrnt iYMYWgst3zTKztinMZ3SpeDY+O8D1PJWCckvn9/1Uwp3vvQKt+s5caAaplPNIDaweG6k aCLg== 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=ZyzHzXYJSE5IRNrKMb82UJCdvPCQxgvAKzTld4ngFfHzGqvVnXaDpWSv2eDf7p/bNj En2Yjc/SkJD8TEshMoH6FTHIIaBBxmxlroWKBPKe0GMK1n8oGlGIMntaa5/Y4JB8rTZc s89DJN5nMqN3I5EWaS7eZDny4xpIPJwuIHTe3LXkNrbnSX3AVJz+alYK0ltODOgr4u+G xdqFHf9Tspy88hVfqekcB2A5bu4R37gfi1tFxaZFMnhwcmCwDezeRxGIm9gJfQH+f1L4 lQEd6cJHgTNG5F7rmLAY6vKkvYJmX+cdDnSQ5iRhtAR8eIUThgkSv0LXU0ojC9dcHg6h 14HQ== X-Gm-Message-State: APt69E1oW7Ua9wWI7DCcHR0VT6veqvPVx6A9h4gtsedc3pitjKODfwzp CXkZYbSpy9sb3pwBPqWYjktqjA== X-Received: by 2002:a37:f50a:: with SMTP id l10-v6mr6187443qkk.109.1530126595292; Wed, 27 Jun 2018 12:09:55 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id n24-v6sm3682582qkh.39.2018.06.27.12.09.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Jun 2018 12:09:54 -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, tj@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 08/14] blk-stat: export helpers for modifying blk_rq_stat Date: Wed, 27 Jun 2018 15:09:34 -0400 Message-Id: <20180627190940.4696-9-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180627190940.4696-1-josef@toxicpanda.com> References: <20180627190940.4696-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