* [PATCH 0/2] rdma: Converge on using secs_to_jiffies()
@ 2025-02-19 21:36 Easwar Hariharan
2025-02-19 21:36 ` [PATCH 1/2] RDMA/mlx4: convert timeouts to secs_to_jiffies() Easwar Hariharan
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Easwar Hariharan @ 2025-02-19 21:36 UTC (permalink / raw)
To: Yishai Hadas, Jason Gunthorpe, Leon Romanovsky
Cc: linux-rdma, linux-kernel, Easwar Hariharan
This series converts users of msecs_to_jiffies() that either use the
multiply pattern of either of:
- msecs_to_jiffies(N*1000) or
- msecs_to_jiffies(N*MSEC_PER_SEC)
where N is a constant or an expression, to avoid the multiplication.
The conversion is made with Coccinelle with the secs_to_jiffies() script
in scripts/coccinelle/misc. Attention is paid to what the best change
can be rather than restricting to what the tool provides.
This series is based on next-20250219
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
Easwar Hariharan (2):
RDMA/mlx4: convert timeouts to secs_to_jiffies()
RDMA/mlx5: convert timeouts to secs_to_jiffies()
drivers/infiniband/hw/mlx4/alias_GUID.c | 2 +-
drivers/infiniband/hw/mlx5/mr.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
---
base-commit: 8936cec5cb6e27649b86fabf383d7ce4113bba49
change-id: 20250219-rdma-secs-to-jiffies-21fb900be3fe
Best regards,
--
Easwar Hariharan <eahariha@linux.microsoft.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] RDMA/mlx4: convert timeouts to secs_to_jiffies()
2025-02-19 21:36 [PATCH 0/2] rdma: Converge on using secs_to_jiffies() Easwar Hariharan
@ 2025-02-19 21:36 ` Easwar Hariharan
2025-02-19 21:36 ` [PATCH 2/2] RDMA/mlx5: " Easwar Hariharan
2025-02-20 7:07 ` [PATCH 0/2] rdma: Converge on using secs_to_jiffies() Leon Romanovsky
2 siblings, 0 replies; 7+ messages in thread
From: Easwar Hariharan @ 2025-02-19 21:36 UTC (permalink / raw)
To: Yishai Hadas, Jason Gunthorpe, Leon Romanovsky
Cc: linux-rdma, linux-kernel, Easwar Hariharan
Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies(). As the value here is a multiple of 1000, use
secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication.
This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
the following Coccinelle rules:
@depends on patch@
expression E;
@@
-msecs_to_jiffies(E * 1000)
+secs_to_jiffies(E)
-msecs_to_jiffies(E * MSEC_PER_SEC)
+secs_to_jiffies(E)
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
drivers/infiniband/hw/mlx4/alias_GUID.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mlx4/alias_GUID.c b/drivers/infiniband/hw/mlx4/alias_GUID.c
index d7327735b8d0d4dd57d44ab1c71554ebf11ce6ce..527f52e41577af3dee60e695f25741f824762fd3 100644
--- a/drivers/infiniband/hw/mlx4/alias_GUID.c
+++ b/drivers/infiniband/hw/mlx4/alias_GUID.c
@@ -437,7 +437,7 @@ static void aliasguid_query_handler(int status,
queue_delayed_work(dev->sriov.alias_guid.ports_guid[port_index].wq,
&dev->sriov.alias_guid.ports_guid[port_index].
alias_guid_work,
- msecs_to_jiffies(resched_delay_sec * 1000));
+ secs_to_jiffies(resched_delay_sec));
}
if (cb_ctx->sa_query) {
list_del(&cb_ctx->list);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] RDMA/mlx5: convert timeouts to secs_to_jiffies()
2025-02-19 21:36 [PATCH 0/2] rdma: Converge on using secs_to_jiffies() Easwar Hariharan
2025-02-19 21:36 ` [PATCH 1/2] RDMA/mlx4: convert timeouts to secs_to_jiffies() Easwar Hariharan
@ 2025-02-19 21:36 ` Easwar Hariharan
2025-04-07 18:06 ` Jason Gunthorpe
2025-02-20 7:07 ` [PATCH 0/2] rdma: Converge on using secs_to_jiffies() Leon Romanovsky
2 siblings, 1 reply; 7+ messages in thread
From: Easwar Hariharan @ 2025-02-19 21:36 UTC (permalink / raw)
To: Yishai Hadas, Jason Gunthorpe, Leon Romanovsky
Cc: linux-rdma, linux-kernel, Easwar Hariharan
Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies(). As the value here is a multiple of 1000, use
secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication.
This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
the following Coccinelle rules:
@depends on patch@
expression E;
@@
-msecs_to_jiffies(E * 1000)
+secs_to_jiffies(E)
-msecs_to_jiffies(E * MSEC_PER_SEC)
+secs_to_jiffies(E)
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
drivers/infiniband/hw/mlx5/mr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 753faa9ad06a8876d4f7c848823825d55df9a43d..86c925489e8179fa2c311ff9ce38c9d51f200649 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -525,7 +525,7 @@ static void queue_adjust_cache_locked(struct mlx5_cache_ent *ent)
ent->fill_to_high_water = false;
if (ent->pending)
queue_delayed_work(ent->dev->cache.wq, &ent->dwork,
- msecs_to_jiffies(1000));
+ secs_to_jiffies(1));
else
mod_delayed_work(ent->dev->cache.wq, &ent->dwork, 0);
}
@@ -576,7 +576,7 @@ static void __cache_work_func(struct mlx5_cache_ent *ent)
"add keys command failed, err %d\n",
err);
queue_delayed_work(cache->wq, &ent->dwork,
- msecs_to_jiffies(1000));
+ secs_to_jiffies(1));
}
}
} else if (ent->mkeys_queue.ci > 2 * ent->limit) {
@@ -2039,7 +2039,7 @@ static int mlx5_revoke_mr(struct mlx5_ib_mr *mr)
spin_lock_irq(&ent->mkeys_queue.lock);
if (ent->is_tmp && !ent->tmp_cleanup_scheduled) {
mod_delayed_work(ent->dev->cache.wq, &ent->dwork,
- msecs_to_jiffies(30 * 1000));
+ secs_to_jiffies(30));
ent->tmp_cleanup_scheduled = true;
}
spin_unlock_irq(&ent->mkeys_queue.lock);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] rdma: Converge on using secs_to_jiffies()
2025-02-19 21:36 [PATCH 0/2] rdma: Converge on using secs_to_jiffies() Easwar Hariharan
2025-02-19 21:36 ` [PATCH 1/2] RDMA/mlx4: convert timeouts to secs_to_jiffies() Easwar Hariharan
2025-02-19 21:36 ` [PATCH 2/2] RDMA/mlx5: " Easwar Hariharan
@ 2025-02-20 7:07 ` Leon Romanovsky
2025-02-20 16:17 ` Easwar Hariharan
2 siblings, 1 reply; 7+ messages in thread
From: Leon Romanovsky @ 2025-02-20 7:07 UTC (permalink / raw)
To: Easwar Hariharan; +Cc: Yishai Hadas, Jason Gunthorpe, linux-rdma, linux-kernel
On Wed, Feb 19, 2025 at 09:36:38PM +0000, Easwar Hariharan wrote:
> This series converts users of msecs_to_jiffies() that either use the
> multiply pattern of either of:
> - msecs_to_jiffies(N*1000) or
> - msecs_to_jiffies(N*MSEC_PER_SEC)
>
> where N is a constant or an expression, to avoid the multiplication.
Can you please provide justification for that? What is wrong with current code?
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] rdma: Converge on using secs_to_jiffies()
2025-02-20 7:07 ` [PATCH 0/2] rdma: Converge on using secs_to_jiffies() Leon Romanovsky
@ 2025-02-20 16:17 ` Easwar Hariharan
2025-02-22 18:13 ` Leon Romanovsky
0 siblings, 1 reply; 7+ messages in thread
From: Easwar Hariharan @ 2025-02-20 16:17 UTC (permalink / raw)
To: Leon Romanovsky
Cc: eahariha, Yishai Hadas, Jason Gunthorpe, linux-rdma, linux-kernel
On 2/19/2025 11:07 PM, Leon Romanovsky wrote:
> On Wed, Feb 19, 2025 at 09:36:38PM +0000, Easwar Hariharan wrote:
>> This series converts users of msecs_to_jiffies() that either use the
>> multiply pattern of either of:
>> - msecs_to_jiffies(N*1000) or
>> - msecs_to_jiffies(N*MSEC_PER_SEC)
>>
>> where N is a constant or an expression, to avoid the multiplication.
>
> Can you please provide justification for that? What is wrong with current code?
>
There is nothing specifically wrong with the current code, it just does an unnecessary
multiplication for what it does, as the cover letter mentions. IMHO, it's also more readable
to just see secs_to_jiffies(30) and understand that it's a 30 second timeout.
Thanks,
Easwar (he/him)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] rdma: Converge on using secs_to_jiffies()
2025-02-20 16:17 ` Easwar Hariharan
@ 2025-02-22 18:13 ` Leon Romanovsky
0 siblings, 0 replies; 7+ messages in thread
From: Leon Romanovsky @ 2025-02-22 18:13 UTC (permalink / raw)
To: Easwar Hariharan; +Cc: Yishai Hadas, Jason Gunthorpe, linux-rdma, linux-kernel
On Thu, Feb 20, 2025 at 08:17:31AM -0800, Easwar Hariharan wrote:
> On 2/19/2025 11:07 PM, Leon Romanovsky wrote:
> > On Wed, Feb 19, 2025 at 09:36:38PM +0000, Easwar Hariharan wrote:
> >> This series converts users of msecs_to_jiffies() that either use the
> >> multiply pattern of either of:
> >> - msecs_to_jiffies(N*1000) or
> >> - msecs_to_jiffies(N*MSEC_PER_SEC)
> >>
> >> where N is a constant or an expression, to avoid the multiplication.
> >
> > Can you please provide justification for that? What is wrong with current code?
> >
>
> There is nothing specifically wrong with the current code.
So let's keep current code as is.
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] RDMA/mlx5: convert timeouts to secs_to_jiffies()
2025-02-19 21:36 ` [PATCH 2/2] RDMA/mlx5: " Easwar Hariharan
@ 2025-04-07 18:06 ` Jason Gunthorpe
0 siblings, 0 replies; 7+ messages in thread
From: Jason Gunthorpe @ 2025-04-07 18:06 UTC (permalink / raw)
To: Easwar Hariharan; +Cc: Yishai Hadas, Leon Romanovsky, linux-rdma, linux-kernel
On Wed, Feb 19, 2025 at 09:36:40PM +0000, Easwar Hariharan wrote:
> Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
> secs_to_jiffies(). As the value here is a multiple of 1000, use
> secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication.
>
> This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
> the following Coccinelle rules:
>
> @depends on patch@
> expression E;
> @@
>
> -msecs_to_jiffies(E * 1000)
> +secs_to_jiffies(E)
>
> -msecs_to_jiffies(E * MSEC_PER_SEC)
> +secs_to_jiffies(E)
>
> Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
> ---
> drivers/infiniband/hw/mlx5/mr.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Applied just this patch, Ye's version of mlx4 is more complete.
Thanks
Jason
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-04-07 18:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 21:36 [PATCH 0/2] rdma: Converge on using secs_to_jiffies() Easwar Hariharan
2025-02-19 21:36 ` [PATCH 1/2] RDMA/mlx4: convert timeouts to secs_to_jiffies() Easwar Hariharan
2025-02-19 21:36 ` [PATCH 2/2] RDMA/mlx5: " Easwar Hariharan
2025-04-07 18:06 ` Jason Gunthorpe
2025-02-20 7:07 ` [PATCH 0/2] rdma: Converge on using secs_to_jiffies() Leon Romanovsky
2025-02-20 16:17 ` Easwar Hariharan
2025-02-22 18:13 ` Leon Romanovsky
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).