* [PATCH 1/1] IB: sw: rdmavt: mr: use 'time_left' variable with wait_for_completion_timeout()
@ 2024-05-02 21:05 Wolfram Sang
2024-05-02 21:37 ` Dennis Dalessandro
0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2024-05-02 21:05 UTC (permalink / raw)
To: linux-rdma
Cc: Wolfram Sang, Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky
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,
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] IB: sw: rdmavt: mr: use 'time_left' variable with wait_for_completion_timeout()
2024-05-02 21:05 [PATCH 1/1] IB: sw: rdmavt: mr: use 'time_left' variable with wait_for_completion_timeout() Wolfram Sang
@ 2024-05-02 21:37 ` Dennis Dalessandro
2024-05-05 13:03 ` Leon Romanovsky
0 siblings, 1 reply; 4+ messages in thread
From: Dennis Dalessandro @ 2024-05-02 21:37 UTC (permalink / raw)
To: Wolfram Sang, linux-rdma; +Cc: Jason Gunthorpe, Leon Romanovsky
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] IB: sw: rdmavt: mr: use 'time_left' variable with wait_for_completion_timeout()
2024-05-02 21:37 ` Dennis Dalessandro
@ 2024-05-05 13:03 ` Leon Romanovsky
2024-05-05 13:20 ` Wolfram Sang
0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2024-05-05 13:03 UTC (permalink / raw)
To: Dennis Dalessandro; +Cc: Wolfram Sang, linux-rdma, Jason Gunthorpe
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] IB: sw: rdmavt: mr: use 'time_left' variable with wait_for_completion_timeout()
2024-05-05 13:03 ` Leon Romanovsky
@ 2024-05-05 13:20 ` Wolfram Sang
0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2024-05-05 13:20 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: Dennis Dalessandro, linux-rdma, Jason Gunthorpe
[-- Attachment #1: Type: text/plain, Size: 526 bytes --]
> > > - 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!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-05 13:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-02 21:05 [PATCH 1/1] IB: sw: rdmavt: mr: use 'time_left' variable with wait_for_completion_timeout() Wolfram Sang
2024-05-02 21:37 ` Dennis Dalessandro
2024-05-05 13:03 ` Leon Romanovsky
2024-05-05 13:20 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).