Skip to contentSkip to conversation

aer: add cond_resched to aer_isr

PATCH In review Spencer Baugh 2 participants 2 messages Jul 23, 2015 – Aug 3, 2015 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aer: add cond_resched to aer_isr

From: Joern Engel <[email protected]>

Multiple nested loops. I have observed 590ms scheduler latency caused by this loop and interrupts. Interrupts were responsible for 190ms, the rest could have been avoided with a cond_resched.

---
 drivers/pci/pcie/aer/aerdrv_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/pcie/aer/aerdrv_core.c +3 -1
index 9803e3d..32b1b5c 100644
@@ -780,8 +780,10 @@ void aer_isr(struct work_struct *work)
 	struct aer_err_source uninitialized_var(e_src);
 
 	mutex_lock(&rpc->rpc_mutex);
-	while (get_e_source(rpc, &e_src))
+	while (get_e_source(rpc, &e_src)) {
 		aer_isr_one_error(p_device, &e_src);
+		cond_resched();
+	}
 	mutex_unlock(&rpc->rpc_mutex);
 
 	wake_up(&rpc->wait_release);
Signature · 1 line
2.5.0.rc3
maintainer
#1 lore raw

Hi Spencer & Joern,

Quoted 5 lines · Spencer Baugh

From: Joern Engel <[email protected]>

Multiple nested loops. I have observed 590ms scheduler latency caused by this loop and interrupts. Interrupts were responsible for 190ms, the rest could have been avoided with a cond_resched.

I'm not disagreeing with this patch, but it would be helpful to sketch the outline of the "multiple nested loop" problem here. This might be a hint that we could do even better by rethinking the algorithm reduce the nesting.

Quoted 25 lines
---
 drivers/pci/pcie/aer/aerdrv_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/pcie/aer/aerdrv_core.c +3 -1
index 9803e3d..32b1b5c 100644
@@ -780,8 +780,10 @@ void aer_isr(struct work_struct *work)
 	struct aer_err_source uninitialized_var(e_src);
 
 	mutex_lock(&rpc->rpc_mutex);
-	while (get_e_source(rpc, &e_src))
+	while (get_e_source(rpc, &e_src)) {
 		aer_isr_one_error(p_device, &e_src);
+		cond_resched();
+	}
 	mutex_unlock(&rpc->rpc_mutex);
 
 	wake_up(&rpc->wait_release);
Signature · 1 line
2.5.0.rc3