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

Configure Feed

Select the types of activity you want to include in your feed.

amdkfd: Introduce kfd_create_process_sysfs as a separate function

KFD creates sysfs entries for a kfd_process in
function kfd_create_process when creating it.

This commit extracts the code creating sysfs
entries to a separate function because it
would be invoked in other code path like
creating secondary kfd contexts (kfd_process).

Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Zhu Lingshan and committed by
Alex Deucher
4cd255b9 f433db9c

+42 -25
+1
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
··· 1053 1053 void kfd_process_destroy_wq(void); 1054 1054 void kfd_cleanup_processes(void); 1055 1055 struct kfd_process *kfd_create_process(struct task_struct *thread); 1056 + int kfd_create_process_sysfs(struct kfd_process *process); 1056 1057 struct kfd_process *kfd_get_process(const struct task_struct *task); 1057 1058 struct kfd_process *kfd_lookup_process_by_pasid(u32 pasid, 1058 1059 struct kfd_process_device **pdd);
+41 -25
drivers/gpu/drm/amd/amdkfd/kfd_process.c
··· 825 825 kfd_process_free_gpuvm(qpd->ib_mem, pdd, &qpd->ib_kaddr); 826 826 } 827 827 828 + int kfd_create_process_sysfs(struct kfd_process *process) 829 + { 830 + int ret; 831 + 832 + if (process->kobj) { 833 + pr_warn("kobject already exsists for the kfd_process\n"); 834 + return -EINVAL; 835 + } 836 + 837 + process->kobj = kfd_alloc_struct(process->kobj); 838 + if (!process->kobj) { 839 + pr_warn("Creating procfs kobject failed"); 840 + return -ENOMEM; 841 + } 842 + ret = kobject_init_and_add(process->kobj, &procfs_type, 843 + procfs.kobj, "%d", 844 + (int)process->lead_thread->pid); 845 + if (ret) { 846 + pr_warn("Creating procfs pid directory failed"); 847 + kobject_put(process->kobj); 848 + return ret; 849 + } 850 + 851 + kfd_sysfs_create_file(process->kobj, &process->attr_pasid, 852 + "pasid"); 853 + 854 + process->kobj_queues = kobject_create_and_add("queues", 855 + process->kobj); 856 + if (!process->kobj_queues) 857 + pr_warn("Creating KFD proc/queues folder failed"); 858 + 859 + kfd_procfs_add_sysfs_stats(process); 860 + kfd_procfs_add_sysfs_files(process); 861 + kfd_procfs_add_sysfs_counters(process); 862 + 863 + return 0; 864 + } 865 + 828 866 struct kfd_process *kfd_create_process(struct task_struct *thread) 829 867 { 830 868 struct kfd_process *process; ··· 912 874 if (!procfs.kobj) 913 875 goto out; 914 876 915 - process->kobj = kfd_alloc_struct(process->kobj); 916 - if (!process->kobj) { 917 - pr_warn("Creating procfs kobject failed"); 918 - goto out; 919 - } 920 - ret = kobject_init_and_add(process->kobj, &procfs_type, 921 - procfs.kobj, "%d", 922 - (int)process->lead_thread->pid); 923 - if (ret) { 924 - pr_warn("Creating procfs pid directory failed"); 925 - kobject_put(process->kobj); 926 - goto out; 927 - } 928 - 929 - kfd_sysfs_create_file(process->kobj, &process->attr_pasid, 930 - "pasid"); 931 - 932 - process->kobj_queues = kobject_create_and_add("queues", 933 - process->kobj); 934 - if (!process->kobj_queues) 935 - pr_warn("Creating KFD proc/queues folder failed"); 936 - 937 - kfd_procfs_add_sysfs_stats(process); 938 - kfd_procfs_add_sysfs_files(process); 939 - kfd_procfs_add_sysfs_counters(process); 877 + ret = kfd_create_process_sysfs(process); 878 + if (ret) 879 + pr_warn("Failed to create sysfs entry for the kfd_process"); 940 880 941 881 kfd_debugfs_add_process(process); 942 882