drm/amdkfd: allow compute partition mode switch with cgroup exclusions
Subsystems (3)
PATCH 1/1 drm/amdkfd: allow compute partition mode switch with cgroup exclusions
The KFD currently bars a compute partition mode switch while a KFD process exists.
Since cgroup excluded devices remain excluded for the lifetime of a KFD process and user space is able to mode switch single devices, allow users to mode switch a device with any running process that has been cgroup excluded from this device.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 8 +-- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 69 ++++++++++++++++++---- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 +- 5 files changed, 70 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
@@ -746,12 +746,12 @@ int amdgpu_amdkfd_send_close_event_drain_irq(struct amdgpu_device *adev,int amdgpu_amdkfd_check_and_lock_kfd (struct amdgpu_device *adev) { -return kgd2kfd_check_and_lock_kfd (); +return kgd2kfd_check_and_lock_kfd (adev->kfd.dev); }void amdgpu_amdkfd_unlock_kfd (struct amdgpu_device *adev) { -kgd2kfd_unlock_kfd (); +kgd2kfd_unlock_kfd (adev->kfd.dev); }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +4 -4
@@ -419,8 +419,8 @@ int kgd2kfd_post_reset(struct kfd_dev *kfd);void kgd2kfd_interrupt (struct kfd_dev *kfd,const void *ih_ring_entry);void kgd2kfd_set_sram_ecc_flag (struct kfd_dev *kfd);void kgd2kfd_smi_event_throttle (struct kfd_dev *kfd,uint64_t throttle_bitmask); -int kgd2kfd_check_and_lock_kfd (void ); -void kgd2kfd_unlock_kfd (void ); +int kgd2kfd_check_and_lock_kfd (struct kfd_dev *kfd); +void kgd2kfd_unlock_kfd (struct kfd_dev *kfd);int kgd2kfd_start_sched (struct kfd_dev *kfd,uint32_t node_id);int kgd2kfd_stop_sched (struct kfd_dev *kfd,uint32_t node_id);bool kgd2kfd_compute_active (struct kfd_dev *kfd,uint32_t node_id);
@@ -489,12 +489,12 @@ void kgd2kfd_smi_event_throttle(struct kfd_dev *kfd, uint64_t throttle_bitmask) { } -static inline int kgd2kfd_check_and_lock_kfd (void ) +static inline int kgd2kfd_check_and_lock_kfd (struct kfd_dev *kfd) {return 0 ; } -static inline void kgd2kfd_unlock_kfd (void ) +static inline void kgd2kfd_unlock_kfd (struct kfd_dev *kfd) { }
drivers/gpu/drm/amd/amdkfd/kfd_device.c +59 -10
93 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4 -1
@@ -372,6 +372,9 @@ struct kfd_dev {/* bitmap for dynamic doorbell allocation from doorbell object */ unsigned long *doorbell_bitmap; + +/* for dynamic partitioning */ +int kfd_dev_lock; };enum kfd_mempool {
@@ -1536,7 +1539,7 @@ static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)int kfd_send_exception_to_runtime (struct kfd_process *p,unsigned int queue_id,uint64_t error_reason); -bool kfd_is_locked (void ); +bool kfd_is_locked (struct kfd_dev *kfd);/* Compute profile */ void kfd_inc_compute_active (struct kfd_node *dev);
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
@@ -854,7 +854,7 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)*/ mutex_lock (&kfd_processes_mutex); -if (kfd_is_locked ()) { +if (kfd_is_locked (NULL )) {pr_debug ("KFD is locked! Cannot create process" ); process =ERR_PTR (-EINVAL ); goto out;
Signature · 1 line
2.34.1
[Public]
-----Original Message-----
From: Kim, Jonathan <[email protected]>
Sent: Thursday, May 29, 2025 3:10 PM
To: [email protected]
Cc: Kasiviswanathan, Harish <[email protected]>; Kim, Jonathan <[email protected]>
Subject: [PATCH] drm/amdkfd: allow compute partition mode switch with cgroup exclusions
The KFD currently bars a compute partition mode switch while a KFD process exists.
Since cgroup excluded devices remain excluded for the lifetime of a KFD process and user space is able to mode switch single devices, allow users to mode switch a device with any running process that has been cgroup excluded from this device.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 8 +-- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 69 ++++++++++++++++++---- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 +- 5 files changed, 70 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
@@ -746,12 +746,12 @@ int amdgpu_amdkfd_send_close_event_drain_irq(struct amdgpu_device *adev,int amdgpu_amdkfd_check_and_lock_kfd (struct amdgpu_device *adev) { -return kgd2kfd_check_and_lock_kfd (); +return kgd2kfd_check_and_lock_kfd (adev->kfd.dev); }void amdgpu_amdkfd_unlock_kfd (struct amdgpu_device *adev) { -kgd2kfd_unlock_kfd (); +kgd2kfd_unlock_kfd (adev->kfd.dev); }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +4 -4
@@ -419,8 +419,8 @@ int kgd2kfd_post_reset(struct kfd_dev *kfd);void kgd2kfd_interrupt (struct kfd_dev *kfd,const void *ih_ring_entry);void kgd2kfd_set_sram_ecc_flag (struct kfd_dev *kfd);void kgd2kfd_smi_event_throttle (struct kfd_dev *kfd,uint64_t throttle_bitmask); -int kgd2kfd_check_and_lock_kfd (void ); -void kgd2kfd_unlock_kfd (void ); +int kgd2kfd_check_and_lock_kfd (struct kfd_dev *kfd); +void kgd2kfd_unlock_kfd (struct kfd_dev *kfd);int kgd2kfd_start_sched (struct kfd_dev *kfd,uint32_t node_id);int kgd2kfd_stop_sched (struct kfd_dev *kfd,uint32_t node_id);bool kgd2kfd_compute_active (struct kfd_dev *kfd,uint32_t node_id);
@@ -489,12 +489,12 @@ void kgd2kfd_smi_event_throttle(struct kfd_dev *kfd, uint64_t throttle_bitmask) { } -static inline int kgd2kfd_check_and_lock_kfd (void ) +static inline int kgd2kfd_check_and_lock_kfd (struct kfd_dev *kfd) {return 0 ; } -static inline void kgd2kfd_unlock_kfd (void ) +static inline void kgd2kfd_unlock_kfd (struct kfd_dev *kfd) { }
drivers/gpu/drm/amd/amdkfd/kfd_device.c +59 -10
93 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4 -1
@@ -372,6 +372,9 @@ struct kfd_dev {/* bitmap for dynamic doorbell allocation from doorbell object */ unsigned long *doorbell_bitmap; + +/* for dynamic partitioning */ +int kfd_dev_lock; };enum kfd_mempool {
@@ -1536,7 +1539,7 @@ static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)int kfd_send_exception_to_runtime (struct kfd_process *p,unsigned int queue_id,uint64_t error_reason); -bool kfd_is_locked (void ); +bool kfd_is_locked (struct kfd_dev *kfd);/* Compute profile */ void kfd_inc_compute_active (struct kfd_node *dev);
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
@@ -854,7 +854,7 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)*/ mutex_lock (&kfd_processes_mutex); -if (kfd_is_locked ()) { +if (kfd_is_locked (NULL )) {pr_debug ("KFD is locked! Cannot create process" ); process =ERR_PTR (-EINVAL ); goto out;
--
2.34.1