From patchwork Wed Aug 1 08:20:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nayan Deshmukh X-Patchwork-Id: 10551845 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 B278E9093 for ; Wed, 1 Aug 2018 08:21:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A517D2AC33 for ; Wed, 1 Aug 2018 08:21:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 996A92AEC1; Wed, 1 Aug 2018 08:21:02 +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 569712AC33 for ; Wed, 1 Aug 2018 08:21:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF20C88052; Wed, 1 Aug 2018 08:21:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6379889CB5; Wed, 1 Aug 2018 08:21:00 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id j8-v6so7460830pff.6; Wed, 01 Aug 2018 01:21:00 -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=dprZ81F77+rCkqJL0PmM8SUhfK1KuDE5/d12GO5ieNY=; b=EF1gn4r8VKDvWVtd3MQGLuoW9Zaj11l+Qq6vZCvnvB9thrnI5lNbdbjEqCmmym5f8F 5/buMe/rf/GGBKtJmOfAjud48qsfhhq29iX7v/J9pdmgx3L0v7fbhGFkkZIB6nLsGS8u JFCZ3ArdkezM77In967K0SA1h+BxKg42ROWmRrXKWJ1M8AcUUlHRKiWPUPtej4WyiKVV 6SxMBKehkkg0Apn8058B6SyILlX9Hu8eSVBeweF2RDIpVmVGc+RuOcsqG6pMBd1hXSiT OcjD9iovAxJSBE75tSSOSKKDPgWeKAX87vbqdZCtNg0H7aUh8iIxmiXvxmdU8Pt4ghqq i+Ew== X-Gm-Message-State: AOUpUlFy/QlEa5eMJ/eW9908SSmTCHupI+urvKkQPusy0tj7YWmi1AKc LI5430salun173TrjGaUdfwTTVIj X-Google-Smtp-Source: AAOMgpfronWTmVtfUAtI/gU8JTXB55971Yb2qP6e2HF1jfkF9WL1mNhBWNv0l5uaZs67n9kz/koG8w== X-Received: by 2002:a63:1403:: with SMTP id u3-v6mr23538274pgl.13.1533111659768; Wed, 01 Aug 2018 01:20:59 -0700 (PDT) Received: from localhost.localdomain ([47.247.93.221]) by smtp.gmail.com with ESMTPSA id c1-v6sm13329283pfg.25.2018.08.01.01.20.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 01:20:59 -0700 (PDT) From: Nayan Deshmukh To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/scheduler: move idle entities to scheduler with less load v2 Date: Wed, 1 Aug 2018 13:50:02 +0530 Message-Id: <20180801082002.20696-4-nayan26deshmukh@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180801082002.20696-1-nayan26deshmukh@gmail.com> References: <20180801082002.20696-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 This is the first attempt to move entities between schedulers to have dynamic load balancing. We just move entities with no jobs for now as moving the ones with jobs will lead to other compilcations like ensuring that the other scheduler does not remove a job from the current entity while we are moving. v2: remove unused variable and an unecessary check Signed-off-by: Nayan Deshmukh --- drivers/gpu/drm/scheduler/gpu_scheduler.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index fb4e542660b0..087fa479f7e0 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c @@ -539,6 +539,8 @@ drm_sched_entity_pop_job(struct drm_sched_entity *entity) if (!sched_job) return NULL; + sched_job->sched = sched; + sched_job->s_fence->sched = sched; while ((entity->dependency = sched->ops->dependency(sched_job, entity))) if (drm_sched_entity_add_dependency_cb(entity)) return NULL; @@ -569,11 +571,23 @@ drm_sched_entity_pop_job(struct drm_sched_entity *entity) void drm_sched_entity_push_job(struct drm_sched_job *sched_job, struct drm_sched_entity *entity) { - struct drm_gpu_scheduler *sched = sched_job->sched; - bool first = false; + struct drm_sched_rq *rq = entity->rq; + bool first = false, reschedule, idle; - trace_drm_sched_job(sched_job, entity); + idle = entity->last_scheduled == NULL || + dma_fence_is_signaled(entity->last_scheduled); + first = spsc_queue_count(&entity->job_queue) == 0; + reschedule = idle && first && (entity->num_rq_list > 1); + if (reschedule) { + rq = drm_sched_entity_get_free_sched(entity); + spin_lock(&entity->rq_lock); + drm_sched_rq_remove_entity(entity->rq, entity); + entity->rq = rq; + spin_unlock(&entity->rq_lock); + } + + trace_drm_sched_job(sched_job, entity); atomic_inc(&entity->rq->sched->num_jobs); first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node); @@ -588,7 +602,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, } drm_sched_rq_add_entity(entity->rq, entity); spin_unlock(&entity->rq_lock); - drm_sched_wakeup(sched); + drm_sched_wakeup(entity->rq->sched); } } EXPORT_SYMBOL(drm_sched_entity_push_job);