rocm-smi will be able to show the events for KFD process start/end, it is the implementation of this feature.
Unified · Split
| @@ -1054,6 +1054,8 @@ static void kfd_process_destroy_pdds(struct kfd_process *p) · 1053 unmodified lines | |||
| 1054 | for (i = 0; i < p->n_pdds; i++) { | 1054 | for (i = 0; i < p->n_pdds; i++) { |
| 1055 | struct kfd_process_device *pdd = p->pdds[i]; | 1055 | struct kfd_process_device *pdd = p->pdds[i]; |
| 1056 | 1056 | ||
| 1057 | kfd_smi_event_process(pdd, false); | ||
| 1058 | |||
| 1057 | pr_debug("Releasing pdd (topology id %d, for pid %d)\n", | 1059 | pr_debug("Releasing pdd (topology id %d, for pid %d)\n", |
| 1058 | pdd->dev->id, p->lead_thread->pid); | 1060 | pdd->dev->id, p->lead_thread->pid); |
| 1059 | kfd_process_device_destroy_cwsr_dgpu(pdd); | 1061 | kfd_process_device_destroy_cwsr_dgpu(pdd); |
| @@ -1715,6 +1717,8 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, · 655 unmodified lines | |||
| 1715 | pdd->pasid = avm->pasid; | 1717 | pdd->pasid = avm->pasid; |
| 1716 | pdd->drm_file = drm_file; | 1718 | pdd->drm_file = drm_file; |
| 1717 | 1719 | ||
| 1720 | kfd_smi_event_process(pdd, true); | ||
| 1721 | |||
| 1718 | return 0; | 1722 | return 0; |
| 1719 | 1723 | ||
| 1720 | err_get_pasid: | 1724 | err_get_pasid: |
| @@ -345,6 +345,27 @@ void kfd_smi_event_unmap_from_gpu(struct kfd_node *node, pid_t pid, · 344 unmodified lines | |||
| 345 | pid, address, last - address + 1, node->id, trigger)); | 345 | pid, address, last - address + 1, node->id, trigger)); |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | void kfd_smi_event_process(struct kfd_process_device *pdd, bool start) | ||
| 349 | { | ||
| 350 | struct amdgpu_task_info *task_info; | ||
| 351 | struct amdgpu_vm *avm; | ||
| 352 | |||
| 353 | if (pdd->drm_priv) | ||
| 354 | return; | ||
| 355 | |||
| 356 | avm = drm_priv_to_vm(pdd->drm_priv); | ||
| 357 | task_info = amdgpu_vm_get_task_info_vm(avm); | ||
| 358 | |||
| 359 | if (task_info) { | ||
| 360 | kfd_smi_event_add(0, pdd->dev, | ||
| 361 | start ? KFD_SMI_EVENT_PROCESS_START : | ||
| 362 | KFD_SMI_EVENT_PROCESS_END, | ||
| 363 | KFD_EVENT_FMT_PROCESS(task_info->pid, | ||
| 364 | task_info->task_name)); | ||
| 365 | amdgpu_vm_put_task_info(task_info); | ||
| 366 | } | ||
| 367 | } | ||
| 368 | |||
| 348 | int kfd_smi_event_open(struct kfd_node *dev, uint32_t *fd) | 369 | int kfd_smi_event_open(struct kfd_node *dev, uint32_t *fd) |
| 349 | { | 370 | { |
| 350 | struct kfd_smi_client *client; | 371 | struct kfd_smi_client *client; |
| @@ -53,4 +53,5 @@ void kfd_smi_event_queue_restore_rescheduled(struct mm_struct *mm); · 52 unmodified lines | |||
| 53 | void kfd_smi_event_unmap_from_gpu(struct kfd_node *node, pid_t pid, | 53 | void kfd_smi_event_unmap_from_gpu(struct kfd_node *node, pid_t pid, |
| 54 | unsigned long address, unsigned long last, | 54 | unsigned long address, unsigned long last, |
| 55 | uint32_t trigger); | 55 | uint32_t trigger); |
| 56 | void kfd_smi_event_process(struct kfd_process_device *pdd, bool start); | ||
| 56 | #endif | 57 | #endif |
| @@ -536,6 +536,8 @@ enum kfd_smi_event { · 535 unmodified lines | |||
| 536 | KFD_SMI_EVENT_QUEUE_EVICTION = 9, | 536 | KFD_SMI_EVENT_QUEUE_EVICTION = 9, |
| 537 | KFD_SMI_EVENT_QUEUE_RESTORE = 10, | 537 | KFD_SMI_EVENT_QUEUE_RESTORE = 10, |
| 538 | KFD_SMI_EVENT_UNMAP_FROM_GPU = 11, | 538 | KFD_SMI_EVENT_UNMAP_FROM_GPU = 11, |
| 539 | KFD_SMI_EVENT_PROCESS_START = 12, | ||
| 540 | KFD_SMI_EVENT_PROCESS_END = 13, | ||
| 539 | 541 | ||
| 540 | /* | 542 | /* |
| 541 | * max event number, as a flag bit to get events from all processes, | 543 | * max event number, as a flag bit to get events from all processes, |
| @@ -651,6 +653,9 @@ struct kfd_ioctl_smi_events_args { · 109 unmodified lines | |||
| 651 | "%lld -%d @%lx(%lx) %x %d\n", (ns), (pid), (addr), (size),\ | 653 | "%lld -%d @%lx(%lx) %x %d\n", (ns), (pid), (addr), (size),\ |
| 652 | (node), (unmap_trigger) | 654 | (node), (unmap_trigger) |
| 653 | 655 | ||
| 656 | #define KFD_EVENT_FMT_PROCESS(pid, task_name)\ | ||
| 657 | "%x %s\n", (pid), (task_name) | ||
| 658 | |||
| 654 | /************************************************************************************************** | 659 | /************************************************************************************************** |
| 655 | * CRIU IOCTLs (Checkpoint Restore In Userspace) | 660 | * CRIU IOCTLs (Checkpoint Restore In Userspace) |
| 656 | * | 661 | * |