Message ID | 20240502210559.11795-2-wsa+renesas@sang-engineering.com (mailing list archive) |
---|---|
State | Rejected |
Headers | show |
Series | [1/1] IB: sw: rdmavt: mr: use 'time_left' variable with wait_for_completion_timeout() | expand |
On 5/2/24 5:05 PM, Wolfram Sang wrote: > There is a confusing pattern in the kernel to use a variable named 'timeout' to > store the result of wait_for_completion_timeout() causing patterns like: > > timeout = wait_for_completion_timeout(...) > if (!timeout) return -ETIMEDOUT; > > with all kinds of permutations. Use 'time_left' as a variable to make the code > self explaining. > > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> > --- > drivers/infiniband/sw/rdmavt/mr.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c > index 7a9afd5231d5..689e708032fd 100644 > --- a/drivers/infiniband/sw/rdmavt/mr.c > +++ b/drivers/infiniband/sw/rdmavt/mr.c > @@ -441,7 +441,7 @@ static void rvt_dereg_clean_qps(struct rvt_mregion *mr) > */ > static int rvt_check_refs(struct rvt_mregion *mr, const char *t) > { > - unsigned long timeout; > + unsigned long time_left; > struct rvt_dev_info *rdi = ib_to_rvt(mr->pd->device); > > if (mr->lkey) { > @@ -451,8 +451,8 @@ static int rvt_check_refs(struct rvt_mregion *mr, const char *t) > synchronize_rcu(); > } > > - timeout = wait_for_completion_timeout(&mr->comp, 5 * HZ); > - if (!timeout) { > + time_left = wait_for_completion_timeout(&mr->comp, 5 * HZ); > + if (!time_left) { > rvt_pr_err(rdi, > "%s timeout mr %p pd %p lkey %x refcount %ld\n", > t, mr, mr->pd, mr->lkey, Nah. Disagree. I think the code is just fine as it is. -Denny
On Thu, May 02, 2024 at 05:37:35PM -0400, Dennis Dalessandro wrote: > On 5/2/24 5:05 PM, Wolfram Sang wrote: > > There is a confusing pattern in the kernel to use a variable named 'timeout' to > > store the result of wait_for_completion_timeout() causing patterns like: > > > > timeout = wait_for_completion_timeout(...) > > if (!timeout) return -ETIMEDOUT; > > > > with all kinds of permutations. Use 'time_left' as a variable to make the code > > self explaining. > > > > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> > > --- > > drivers/infiniband/sw/rdmavt/mr.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c > > index 7a9afd5231d5..689e708032fd 100644 > > --- a/drivers/infiniband/sw/rdmavt/mr.c > > +++ b/drivers/infiniband/sw/rdmavt/mr.c > > @@ -441,7 +441,7 @@ static void rvt_dereg_clean_qps(struct rvt_mregion *mr) > > */ > > static int rvt_check_refs(struct rvt_mregion *mr, const char *t) > > { > > - unsigned long timeout; > > + unsigned long time_left; > > struct rvt_dev_info *rdi = ib_to_rvt(mr->pd->device); > > > > if (mr->lkey) { > > @@ -451,8 +451,8 @@ static int rvt_check_refs(struct rvt_mregion *mr, const char *t) > > synchronize_rcu(); > > } > > > > - timeout = wait_for_completion_timeout(&mr->comp, 5 * HZ); > > - if (!timeout) { > > + time_left = wait_for_completion_timeout(&mr->comp, 5 * HZ); > > + if (!time_left) { > > rvt_pr_err(rdi, > > "%s timeout mr %p pd %p lkey %x refcount %ld\n", > > t, mr, mr->pd, mr->lkey, > > Nah. Disagree. I think the code is just fine as it is. I agree with Dennis. Let's drop this patch. Thanks > > -Denny
> > > - timeout = wait_for_completion_timeout(&mr->comp, 5 * HZ); > > > - if (!timeout) { > > > + time_left = wait_for_completion_timeout(&mr->comp, 5 * HZ); > > > + if (!time_left) { > > > rvt_pr_err(rdi, > > > "%s timeout mr %p pd %p lkey %x refcount %ld\n", > > > t, mr, mr->pd, mr->lkey, > > > > Nah. Disagree. I think the code is just fine as it is. > > I agree with Dennis. Let's drop this patch. Okay, I added your subsystem to the discard-list. Thanks for the review nonetheless!
diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c index 7a9afd5231d5..689e708032fd 100644 --- a/drivers/infiniband/sw/rdmavt/mr.c +++ b/drivers/infiniband/sw/rdmavt/mr.c @@ -441,7 +441,7 @@ static void rvt_dereg_clean_qps(struct rvt_mregion *mr) */ static int rvt_check_refs(struct rvt_mregion *mr, const char *t) { - unsigned long timeout; + unsigned long time_left; struct rvt_dev_info *rdi = ib_to_rvt(mr->pd->device); if (mr->lkey) { @@ -451,8 +451,8 @@ static int rvt_check_refs(struct rvt_mregion *mr, const char *t) synchronize_rcu(); } - timeout = wait_for_completion_timeout(&mr->comp, 5 * HZ); - if (!timeout) { + time_left = wait_for_completion_timeout(&mr->comp, 5 * HZ); + if (!time_left) { rvt_pr_err(rdi, "%s timeout mr %p pd %p lkey %x refcount %ld\n", t, mr, mr->pd, mr->lkey,
There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_timeout() causing patterns like: timeout = wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> --- drivers/infiniband/sw/rdmavt/mr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)