From patchwork Sun Oct 28 09:59:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nayan Deshmukh X-Patchwork-Id: 10658517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CBDBD14BD for ; Sun, 28 Oct 2018 10:00:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0C3D2A241 for ; Sun, 28 Oct 2018 10:00:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A49F82A252; Sun, 28 Oct 2018 10:00:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8F6CB2A241 for ; Sun, 28 Oct 2018 10:00:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE4DF89786; Sun, 28 Oct 2018 10:00:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB1F089786 for ; Sun, 28 Oct 2018 10:00:15 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id 32-v6so2497372pgu.2 for ; Sun, 28 Oct 2018 03:00:15 -0700 (PDT) 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=g3qVLbBB94x9hYFSj2IuSR7htWeR83d3WZHQ8DQSme8=; b=TWjuq+gF7tXxQmdatMtafGYOlClr37DXAZQju/3Ws1HvP1OpbamYAGK+OBDz8pCHIq M2MCJt4cUPI0Czg3SgddGEZ5tmq53Cvcj8jTzxzyjJ7KSN4IVbAX6dDytCIllL5bIzVn 4O5Ax5SNt5Hfl5R5YQbkYDqmzGZGnbyACf/nx7mgUuBh/oOG4F3XHpJS/Z7J5LHHYKti HtnAytt+C0nn4R4nIyccwJqqvs93mvT/0d/iEH3F+b5WaQulowYC2O7VlVidHkvIdWJu vUoJUQNf97V5nnwMLZNrXsWw96s/4TvwbkBCBygRP3bF2vic5zRTbpN9wMn7rXJnixDb YiCQ== X-Gm-Message-State: AGRZ1gKE4co0sjCR320bpMrh8uuEkcAOV+Uyoef63AhJIbcXo7V8CEAR 7+ZaImi6DRGF3UsTOxmdTp99EJ2oE9I= X-Google-Smtp-Source: AJdET5dVhmd8iBzFjjfE8wn1jqDUl2XzMMYeYjx1v1GMWKq7aFbgKTwFccZekD8WhraaiasOAci9LQ== X-Received: by 2002:a62:4784:: with SMTP id p4-v6mr8981000pfi.257.1540720815137; Sun, 28 Oct 2018 03:00:15 -0700 (PDT) Received: from localhost.localdomain ([175.115.37.73]) by smtp.gmail.com with ESMTPSA id k86-v6sm27657799pfb.167.2018.10.28.03.00.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Oct 2018 03:00:14 -0700 (PDT) From: Nayan Deshmukh To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/scheduler: use hw_rq_count for load calculation Date: Sun, 28 Oct 2018 18:59:25 +0900 Message-Id: <20181028095925.20389-1-nayan26deshmukh@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nayan Deshmukh , christian.koenig@amd.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP If the hardware queue for a scheduler is empty then we don't need to the shift the entities from their current scheduler as they are not getting scheduled because of some dependency. v2: to calculate the least loaded scheduler we only use hw_rq_count when the number of jobs in their run queue are same Signed-off-by: Nayan Deshmukh --- drivers/gpu/drm/scheduler/sched_entity.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 3e22a54a99c2..cfe48df6621d 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -125,15 +125,21 @@ bool drm_sched_entity_is_ready(struct drm_sched_entity *entity) static struct drm_sched_rq * drm_sched_entity_get_free_sched(struct drm_sched_entity *entity) { - struct drm_sched_rq *rq = NULL; + struct drm_sched_rq *rq = NULL, *curr_rq = NULL; unsigned int min_jobs = UINT_MAX, num_jobs; int i; for (i = 0; i < entity->num_rq_list; ++i) { - num_jobs = atomic_read(&entity->rq_list[i]->sched->num_jobs); + curr_rq = entity->rq_list[i]; + num_jobs = atomic_read(&curr_rq->sched->num_jobs); if (num_jobs < min_jobs) { min_jobs = num_jobs; - rq = entity->rq_list[i]; + rq = curr_rq; + } else if (num_jobs == min_jobs) { + if (atomic_read(&curr_rq->sched->hw_rq_count) < + atomic_read(&rq->sched->hw_rq_count)) { + rq = curr_rq; + } } }