From patchwork Tue Feb 7 17:24:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 93574 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2301782qgi; Tue, 7 Feb 2017 09:25:43 -0800 (PST) X-Received: by 10.98.211.8 with SMTP id q8mr21132852pfg.164.1486488343444; Tue, 07 Feb 2017 09:25:43 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l24si4648144pgn.200.2017.02.07.09.25.43; Tue, 07 Feb 2017 09:25:43 -0800 (PST) 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=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755499AbdBGRZU (ORCPT + 25 others); Tue, 7 Feb 2017 12:25:20 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:37494 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755483AbdBGRZQ (ORCPT ); Tue, 7 Feb 2017 12:25:16 -0500 Received: by mail-wm0-f45.google.com with SMTP id v77so164406842wmv.0 for ; Tue, 07 Feb 2017 09:25:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fv53537uhbLKPf5wdDmLCww75fxppaINVrKNajkznm8=; b=NKeRVvsl+K7oNeKUIWctDUSt5OEPGcQ/lkXHzjOOoUa9wVTr7Gc6f8Gy77/96lqMi7 NdFoIGlxeK2/TXeDD8A/dXI7lPR1phV7FLk9OUQLFaz2WqjgdbasqaQbH43MaV4DESm7 QsiWlDLbxk16xjXZa5bUJGsdjZmZz82ngXJYo= 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=fv53537uhbLKPf5wdDmLCww75fxppaINVrKNajkznm8=; b=hvWQeHukjkg91qv4xWR1ONSvSX3c3CM4vJOqBokFoRuFb0cHLaTjBzI+w3RY05d0A3 F+RMAvnEwIdGVlC0GehxKvc1luiRNMzaR1QcmWc826Z5prc44kHAZkmW6gnx11VsyRri AQ1MTftjEahedXpnIV4hptjNo4Bfy1153SxJ8EYea8Y9FrFJfAV3uBYgNdMRlVjtyQMl 0T6gpI1xhGHoTLtjthh+uEcWptiLGWiZLdcJ8k7Em+hbk+ufN/MjWqAcG97U4giWMyHN XPKGALIBzhoAv4IYiOVhi3rXtolalp7el6KG+DzK3RS4aQbCiM3h83kRVUokalmPkmbQ ubmA== X-Gm-Message-State: AMke39kZyS+AfSE0g3nftt4wVbpiJxFL60MHOR1SQcHSZuL0EKtr39h4SrVAlvGwQTRqXzHw X-Received: by 10.28.35.65 with SMTP id j62mr12931734wmj.31.1486488304414; Tue, 07 Feb 2017 09:25:04 -0800 (PST) Received: from localhost.localdomain ([185.14.11.102]) by smtp.gmail.com with ESMTPSA id p7sm8384228wrc.34.2017.02.07.09.25.01 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 Feb 2017 09:25:03 -0800 (PST) From: Paolo Valente To: Jens Axboe , Tejun Heo Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, Paolo Valente Subject: [WIP PATCHSET 2/4] Move thinktime from bic to bfqq Date: Tue, 7 Feb 2017 18:24:44 +0100 Message-Id: <20170207172446.4528-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170207172446.4528-1-paolo.valente@linaro.org> References: <20170207172446.4528-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prep change to make it possible to protect this field with a scheduler lock. Signed-off-by: Paolo Valente --- block/bfq-mq-iosched.c | 28 ++++++++++++++-------------- block/bfq-mq.h | 30 ++++++++++++++++-------------- 2 files changed, 30 insertions(+), 28 deletions(-) -- 2.10.0 diff --git a/block/bfq-mq-iosched.c b/block/bfq-mq-iosched.c index 0a7da4e..7e3f429 100644 --- a/block/bfq-mq-iosched.c +++ b/block/bfq-mq-iosched.c @@ -670,6 +670,7 @@ bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_io_cq *bic) else bfq_clear_bfqq_IO_bound(bfqq); + bfqq->ttime = bic->saved_ttime; bfqq->wr_coeff = bic->saved_wr_coeff; bfqq->wr_start_at_switch_to_srt = bic->saved_wr_start_at_switch_to_srt; BUG_ON(time_is_after_jiffies(bfqq->wr_start_at_switch_to_srt)); @@ -1247,7 +1248,7 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, * details on the usage of the next variable. */ arrived_in_time = ktime_get_ns() <= - RQ_BIC(rq)->ttime.last_end_request + + bfqq->ttime.last_end_request + bfqd->bfq_slice_idle * 3; bfq_log_bfqq(bfqd, bfqq, @@ -2003,6 +2004,7 @@ static void bfq_bfqq_save_state(struct bfq_queue *bfqq) if (!bic) return; + bic->saved_ttime = bfqq->ttime; bic->saved_idle_window = bfq_bfqq_idle_window(bfqq); bic->saved_IO_bound = bfq_bfqq_IO_bound(bfqq); bic->saved_in_large_burst = bfq_bfqq_in_large_burst(bfqq); @@ -3870,11 +3872,6 @@ static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) bfq_put_queue(bfqq); } -static void bfq_init_icq(struct io_cq *icq) -{ - icq_to_bic(icq)->ttime.last_end_request = ktime_get_ns() - (1ULL<<32); -} - static void bfq_exit_icq(struct io_cq *icq) { struct bfq_io_cq *bic = icq_to_bic(icq); @@ -4000,6 +3997,9 @@ static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, bfq_mark_bfqq_just_created(bfqq); } else bfq_clear_bfqq_sync(bfqq); + + bfqq->ttime.last_end_request = ktime_get_ns() - (1ULL<<32); + bfq_mark_bfqq_IO_bound(bfqq); /* Tentative initial value to trade off between thr and lat */ @@ -4107,14 +4107,14 @@ static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, } static void bfq_update_io_thinktime(struct bfq_data *bfqd, - struct bfq_io_cq *bic) + struct bfq_queue *bfqq) { - struct bfq_ttime *ttime = &bic->ttime; - u64 elapsed = ktime_get_ns() - bic->ttime.last_end_request; + struct bfq_ttime *ttime = &bfqq->ttime; + u64 elapsed = ktime_get_ns() - bfqq->ttime.last_end_request; elapsed = min_t(u64, elapsed, 2 * bfqd->bfq_slice_idle); - ttime->ttime_samples = (7*bic->ttime.ttime_samples + 256) / 8; + ttime->ttime_samples = (7*bfqq->ttime.ttime_samples + 256) / 8; ttime->ttime_total = div_u64(7*ttime->ttime_total + 256*elapsed, 8); ttime->ttime_mean = div64_ul(ttime->ttime_total + 128, ttime->ttime_samples); @@ -4157,8 +4157,8 @@ static void bfq_update_idle_window(struct bfq_data *bfqd, (bfqd->hw_tag && BFQQ_SEEKY(bfqq) && bfqq->wr_coeff == 1)) enable_idle = 0; - else if (bfq_sample_valid(bic->ttime.ttime_samples)) { - if (bic->ttime.ttime_mean > bfqd->bfq_slice_idle && + else if (bfq_sample_valid(bfqq->ttime.ttime_samples)) { + if (bfqq->ttime.ttime_mean > bfqd->bfq_slice_idle && bfqq->wr_coeff == 1) enable_idle = 0; else @@ -4185,7 +4185,7 @@ static void bfq_rq_enqueued(struct bfq_data *bfqd, struct bfq_queue *bfqq, if (rq->cmd_flags & REQ_META) bfqq->meta_pending++; - bfq_update_io_thinktime(bfqd, bic); + bfq_update_io_thinktime(bfqd, bfqq); bfq_update_io_seektime(bfqd, bfqq, rq); if (bfqq->entity.service > bfq_max_budget(bfqd) / 8 || !BFQQ_SEEKY(bfqq)) @@ -4354,7 +4354,7 @@ static void bfq_completed_request(struct request_queue *q, struct request *rq) now_ns = ktime_get_ns(); - RQ_BIC(rq)->ttime.last_end_request = now_ns; + bfqq->ttime.last_end_request = now_ns; /* * Using us instead of ns, to get a reasonable precision in diff --git a/block/bfq-mq.h b/block/bfq-mq.h index f28feb6..c6acee2 100644 --- a/block/bfq-mq.h +++ b/block/bfq-mq.h @@ -199,6 +199,18 @@ struct bfq_entity { struct bfq_group; /** + * struct bfq_ttime - per process thinktime stats. + */ +struct bfq_ttime { + u64 last_end_request; /* completion time of last request */ + + u64 ttime_total; /* total process thinktime */ + unsigned long ttime_samples; /* number of thinktime samples */ + u64 ttime_mean; /* average process thinktime */ + +}; + +/** * struct bfq_queue - leaf schedulable entity. * * A bfq_queue is a leaf request queue; it can be associated with an @@ -259,6 +271,9 @@ struct bfq_queue { /* node for active/idle bfqq list inside parent bfqd */ struct list_head bfqq_list; + /* associated @bfq_ttime struct */ + struct bfq_ttime ttime; + /* bit vector: a 1 for each seeky requests in history */ u32 seek_history; @@ -322,18 +337,6 @@ struct bfq_queue { }; /** - * struct bfq_ttime - per process thinktime stats. - */ -struct bfq_ttime { - u64 last_end_request; /* completion time of last request */ - - u64 ttime_total; /* total process thinktime */ - unsigned long ttime_samples; /* number of thinktime samples */ - u64 ttime_mean; /* average process thinktime */ - -}; - -/** * struct bfq_io_cq - per (request_queue, io_context) structure. */ struct bfq_io_cq { @@ -341,8 +344,6 @@ struct bfq_io_cq { struct io_cq icq; /* must be the first member */ /* array of two process queues, the sync and the async */ struct bfq_queue *bfqq[2]; - /* associated @bfq_ttime struct */ - struct bfq_ttime ttime; /* per (request_queue, blkcg) ioprio */ int ioprio; #ifdef BFQ_GROUP_IOSCHED_ENABLED @@ -379,6 +380,7 @@ struct bfq_io_cq { unsigned long saved_last_wr_start_finish; unsigned long saved_wr_start_at_switch_to_srt; unsigned int saved_wr_cur_max_time; + struct bfq_ttime saved_ttime; }; enum bfq_device_speed {