Skip to contentSkip to conversation

drm/amdkfd: Adding delay after sending the Exception event to runtime

PATCH In review Ahmad Rehman 2 participants 2 messages Oct 17, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: Adding delay after sending the Exception event to runtime

The patch adds the sleep to yield for the runtime to act on the EXCEPTION event. This allows the runtime/app to execute actions on signal reception before driver gets a chance to move ahead with the sequence.

---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +7 -0
index 82905f3e54dd..8dfb796fd506 100644
@@ -1329,6 +1329,13 @@ void kfd_signal_reset_event(struct kfd_node *dev)
 		}
 
 		rcu_read_unlock();
+
+		/*
+		 * Since the set_event is asynchronous, putting a delay
+		 * to give runtime sometime to act on the EXCEPTION before
+		 * driver moves ahead.
+		 */
+		ssleep(2);
 	}
 	srcu_read_unlock(&kfd_processes_srcu, idx);
 }
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 15 lines · Ahmad Rehman

The patch adds the sleep to yield for the runtime to act on the EXCEPTION event. This allows the runtime/app to execute actions on signal reception before driver gets a chance to move ahead with the sequence.

---
  drivers/gpu/drm/amd/amdkfd/kfd_events.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +0 -0
index 82905f3e54dd..8dfb796fd506 100644

drivers/gpu/drm/amd/amdkfd/kfd_events.c void kfd_signal_reset_event(struct kfd_node *dev) · line 1338

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_events.c +7 -0
@@ -1329,6 +1329,13 @@ void kfd_signal_reset_event(struct kfd_node *dev)
  		}
 
  		rcu_read_unlock();
+
+		/*
+		 * Since the set_event is asynchronous, putting a delay
+		 * to give runtime sometime to act on the EXCEPTION before
+		 * driver moves ahead.
+		 */
+		ssleep(2);

This adds a 2s sleep inside a loop that iterates over all processes using KFD. If you have multiple KFD processes running, that could add up to a significant delay.

I also don't like waiting before the srcu_read_unlock, because that would block other threads synchronizing with the kfd_processes_srcu (mostly kfd_process_notifier_release).

What exactly is it that you want to prevent "moving on" to here?

Regards,
  Felix

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_events.c +0 -0
  	}
  	srcu_read_unlock(&kfd_processes_srcu, idx);
  }