[PATCH net-next v2 1/2] net/smc: convert timeouts to secs_to_jiffies()

Easwar Hariharan posted 2 patches 3 months ago
There is a newer version of this series
[PATCH net-next v2 1/2] net/smc: convert timeouts to secs_to_jiffies()
Posted by Easwar Hariharan 3 months ago
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>
---
 net/smc/af_smc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 8d56e4db63e041724f156aa3ab30bab745a15bad..bdbaad17f98012c10d0bbc721c80d4c5ae4fb220 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2735,8 +2735,7 @@ int smc_accept(struct socket *sock, struct socket *new_sock,
 
 	if (lsmc->sockopt_defer_accept && !(arg->flags & O_NONBLOCK)) {
 		/* wait till data arrives on the socket */
-		timeo = msecs_to_jiffies(lsmc->sockopt_defer_accept *
-								MSEC_PER_SEC);
+		timeo = secs_to_jiffies(lsmc->sockopt_defer_accept);
 		if (smc_sk(nsk)->use_fallback) {
 			struct sock *clcsk = smc_sk(nsk)->clcsock->sk;
 

-- 
2.43.0
Re: [PATCH net-next v2 1/2] net/smc: convert timeouts to secs_to_jiffies()
Posted by Sidraya Jayagond 3 months ago

On 08/07/25 3:33 am, 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>
> ---
>   net/smc/af_smc.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index 8d56e4db63e041724f156aa3ab30bab745a15bad..bdbaad17f98012c10d0bbc721c80d4c5ae4fb220 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -2735,8 +2735,7 @@ int smc_accept(struct socket *sock, struct socket *new_sock,
>   
>   	if (lsmc->sockopt_defer_accept && !(arg->flags & O_NONBLOCK)) {
>   		/* wait till data arrives on the socket */
> -		timeo = msecs_to_jiffies(lsmc->sockopt_defer_accept *
> -								MSEC_PER_SEC);
> +		timeo = secs_to_jiffies(lsmc->sockopt_defer_accept);
>   		if (smc_sk(nsk)->use_fallback) {
>   			struct sock *clcsk = smc_sk(nsk)->clcsock->sk;
>   
> 
Reviewed-by: Sidraya Jayagond <sidraya@linux.ibm.com>


Re: [PATCH net-next v2 1/2] net/smc: convert timeouts to secs_to_jiffies()
Posted by Guangguan Wang 3 months ago

在 2025/7/8 06:03, 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>
> ---
>  net/smc/af_smc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index 8d56e4db63e041724f156aa3ab30bab745a15bad..bdbaad17f98012c10d0bbc721c80d4c5ae4fb220 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -2735,8 +2735,7 @@ int smc_accept(struct socket *sock, struct socket *new_sock,
>  
>  	if (lsmc->sockopt_defer_accept && !(arg->flags & O_NONBLOCK)) {
>  		/* wait till data arrives on the socket */
> -		timeo = msecs_to_jiffies(lsmc->sockopt_defer_accept *
> -								MSEC_PER_SEC);
> +		timeo = secs_to_jiffies(lsmc->sockopt_defer_accept);
>  		if (smc_sk(nsk)->use_fallback) {
>  			struct sock *clcsk = smc_sk(nsk)->clcsock->sk;
>  
> 

LGTM.
Reviewed-by: Guangguan Wang <guangguan.wang@linux.alibaba.com>
Re: [PATCH net-next v2 1/2] net/smc: convert timeouts to secs_to_jiffies()
Posted by Dust Li 3 months ago
On 2025-07-07 15:03:32, 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>

Reviewed-by: Dust Li <dust.li@linux.alibaba.com>

Best regards,
Dust