Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdkfd: add smi events for process start and end

rocm-smi will be able to show the events for KFD process
start/end, it is the implementation of this feature.

Signed-off-by: Eric Huang <jinhuieric.huang@amd.com>
Reviewed-by: Kent Russell <kent.russell@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Eric Huang and committed by
Alex Deucher
4172b556 1d9bff4c

+31
+4
drivers/gpu/drm/amd/amdkfd/kfd_process.c
··· 1054 1054 for (i = 0; i < p->n_pdds; i++) { 1055 1055 struct kfd_process_device *pdd = p->pdds[i]; 1056 1056 1057 + kfd_smi_event_process(pdd, false); 1058 + 1057 1059 pr_debug("Releasing pdd (topology id %d, for pid %d)\n", 1058 1060 pdd->dev->id, p->lead_thread->pid); 1059 1061 kfd_process_device_destroy_cwsr_dgpu(pdd); ··· 1716 1714 1717 1715 pdd->pasid = avm->pasid; 1718 1716 pdd->drm_file = drm_file; 1717 + 1718 + kfd_smi_event_process(pdd, true); 1719 1719 1720 1720 return 0; 1721 1721
+21
drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
··· 345 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 369 int kfd_smi_event_open(struct kfd_node *dev, uint32_t *fd) 349 370 { 350 371 struct kfd_smi_client *client;
+1
drivers/gpu/drm/amd/amdkfd/kfd_smi_events.h
··· 53 53 void kfd_smi_event_unmap_from_gpu(struct kfd_node *node, pid_t pid, 54 54 unsigned long address, unsigned long last, 55 55 uint32_t trigger); 56 + void kfd_smi_event_process(struct kfd_process_device *pdd, bool start); 56 57 #endif
+5
include/uapi/linux/kfd_ioctl.h
··· 536 536 KFD_SMI_EVENT_QUEUE_EVICTION = 9, 537 537 KFD_SMI_EVENT_QUEUE_RESTORE = 10, 538 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 543 * max event number, as a flag bit to get events from all processes, ··· 652 650 #define KFD_EVENT_FMT_UNMAP_FROM_GPU(ns, pid, addr, size, node, unmap_trigger)\ 653 651 "%lld -%d @%lx(%lx) %x %d\n", (ns), (pid), (addr), (size),\ 654 652 (node), (unmap_trigger) 653 + 654 + #define KFD_EVENT_FMT_PROCESS(pid, task_name)\ 655 + "%x %s\n", (pid), (task_name) 655 656 656 657 /************************************************************************************************** 657 658 * CRIU IOCTLs (Checkpoint Restore In Userspace)