From: "Chen, Xiaogang" <xiaogang.chen@amd.com>
To: "Zhu, Lingshan" <lingshan.zhu@amd.com>,
felix.kuehling@amd.com, alexander.deucher@amd.com
Cc: ray.huang@amd.com, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] amdkfd: implement per process/device pasid in sysfs
Date: Fri, 31 Oct 2025 09:40:05 -0500 [thread overview]
Message-ID: <d2f42b51-3905-4274-be84-d4d086b4f072@amd.com> (raw)
In-Reply-To: <89b6057a-ff21-46a2-951b-b96888f60b3d@amd.com>
[-- Attachment #1: Type: text/plain, Size: 6294 bytes --]
On 10/30/2025 9:48 PM, Zhu, Lingshan wrote:
> On 10/30/2025 11:53 PM, Chen, Xiaogang wrote:
>>
>> On 10/29/2025 10:45 PM, Zhu Lingshan wrote:
>>> The pasid is a per-process-per-device attribute,
>>> therefore this commit implements per
>>> struct kfd_process_device->pasid in sysfs
>> This per device pasid is used internally in kfd, not used at user
>> space. So no need to exposing it.
> current sysfs implementation exposing PASID to user space, but buggy value 0, this commit
> intends to fix this issue.
It is just for keeping current tools working. The PASID value has no
meaning for use space that it would not get useful info about driver
through it or uses PASID to change driver behavior.
Regards
Xiaogang
>
> Thanks
> Lingshan
>>>
>>> Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 ++-------
>>> drivers/gpu/drm/amd/amdkfd/kfd_process.c | 18 +++++++++++-------
>>> 2 files changed, 13 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> index 70ef051511bb..6a3cfeccacd8 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> @@ -864,6 +864,8 @@ struct kfd_process_device {
>>> bool has_reset_queue;
>>> u32 pasid;
>>> + char pasid_filename[MAX_SYSFS_FILENAME_LEN];
>>> + struct attribute attr_pasid;
>>> };
>>> #define qpd_to_pdd(x) container_of(x, struct kfd_process_device,
>>> qpd)
>>> @@ -983,7 +985,6 @@ struct kfd_process {
>>> /* Kobj for our procfs */
>>> struct kobject *kobj;
>>> struct kobject *kobj_queues;
>>> - struct attribute attr_pasid;
>> We keep it to have use space tools(ex rocm-smi) work as the tools
>> still read it before they change.
>>> /* Keep track cwsr init */
>>> bool has_cwsr;
>>> @@ -1100,12 +1101,6 @@ void
>>> kfd_process_device_remove_obj_handle(struct kfd_process_device *pdd,
>>> int handle);
>>> struct kfd_process *kfd_lookup_process_by_pid(struct pid *pid);
>>> -/* PASIDs */
>>> -int kfd_pasid_init(void);
>>> -void kfd_pasid_exit(void);
>>> -u32 kfd_pasid_alloc(void);
>>> -void kfd_pasid_free(u32 pasid);
>> This part is right, these declarations were forgotten to remove.
>>> -
>>> /* Doorbells */
>>> size_t kfd_doorbell_process_slice(struct kfd_dev *kfd);
>>> int kfd_doorbell_init(struct kfd_dev *kfd);
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>>> index ddfe30c13e9d..24cf3b250b37 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>>> @@ -328,9 +328,11 @@ static int kfd_get_cu_occupancy(struct
>>> attribute *attr, char *buffer)
>>> static ssize_t kfd_procfs_show(struct kobject *kobj, struct
>>> attribute *attr,
>>> char *buffer)
>>> {
>>> - if (strcmp(attr->name, "pasid") == 0)
>>> - return snprintf(buffer, PAGE_SIZE, "%d\n", 0);
>>
>> Same as above we keep it to have compatibility with current tools.
>>
>> Regards
>>
>> Xiaogang
>>
>>> - else if (strncmp(attr->name, "vram_", 5) == 0) {
>>> + if (strncmp(attr->name, "pasid_", 6) == 0) {
>>> + struct kfd_process_device *pdd = container_of(attr, struct
>>> kfd_process_device,
>>> + attr_pasid);
>>> + return snprintf(buffer, PAGE_SIZE, "%u\n", pdd->pasid);
>>> + } else if (strncmp(attr->name, "vram_", 5) == 0) {
>>> struct kfd_process_device *pdd = container_of(attr, struct
>>> kfd_process_device,
>>> attr_vram);
>>> return snprintf(buffer, PAGE_SIZE, "%llu\n",
>>> atomic64_read(&pdd->vram_usage));
>>> @@ -662,6 +664,7 @@ static void kfd_procfs_add_sysfs_files(struct
>>> kfd_process *p)
>>> * Create sysfs files for each GPU:
>>> * - proc/<pid>/vram_<gpuid>
>>> * - proc/<pid>/sdma_<gpuid>
>>> + * - proc/<pid>/pasid_<gpuid>
>>> */
>>> for (i = 0; i < p->n_pdds; i++) {
>>> struct kfd_process_device *pdd = p->pdds[i];
>>> @@ -675,6 +678,10 @@ static void kfd_procfs_add_sysfs_files(struct
>>> kfd_process *p)
>>> pdd->dev->id);
>>> kfd_sysfs_create_file(p->kobj, &pdd->attr_sdma,
>>> pdd->sdma_filename);
>>> +
>>> + snprintf(pdd->pasid_filename, MAX_SYSFS_FILENAME_LEN,
>>> "pasid_%u",
>>> + pdd->dev->id);
>>> + kfd_sysfs_create_file(p->kobj, &pdd->attr_pasid,
>>> pdd->pasid_filename);
>>> }
>>> }
>>> @@ -888,9 +895,6 @@ struct kfd_process *kfd_create_process(struct
>>> task_struct *thread)
>>> goto out;
>>> }
>>> - kfd_sysfs_create_file(process->kobj, &process->attr_pasid,
>>> - "pasid");
>>> -
>>> process->kobj_queues = kobject_create_and_add("queues",
>>> process->kobj);
>>> if (!process->kobj_queues)
>>> @@ -1104,7 +1108,6 @@ static void kfd_process_remove_sysfs(struct
>>> kfd_process *p)
>>> if (!p->kobj)
>>> return;
>>> - sysfs_remove_file(p->kobj, &p->attr_pasid);
>>> kobject_del(p->kobj_queues);
>>> kobject_put(p->kobj_queues);
>>> p->kobj_queues = NULL;
>>> @@ -1114,6 +1117,7 @@ static void kfd_process_remove_sysfs(struct
>>> kfd_process *p)
>>> sysfs_remove_file(p->kobj, &pdd->attr_vram);
>>> sysfs_remove_file(p->kobj, &pdd->attr_sdma);
>>> + sysfs_remove_file(p->kobj, &pdd->attr_pasid);
>>> sysfs_remove_file(pdd->kobj_stats, &pdd->attr_evict);
>>> if (pdd->dev->kfd2kgd->get_cu_occupancy)
[-- Attachment #2: Type: text/html, Size: 11180 bytes --]
next prev parent reply other threads:[~2025-10-31 14:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 3:45 [PATCH] amdkfd: implement per process/device pasid in sysfs Zhu Lingshan
2025-10-30 15:05 ` Kuehling, Felix
2025-10-31 2:46 ` Zhu, Lingshan
2025-10-31 13:44 ` Kuehling, Felix
2025-10-30 15:53 ` Chen, Xiaogang
2025-10-30 16:15 ` Christian König
2025-10-31 2:53 ` Zhu, Lingshan
2025-10-31 2:48 ` Zhu, Lingshan
2025-10-31 14:40 ` Chen, Xiaogang [this message]
2025-10-30 18:32 ` Eric Huang
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=d2f42b51-3905-4274-be84-d4d086b4f072@amd.com \
--to=xiaogang.chen@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=felix.kuehling@amd.com \
--cc=lingshan.zhu@amd.com \
--cc=ray.huang@amd.com \
/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;
as well as URLs for NNTP newsgroup(s).