drm/amdkfd: Add queue information to sysfs
Subsystems (3)
PATCH 1/1 drm/amdkfd: Add queue information to sysfs
Provide compute queues information in sysfs under /sys/class/kfd/kfd/proc. The format is /sys/class/kfd/kfd/proc/<pid>/queues/<queue id>/XX where XX are size, type, and gpuid three files to represent queue size, queue type, and the GPU this queue uses. <queue id> folder and files underneath are generated when a queue is created. They are removed when the queue is destroyed.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 ++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 99 ++++++++++++++++++++++ .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 + 3 files changed, 110 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +9 -0
@@ -503,6 +503,12 @@ struct queue {struct kfd_process *process;struct kfd_dev *device;void *gws; + +/* procfs */ +struct kobject *kobj_qid; +struct attribute attr_size; +struct attribute attr_type; +struct attribute attr_gpuid; };/*
@@ -730,6 +736,7 @@ struct kfd_process {/* Kobj for our procfs */ struct kobject *kobj; +struct kobject *kobj_queues;struct attribute attr_pasid; };
@@ -836,6 +843,8 @@ extern struct device *kfd_device;/* KFD's procfs */ void kfd_procfs_init (void );void kfd_procfs_shutdown (void ); +int kfd_procfs_add_queue (struct queue *q); +void kfd_procfs_del_queue (struct queue *q);/* Topology */ int kfd_topology_init (void );
drivers/gpu/drm/amd/amdkfd/kfd_process.c +99 -0
117 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +2 -0
@@ -322,6 +322,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,if (q) {pr_debug ("PQM done creating queue\n" ); +kfd_procfs_add_queue (q);print_queue_properties (&q->properties); }
@@ -378,6 +379,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid) }if (pqn->q) { +kfd_procfs_del_queue (pqn->q); dqm = pqn->q->device->dqm; retval = dqm->ops.destroy_queue (dqm, &pdd->qpd, pqn->q);if (retval) {
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
One minor comment.
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Amber Lin
Sent: Thursday, January 30, 2020 12:46 AM
To: [email protected]
Cc: Lin, Amber <[email protected]>
Subject: [PATCH] drm/amdkfd: Add queue information to sysfs
Provide compute queues information in sysfs under /sys/class/kfd/kfd/proc. The format is /sys/class/kfd/kfd/proc/<pid>/queues/<queue id>/XX where XX are size, type, and gpuid three files to represent queue size, queue type, and the GPU this queue uses. <queue id> folder and files underneath are generated when a queue is created. They are removed when the queue is destroyed.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 ++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 99 ++++++++++++++++++++++ .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 + 3 files changed, 110 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +9 -0
@@ -503,6 +503,12 @@ struct queue {struct kfd_process *process;struct kfd_dev *device;void *gws; + +/* procfs */ +struct kobject *kobj_qid; +struct attribute attr_size; +struct attribute attr_type; +struct attribute attr_gpuid; };/*
@@ -730,6 +736,7 @@ struct kfd_process {/* Kobj for our procfs */ struct kobject *kobj; +struct kobject *kobj_queues;struct attribute attr_pasid; };
@@ -836,6 +843,8 @@ extern struct device *kfd_device;/* KFD's procfs */ void kfd_procfs_init (void );void kfd_procfs_shutdown (void ); +int kfd_procfs_add_queue (struct queue *q); +void kfd_procfs_del_queue (struct queue *q);/* Topology */ int kfd_topology_init (void );
drivers/gpu/drm/amd/amdkfd/kfd_process.c +78 -0
82 lines not on this page · raw message
[HK] : proc is not used
+
+ if (!q || !q->process)
+ return;
+ proc = q->process;
+
+ sysfs_remove_file(q->kobj_qid, &q->attr_size);
+ sysfs_remove_file(q->kobj_qid, &q->attr_type);
+ sysfs_remove_file(q->kobj_qid, &q->attr_gpuid);
+ kobject_del(q->kobj_qid);
+ kobject_put(q->kobj_qid);
+ q->kobj_qid = NULL;
+}
+
int kfd_process_create_wq(void)
{
if (!kfd_process_wq)
@@ -323,6 +414,11 @@ struct kfd_process *kfd_create_process(struct file *filep)
if (ret)
pr_warn("Creating pasid for pid %d failed",
(int)process->lead_thread->pid);
+
+ process->kobj_queues = kobject_create_and_add("queues",
+ process->kobj);
+ if (!process->kobj_queues)
+ pr_warn("Creating KFD proc/queues folder failed");
}
out:
if (!IS_ERR(process))
@@ -457,6 +553,9 @@ static void kfd_process_wq_release(struct work_struct *work)
/* Remove the procfs files */
if (p->kobj) {
sysfs_remove_file(p->kobj, &p->attr_pasid);
+ kobject_del(p->kobj_queues);
+ kobject_put(p->kobj_queues);
+ p->kobj_queues = NULL;
kobject_del(p->kobj);
kobject_put(p->kobj);
p->kobj = NULL;
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +2 -0
@@ -322,6 +322,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,if (q) {pr_debug ("PQM done creating queue\n" ); +kfd_procfs_add_queue (q);print_queue_properties (&q->properties); }
@@ -378,6 +379,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid) }if (pqn->q) { +kfd_procfs_del_queue (pqn->q); dqm = pqn->q->device->dqm; retval = dqm->ops.destroy_queue (dqm, &pdd->qpd, pqn->q);if (retval) {
Signature · 10 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Charish.kasiviswanathan%40amd.com%7C496ec14c22b84457329608d7a547c2ed%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637159600420395549&sdata=h6eKxRwq4kPv7z7qHuiPvhb7UoR0QKlRWK8OAdBEyqk%3D&reserved=0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx