From: "Kuehling, Felix" <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
To: "Zeng, Oak" <Oak.Zeng-5C7GfCeVMHo@public.gmane.org>,
"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Cc: "Keely, Sean" <Sean.Keely-5C7GfCeVMHo@public.gmane.org>
Subject: Re: [PATCH 5/7] drm/amdkfd: Add function to set queue gws
Date: Wed, 22 May 2019 21:46:17 +0000 [thread overview]
Message-ID: <05f3ae91-100b-60d9-08e5-627245e38c64@amd.com> (raw)
In-Reply-To: <1558540278-23734-5-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org>
On 2019-05-22 11:51 a.m., Zeng, Oak wrote:
> Add functions in process queue manager to
> set/get queue gws. Also set process's number
> of gws used. Currently only one queue in
> process can use and use all gws.
>
> Change-Id: I03e480c8692db3eabfc3a188cce8904d5d962ab7
> Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 +++
> .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 58 ++++++++++++++++++++++
> 2 files changed, 64 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> index 5969e37..40a5c67 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> @@ -454,6 +454,9 @@ struct queue_properties {
> *
> * @device: The kfd device that created this queue.
> *
> + * @gws: Pointing to gws kgd_mem if this is a gws control queue; NULL
> + * otherwise.
> + *
> * This structure represents user mode compute queues.
> * It contains all the necessary data to handle such queues.
> *
> @@ -475,6 +478,7 @@ struct queue {
>
> struct kfd_process *process;
> struct kfd_dev *device;
> + void *gws;
> };
>
> /*
> @@ -868,6 +872,8 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
> struct queue_properties *p);
> int pqm_set_cu_mask(struct process_queue_manager *pqm, unsigned int qid,
> struct queue_properties *p);
> +int pqm_set_gws(struct process_queue_manager *pqm, unsigned int qid,
> + void *gws);
> struct kernel_queue *pqm_get_kernel_queue(struct process_queue_manager *pqm,
> unsigned int qid);
> int pqm_get_wave_state(struct process_queue_manager *pqm,
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> index e652e25..a78494d 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> @@ -26,6 +26,7 @@
> #include "kfd_device_queue_manager.h"
> #include "kfd_priv.h"
> #include "kfd_kernel_queue.h"
> +#include "amdgpu_amdkfd.h"
>
> static inline struct process_queue_node *get_queue_by_qid(
> struct process_queue_manager *pqm, unsigned int qid)
> @@ -74,6 +75,57 @@ void kfd_process_dequeue_from_device(struct kfd_process_device *pdd)
> pdd->already_dequeued = true;
> }
>
> +int pqm_set_gws(struct process_queue_manager *pqm, unsigned int qid,
> + void *gws)
> +{
> + struct kfd_dev *dev = NULL;
> + struct process_queue_node *pqn;
> + struct kfd_process_device *pdd;
> +
> + pqn = get_queue_by_qid(pqm, qid);
> + if (!pqn) {
> + pr_err("Queue id does not match any known queue\n");
> + return -EINVAL;
> + }
> +
> + if (pqn->q)
> + dev = pqn->q->device;
> + if (WARN_ON(!dev))
> + return -ENODEV;
> +
> + pdd = kfd_get_process_device_data(dev, pqm->process);
> + if (!pdd) {
> + pr_err("Process device data doesn't exist\n");
> + return -EINVAL;
> + }
> +
> + /* Only allow one queue per process can have GWS assigned */
> + list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
> + if (pqn->q && pqn->q->gws)
> + return -EINVAL;
> + }
> +
> + pqn->q->gws = gws;
> + pdd->qpd.num_gws = gws ? amdgpu_amdkfd_get_num_gws(dev->kgd) : 0;
> +
> + return pqn->q->device->dqm->ops.update_queue(pqn->q->device->dqm,
> + pqn->q);
When pqm_set_gws is called during pqm_destroy_queue, this is
unnecessary. It would result in two preemptions and runlist updates
every time a queue is destroyed. See below.
> +}
> +
> +static void *pqm_get_gws(struct process_queue_manager *pqm, unsigned int qid)
> +{
> + struct process_queue_node *pqn;
> +
> + pqn = get_queue_by_qid(pqm, qid);
> + if (!pqn) {
> + pr_debug("No queue %d exists for get gws operation\n", qid);
> + return NULL;
> + }
> +
> + return pqn->q->gws;
> +}
> +
> +
> void kfd_process_dequeue_from_all_devices(struct kfd_process *p)
> {
> struct kfd_process_device *pdd;
> @@ -313,6 +365,12 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
> return -1;
> }
>
> + if (pqm_get_gws(pqm, qid)) {
All pqm_get_gws really does an extra lookup of the pqn, which you
already know here. Instead, could you just replace this with:
if (pqn->q->gws) ...
And remove pqm_get_gws.
> + amdgpu_amdkfd_remove_gws_from_process(pqm->process->kgd_process_info,
> + pqm_get_gws(pqm, qid));
> + pqm_set_gws(pqm, qid, NULL);
If you call pqm_set_gws here, it will unnecessarily cause a preemption
and runlist update. It also does more lookups of pdd and pqn, both of
which you already know here. You don't really need to update the queue
that you're about to destroy. All you really need to do here is update
pdd->qpd.num_gws. You can do that without calling pqm_set_gws.
Regards,
Felix
> + }
> +
> if (pqn->kq) {
> /* destroy kernel queue (DIQ) */
> dqm = pqn->kq->dev->dqm;
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2019-05-22 21:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 15:51 [PATCH 1/7] drm/amdkfd: Add gws number to kfd topology node properties Zeng, Oak
[not found] ` <1558540278-23734-1-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org>
2019-05-22 15:51 ` [PATCH 2/7] drm/amdgpu: Add interface to alloc gws from amdgpu Zeng, Oak
2019-05-22 15:51 ` [PATCH 3/7] drm/amdkfd: Allocate gws on device initialization Zeng, Oak
2019-05-22 15:51 ` [PATCH 4/7] drm/amdgpu: Add function to add/remove gws to kfd process Zeng, Oak
[not found] ` <1558540278-23734-4-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org>
2019-05-22 21:49 ` Kuehling, Felix
2019-05-22 15:51 ` [PATCH 5/7] drm/amdkfd: Add function to set queue gws Zeng, Oak
[not found] ` <1558540278-23734-5-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org>
2019-05-22 21:46 ` Kuehling, Felix [this message]
2019-05-22 15:51 ` [PATCH 6/7] drm/amdkfd: New IOCTL to allocate queue GWS Zeng, Oak
[not found] ` <1558540278-23734-6-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org>
2019-05-22 21:49 ` Kuehling, Felix
2019-05-22 15:51 ` [PATCH 7/7] drm/amdkfd: PM4 packets change to support GWS Zeng, Oak
-- strict thread matches above, loose matches on Subject: below --
2019-05-23 18:40 [PATCH 1/7] drm/amdkfd: Add gws number to kfd topology node properties Zeng, Oak
[not found] ` <1558636843-9867-1-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org>
2019-05-23 18:41 ` [PATCH 5/7] drm/amdkfd: Add function to set queue gws Zeng, Oak
[not found] ` <1558636843-9867-5-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org>
2019-05-23 21:42 ` Kuehling, Felix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05f3ae91-100b-60d9-08e5-627245e38c64@amd.com \
--to=felix.kuehling-5c7gfcevmho@public.gmane.org \
--cc=Oak.Zeng-5C7GfCeVMHo@public.gmane.org \
--cc=Sean.Keely-5C7GfCeVMHo@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox