public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: brolerliew <brolerliew@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: brolerliew@gmail.com,
	Andrey Grodzovsky <andrey.grodzovsky@amd.com>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] drm/scheduler: set current_entity to next when remove from rq
Date: Tue, 25 Oct 2022 14:18:46 +0800	[thread overview]
Message-ID: <20221025061846.447975-1-brolerliew@gmail.com> (raw)

When entity move from one rq to another, current_entity will be set to NULL
if it is the moving entity. This make entities close to rq head got
selected more frequently, especially when doing load balance between
multiple drm_gpu_scheduler.

Make current_entity to next when removing from rq.

Signed-off-by: brolerliew <brolerliew@gmail.com>
---
 drivers/gpu/drm/scheduler/sched_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 2fab218d7082..00b22cc50f08 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -168,10 +168,11 @@ void drm_sched_rq_remove_entity(struct drm_sched_rq *rq,
 	spin_lock(&rq->lock);
 
 	atomic_dec(rq->sched->score);
-	list_del_init(&entity->list);
 
 	if (rq->current_entity == entity)
-		rq->current_entity = NULL;
+		rq->current_entity = list_next_entry(entity, list);
+
+	list_del_init(&entity->list);
 
 	if (drm_sched_policy == DRM_SCHED_POLICY_FIFO)
 		drm_sched_rq_remove_fifo_locked(entity);
-- 
2.34.1


             reply	other threads:[~2022-10-25  6:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25  6:18 brolerliew [this message]
2022-10-25 13:35 ` [PATCH] drm/scheduler: set current_entity to next when remove from rq Alex Deucher
2022-10-25 17:50   ` Luben Tuikov
2022-10-27  7:01     ` Luben Tuikov
2022-10-27  8:07       ` Luben Tuikov
2022-10-27  8:19         ` Christian König
2022-10-27  8:24           ` Luben Tuikov
     [not found]             ` <CAODyvyypneTxCDUgUNB0UCm+eZtKn_yLJRxZ8nh-kg2PUkaTjw@mail.gmail.com>
     [not found]               ` <37c0c9f3-be29-aa0e-94b3-c1ae75e70763@amd.com>
2022-10-27 15:46                 ` Luben Tuikov

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=20221025061846.447975-1-brolerliew@gmail.com \
    --to=brolerliew@gmail.com \
    --cc=airlied@gmail.com \
    --cc=andrey.grodzovsky@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox