i40e: avoid spin loop in i40e_asq_send_command()
Subsystems (2)
PATCH 1/1 i40e: avoid spin loop in i40e_asq_send_command()
Previously, the kernel could spend up to 250 ms waiting for a command to be submitted to an admin queue. This function is also called in a loop, e.g., in i40e_get_module_eeprom() (through i40e_aq_get_phy_register()), so the time spent in the kernel may be even higher. We observed scheduling delays of over 2 seconds in production,
with stacktraces pointing to this code as the culprit.
Add a call to cond_resched() so the loop can yield the CPU. Also compute the total time using the jiffies counter instead of assuming udelay() waits the precise time interval requested.
Signed-off-by Caleb Sander <[email protected]>
Reviewed-by Joern Engel <[email protected]>
--- drivers/net/ethernet/intel/i40e/i40e_adminq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_adminq.c +3 -3
@@ -902,7 +902,7 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,* we need to wait for desc write back */ if (!details->async && !details->postpone) { -u32 total_delay =0 ; +unsigned long timeout_end = jiffies +usecs_to_jiffies (hw->aq.asq_cmd_timeout); do { /* AQ designers suggest use of head for better
@@ -910,9 +910,9 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,*/ if (i40e_asq_done (hw))break ; +cond_resched ();udelay (50 ); - total_delay +=50 ; - }while (total_delay < hw->aq.asq_cmd_timeout); + }while (time_before (jiffies, timeout_end)); }/* if ready, copy the desc back to temp */
Signature · 1 line
2.17.1