All of lore.kernel.org
 help / color / mirror / Atom feed
From: brookxu <brookxu.cn@gmail.com>
To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org
Cc: linux-block@vger.kernel.org, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 10/14] bfq: optimize IO injection under better_fairness
Date: Thu, 25 Mar 2021 14:57:54 +0800	[thread overview]
Message-ID: <d572933d913b4c38808446abe263b24bdac38098.1616649216.git.brookxu@tencent.com> (raw)
In-Reply-To: <cover.1616649216.git.brookxu@tencent.com>
In-Reply-To: <cover.1616649216.git.brookxu@tencent.com>

From: Chunguang Xu <brookxu@tencent.com>

In order to ensure better Qos of tasks of different groups
and different classes under better_fairness, we only allow
the queues of the same class in the same group can be
injected.

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
---
 block/bfq-iosched.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 51192bd..be5b1e3 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -1900,6 +1900,27 @@ static void bfq_reset_inject_limit(struct bfq_data *bfqd,
 	bfqq->decrease_time_jif = jiffies;
 }
 
+static bool bfq_bfqq_may_inject(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq)
+{
+	struct bfq_data *bfqd = bfqq->bfqd;
+	bool ret = true;
+
+	if (unlikely(bfqd->better_fairness)) {
+		/*
+		 * In addition to throughput, better_fairness also pays
+		 * attention to Qos. In the container scenario, in order
+		 * to ensure the Qos of each group we only allow tasks
+		 * of the same class in the same group to be injected.
+		 */
+		if (bfq_class(bfqq) != bfq_class(new_bfqq))
+			ret = false;
+
+		if (bfqq_group(bfqq) != bfqq_group(new_bfqq))
+			ret = false;
+	}
+	return ret;
+}
+
 static void bfq_update_io_intensity(struct bfq_queue *bfqq, u64 now_ns)
 {
 	u64 tot_io_time = now_ns - bfqq->io_start_time;
@@ -1985,7 +2006,8 @@ static void bfq_check_waker(struct bfq_data *bfqd, struct bfq_queue *bfqq,
 	    bfqd->last_completed_rq_bfqq == bfqq ||
 	    bfq_bfqq_has_short_ttime(bfqq) ||
 	    now_ns - bfqd->last_completion >= 4 * NSEC_PER_MSEC ||
-	    bfqd->last_completed_rq_bfqq == bfqq->waker_bfqq)
+	    bfqd->last_completed_rq_bfqq == bfqq->waker_bfqq ||
+	    !bfq_bfqq_may_inject(bfqq, bfqd->last_completed_rq_bfqq))
 		return;
 
 	if (bfqd->last_completed_rq_bfqq !=
@@ -4415,6 +4437,9 @@ static bool bfq_bfqq_must_idle(struct bfq_queue *bfqq)
 			else
 				limit = in_serv_bfqq->inject_limit;
 
+			if (!bfq_bfqq_may_inject(in_serv_bfqq, bfqq))
+				continue;
+
 			if (bfqd->rq_in_driver < limit) {
 				bfqd->rqs_injected = true;
 				return bfqq;
@@ -4590,6 +4615,7 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd)
 		 * happen to be served only after other queues.
 		 */
 		if (async_bfqq &&
+		    !(bfqd->better_fairness && !bfq_class_idx(&bfqq->entity)) &&
 		    icq_to_bic(async_bfqq->next_rq->elv.icq) == bfqq->bic &&
 		    bfq_serv_to_charge(async_bfqq->next_rq, async_bfqq) <=
 		    bfq_bfqq_budget_left(async_bfqq))
-- 
1.8.3.1


WARNING: multiple messages have this Message-ID (diff)
From: brookxu <brookxu.cn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: paolo.valente-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
	tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH v3 10/14] bfq: optimize IO injection under better_fairness
Date: Thu, 25 Mar 2021 14:57:54 +0800	[thread overview]
Message-ID: <d572933d913b4c38808446abe263b24bdac38098.1616649216.git.brookxu@tencent.com> (raw)
In-Reply-To: <cover.1616649216.git.brookxu-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
In-Reply-To: <cover.1616649216.git.brookxu-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>

From: Chunguang Xu <brookxu-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>

In order to ensure better Qos of tasks of different groups
and different classes under better_fairness, we only allow
the queues of the same class in the same group can be
injected.

Signed-off-by: Chunguang Xu <brookxu-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
---
 block/bfq-iosched.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 51192bd..be5b1e3 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -1900,6 +1900,27 @@ static void bfq_reset_inject_limit(struct bfq_data *bfqd,
 	bfqq->decrease_time_jif = jiffies;
 }
 
+static bool bfq_bfqq_may_inject(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq)
+{
+	struct bfq_data *bfqd = bfqq->bfqd;
+	bool ret = true;
+
+	if (unlikely(bfqd->better_fairness)) {
+		/*
+		 * In addition to throughput, better_fairness also pays
+		 * attention to Qos. In the container scenario, in order
+		 * to ensure the Qos of each group we only allow tasks
+		 * of the same class in the same group to be injected.
+		 */
+		if (bfq_class(bfqq) != bfq_class(new_bfqq))
+			ret = false;
+
+		if (bfqq_group(bfqq) != bfqq_group(new_bfqq))
+			ret = false;
+	}
+	return ret;
+}
+
 static void bfq_update_io_intensity(struct bfq_queue *bfqq, u64 now_ns)
 {
 	u64 tot_io_time = now_ns - bfqq->io_start_time;
@@ -1985,7 +2006,8 @@ static void bfq_check_waker(struct bfq_data *bfqd, struct bfq_queue *bfqq,
 	    bfqd->last_completed_rq_bfqq == bfqq ||
 	    bfq_bfqq_has_short_ttime(bfqq) ||
 	    now_ns - bfqd->last_completion >= 4 * NSEC_PER_MSEC ||
-	    bfqd->last_completed_rq_bfqq == bfqq->waker_bfqq)
+	    bfqd->last_completed_rq_bfqq == bfqq->waker_bfqq ||
+	    !bfq_bfqq_may_inject(bfqq, bfqd->last_completed_rq_bfqq))
 		return;
 
 	if (bfqd->last_completed_rq_bfqq !=
@@ -4415,6 +4437,9 @@ static bool bfq_bfqq_must_idle(struct bfq_queue *bfqq)
 			else
 				limit = in_serv_bfqq->inject_limit;
 
+			if (!bfq_bfqq_may_inject(in_serv_bfqq, bfqq))
+				continue;
+
 			if (bfqd->rq_in_driver < limit) {
 				bfqd->rqs_injected = true;
 				return bfqq;
@@ -4590,6 +4615,7 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd)
 		 * happen to be served only after other queues.
 		 */
 		if (async_bfqq &&
+		    !(bfqd->better_fairness && !bfq_class_idx(&bfqq->entity)) &&
 		    icq_to_bic(async_bfqq->next_rq->elv.icq) == bfqq->bic &&
 		    bfq_serv_to_charge(async_bfqq->next_rq, async_bfqq) <=
 		    bfq_bfqq_budget_left(async_bfqq))
-- 
1.8.3.1


  parent reply	other threads:[~2021-03-25  6:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25  6:57 [PATCH v3 00/14] bfq: introduce bfq.ioprio for cgroup brookxu
2021-03-25  6:57 ` [PATCH v3 01/14] bfq: introduce bfq_entity_to_bfqg helper method brookxu
2021-03-25  6:57 ` [PATCH v3 02/14] bfq: convert the type of bfq_group.bfqd to bfq_data* brookxu
2021-03-25  6:57 ` [PATCH v3 03/14] bfq: introduce bfq.ioprio for cgroup brookxu
2021-03-25  6:57 ` [PATCH v3 04/14] bfq: introduce bfq_ioprio_class to get ioprio class brookxu
2021-03-25  6:57   ` brookxu
2021-03-25  6:57 ` [PATCH v3 05/14] bfq: limit the IO depth of CLASS_IDLE to 1 brookxu
2021-03-25  6:57 ` [PATCH v3 06/14] bfq: keep the minimun bandwidth for CLASS_BE brookxu
2021-03-25  6:57 ` [PATCH v3 07/14] bfq: introduce better_fairness for container scene brookxu
2021-03-25  6:57 ` [PATCH v3 08/14] bfq: introduce prio_expire flag for bfq_queue brookxu
2021-03-25  6:57   ` brookxu
2021-03-25  6:57 ` [PATCH v3 09/14] bfq: expire in_serv_queue for prio_expire under better_fairness brookxu
2021-03-25  6:57   ` brookxu
2021-03-25  6:57 ` brookxu [this message]
2021-03-25  6:57   ` [PATCH v3 10/14] bfq: optimize IO injection " brookxu
2021-03-25  6:57 ` [PATCH v3 11/14] bfq: disable idle for prio_expire " brookxu
2021-03-25  6:57   ` brookxu
2021-03-25  6:57 ` [PATCH v3 12/14] bfq: disable merging between different groups " brookxu
2021-03-25  6:57 ` [PATCH v3 13/14] bfq: remove unnecessary initialization logic brookxu
2021-03-25  6:57 ` [PATCH v3 14/14] bfq: optimize the calculation of bfq_weight_to_ioprio() brookxu
2021-04-04 16:09 ` [PATCH v3 00/14] bfq: introduce bfq.ioprio for cgroup Tejun Heo
2021-04-06  7:31   ` brookxu
2021-04-06  7:31     ` brookxu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d572933d913b4c38808446abe263b24bdac38098.1616649216.git.brookxu@tencent.com \
    --to=brookxu.cn@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paolo.valente@linaro.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.