From patchwork Thu Jul 12 06:36:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nayan Deshmukh X-Patchwork-Id: 10521129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B8B5603D7 for ; Thu, 12 Jul 2018 06:37:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74F3C291F1 for ; Thu, 12 Jul 2018 06:37:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6947B291FF; Thu, 12 Jul 2018 06:37:12 +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 2142F291F1 for ; Thu, 12 Jul 2018 06:37:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B56E6EE5E; Thu, 12 Jul 2018 06:37:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F92F6EE5C; Thu, 12 Jul 2018 06:37:08 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id z8-v6so2140602pgu.8; Wed, 11 Jul 2018 23:37:08 -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=fTVtiScJ2LnU3jWXdIHDecFaBPjkOpHkbmOazuCh9vQ=; b=XteTdUc7j3SK5W7R52ZrZh4TDwtVQhziNODbDxN/RBRJxeMSuJSiIV8YJJ7Ivvfnue watbU1R9ceLrfRL9MnmNPKEADw2J2d/eQloEFucxZQ88rK19PWpAM5uia2Y5UZt0RUwc fi2GocG3BPkgYGVxrocjhlUs/xmJaOwOoWVdMYT02/TOYnYFLqDXndze1SmkTMnNN9Oj N8lnpQts3eswR+Hct8nAF3ZDfdsP00jz6LKDnmJTdtexSf2Tsvo6Cy7IwLfBuBHBZ+/4 dnsyv1paQdFZO81ngYI2+zCpkakDvKGhOQxQNk99S8gjy9TdpHgnFcHu2XZq6oZz3O5x ciRA== X-Gm-Message-State: AOUpUlEiFemKbmqEcEAxuqRcqsoXRRuPg5IIAidTMCCIQrX+FYFrUuP5 JOm5xmigre0Bs+0JATPDyBo8GhVL X-Google-Smtp-Source: AAOMgpcPl/wPUik5aWjx0r/Fr14M8eHQ0izok1BMi7RDCNGwdFfLSvAM8vHtfi15zW53uk4Sbd6QSA== X-Received: by 2002:a65:5307:: with SMTP id m7-v6mr925676pgq.431.1531377427466; Wed, 11 Jul 2018 23:37:07 -0700 (PDT) Received: from localhost.localdomain ([157.34.9.220]) by smtp.gmail.com with ESMTPSA id 5-v6sm48247096pgc.86.2018.07.11.23.37.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 23:37:06 -0700 (PDT) From: Nayan Deshmukh To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/scheduler: add counter for total jobs in scheduler Date: Thu, 12 Jul 2018 12:06:42 +0530 Message-Id: <20180712063643.8030-3-nayan26deshmukh@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180712063643.8030-1-nayan26deshmukh@gmail.com> References: <20180712063643.8030-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 429b1328653a..3dc1a4f07e3f 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c @@ -538,6 +538,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, trace_drm_sched_job(sched_job, entity); first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node); + atomic_inc(&entity->sched->num_jobs); /* first job wakes up scheduler */ if (first) { @@ -818,6 +819,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); @@ -935,6 +937,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 43e93d6077cf..605bd4ad2397 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -257,6 +257,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. */ @@ -274,6 +275,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,