On Thu, 2020-10-01 at 16:23 -0700, Jakub Kicinski wrote: > On Thu, 1 Oct 2020 12:52:37 -0700 sa...@kernel.org wrote: > > +static int cmd_alloc_index_retry(struct mlx5_cmd *cmd) > > +{ > > + unsigned long alloc_end = jiffies + msecs_to_jiffies(1000); > > + int idx; > > + > > +retry: > > + idx = cmd_alloc_index(cmd); > > + if (idx < 0 && time_before(jiffies, alloc_end)) { > > + /* Index allocation can fail on heavy load of commands. > > This is a temporary > > + * situation as the current command already holds the > > semaphore, meaning that > > + * another command completion is being handled and it > > is expected to release > > + * the entry index soon. > > + */ > > + cond_resched(); > > + goto retry; > > + } > > + return idx; > > +} > > This looks excessive. At least add some cpu_relax(), or udelay()?
cpu_relax() should also work fine, it is just that we have 100% certainty that the allocation will success real soon.