From patchwork Tue Jul 31 10:37:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nayan Deshmukh X-Patchwork-Id: 10550619 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 3550214E2 for ; Tue, 31 Jul 2018 10:38:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24A5F2A8BE for ; Tue, 31 Jul 2018 10:38:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 193FF2A8C5; Tue, 31 Jul 2018 10:38:15 +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 D608B2A8BE for ; Tue, 31 Jul 2018 10:38:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C02B6E347; Tue, 31 Jul 2018 10:38:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE97F6E344; Tue, 31 Jul 2018 10:38:10 +0000 (UTC) Received: by mail-pl0-x243.google.com with SMTP id d5-v6so1423258pll.4; Tue, 31 Jul 2018 03:38:10 -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=kKW+vNRiqTQpuCj67tpVWIBPOjKE+lFDcZPGt8HuxMc=; b=kn5qyjFx9+wxAMhNbKhwZId5Ea32UMgHTthvilyHW64YKK5w1H6Ad/LS/Kab3w3Cy+ chmWMc1wUUBXXdMexnfG8Rfrxzl7avlikyuDeLTT6gKp937v638mc7ZG7Wum7EzQJlOF QrVJH+jbD+pw0PnYlO0B9R2c6TX7530nhSuWZ9774R0sDugPBRI6LiIWkccNSGxEz5qI ZBhHd5a45HxHBPWTJ6I0piGc+JCp3pY+WQ1B1qSd0BPafJE6+yD1TKkcQbu4W18LTPmS IG3/oNgYED4Z7uP/pYXgilxcb+PyQoLmjKTx5NDCRKBjh+Y94UV9l/xqqK6W6KijRnfV XX3Q== X-Gm-Message-State: AOUpUlG1leCKAVnlz+Gm3N8+jjY2zCi4jAK+dsZtJ+23G05i2QweoW71 8nK3iLzY1rnf1/KBuDqGmd5/Z0REtTk= X-Google-Smtp-Source: AAOMgpf6EjBriPyDmqpKhJJ1zF9K4jv/DxjUVr0mCuJLI+m+dYndl9pmjhCoEbgebMSclv8V5Ckw6A== X-Received: by 2002:a17:902:4a0c:: with SMTP id w12-v6mr20090157pld.289.1533033490275; Tue, 31 Jul 2018 03:38:10 -0700 (PDT) Received: from localhost.localdomain ([47.247.27.231]) by smtp.gmail.com with ESMTPSA id u13-v6sm23196084pfg.79.2018.07.31.03.38.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Jul 2018 03:38:09 -0700 (PDT) From: Nayan Deshmukh To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/scheduler: add new function to get least loaded sched Date: Tue, 31 Jul 2018 16:07:35 +0530 Message-Id: <20180731103736.7813-4-nayan26deshmukh@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180731103736.7813-1-nayan26deshmukh@gmail.com> References: <20180731103736.7813-1-nayan26deshmukh@gmail.com> 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 , amd-gfx@lists.freedesktop.org, 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 The function selects the run queue from the rq_list with the least load. The load is decided by the number of jobs in a scheduler. Signed-off-by: Nayan Deshmukh --- drivers/gpu/drm/scheduler/gpu_scheduler.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index 375f6f7f6a93..c67f65ad8f15 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c @@ -255,6 +255,32 @@ static bool drm_sched_entity_is_ready(struct drm_sched_entity *entity) return true; } +/** + * drm_sched_entity_get_free_sched - Get the rq from rq_list with least load + * + * @entity: scheduler entity + * + * Return the pointer to the rq with least load. + */ +static struct drm_sched_rq * +drm_sched_entity_get_free_sched(struct drm_sched_entity *entity) +{ + struct drm_sched_rq *rq = NULL; + unsigned int min_jobs = UINT_MAX; + int i; + + for (i = 0; i < entity->num_rq_list; ++i) { + if (atomic_read(&entity->rq_list[i]->sched->num_jobs) < + min_jobs) { + min_jobs = atomic_read( + &entity->rq_list[i]->sched->num_jobs); + rq = entity->rq_list[i]; + } + } + + return rq; +} + static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f, struct dma_fence_cb *cb) {