From patchwork Wed Aug 1 08:20:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nayan Deshmukh X-Patchwork-Id: 10551841 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 BD96014E2 for ; Wed, 1 Aug 2018 08:20:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF2772AC33 for ; Wed, 1 Aug 2018 08:20:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A11D62AEC1; Wed, 1 Aug 2018 08:20:43 +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 510FE2AC33 for ; Wed, 1 Aug 2018 08:20:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 815A289B99; Wed, 1 Aug 2018 08:20:41 +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 664FA89B99; Wed, 1 Aug 2018 08:20:40 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id u24-v6so7455293pfn.13; Wed, 01 Aug 2018 01:20:40 -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=5GlFr87IlwXBB0lwQWapQtux1m3YiQrIk6nkGRs6QqE=; b=HqKE8MCNn8Qg/EphEILRLQQr9PYYdR8oxqExA1bjbD6QX6REPz4YwjRCaZhBITVAUf kudKuPJPfKO61squyyrS7RoH3bH7dnuJZFtJkKsSOfov/3nSAlI1oZsYc7RfzQADF5fg bCrLLZ4q6X88EdsVxp8Qf2/GYDsnErlFIsL08FKYJckDBYMMD9tnp+KiiqGggDXmJu6X 7Kr5DO351N9Gq5dyhdfvOVyMdNd2MknPLFIf4Lhp5Sm0MyQD+Oph0BJczKpR5tCmkfx4 EZaep8NyvhDuKaTdgZrWi4r7jW1t/h7lMVAeVHXUzzcdTLeBX/Wb3oepvRPccR1g4um1 LyXw== X-Gm-Message-State: AOUpUlHSc+mUrG77VRdWaYD5+zJkDHHEnFm0XWVwB5d0dTH36VfAodOi KJJonUsHHZkthLDRpoCWlpkPzQXm X-Google-Smtp-Source: AAOMgpeFyruIqmIqp0+/EDC44FAQfATQL6ik3tCPC+W6ziAB8agHd0+j/Tsprz/t3pSKoyYedW1q0w== X-Received: by 2002:a62:8913:: with SMTP id v19-v6mr4374217pfd.127.1533111639745; Wed, 01 Aug 2018 01:20:39 -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.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 01:20:39 -0700 (PDT) From: Nayan Deshmukh To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm/scheduler: add counter for total jobs in scheduler Date: Wed, 1 Aug 2018 13:50:00 +0530 Message-Id: <20180801082002.20696-2-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 Signed-off-by: Nayan Deshmukh --- drivers/gpu/drm/scheduler/gpu_scheduler.c | 3 +++ include/drm/gpu_scheduler.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index a3eacc35cf98..375f6f7f6a93 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c @@ -549,6 +549,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, 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); /* first job wakes up scheduler */ @@ -836,6 +837,7 @@ static void drm_sched_process_job(struct dma_fence *f, struct dma_fence_cb *cb) dma_fence_get(&s_fence->finished); atomic_dec(&sched->hw_rq_count); + atomic_dec(&sched->num_jobs); drm_sched_fence_finished(s_fence); trace_drm_sched_process_job(s_fence); @@ -953,6 +955,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, INIT_LIST_HEAD(&sched->ring_mirror_list); spin_lock_init(&sched->job_list_lock); atomic_set(&sched->hw_rq_count, 0); + atomic_set(&sched->num_jobs, 0); atomic64_set(&sched->job_id_count, 0); /* Each scheduler will run on a seperate kernel thread */ diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index a60896222a3e..89881ce974a5 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -260,6 +260,7 @@ struct drm_sched_backend_ops { * @job_list_lock: lock to protect the ring_mirror_list. * @hang_limit: once the hangs by a job crosses this limit then it is marked * guilty and it will be considered for scheduling further. + * @num_jobs: the number of jobs in queue in the scheduler * * One scheduler is implemented for each hardware ring. */ @@ -277,6 +278,7 @@ struct drm_gpu_scheduler { struct list_head ring_mirror_list; spinlock_t job_list_lock; int hang_limit; + atomic_t num_jobs; }; int drm_sched_init(struct drm_gpu_scheduler *sched,