Converge on using secs_to_jiffies() part two
Subsystems (6)
v2 cover Converge on using secs_to_jiffies() part two
This is the second series (part 1*) that 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 net-next.
---
Changes in v2:
- Implemented report mode for the secs_to_jiffies coccicheck script (Jakub), patch has been queued by Andrew Morton in mm-nonmm-unstable
- Link: https://web.git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/commit/?h=mm-nonmm-unstable&id=a01189aaf16e8d8d619067939ea21ea97a279864
- Drop change to netfilter already merged upstream: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f4293c2baf6faa5f1a1638bcce698ed88d0d396e
- Link to v1: https://lore.kernel.org/r/20250219-netdev-secs-to-jiffies-part-2-v1-0-c484cc63611b@linux.microsoft.com
---
Easwar Hariharan (2):
net/smc: convert timeouts to secs_to_jiffies()
net: ipconfig: convert timeouts to secs_to_jiffies()
net/ipv4/ipconfig.c | 6 +++--- net/smc/af_smc.c | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-)
---
base-commit: 6b9fd8857b9fc4dd62e7cd300327f0e48dd76642
change-id: 20250128-netdev-secs-to-jiffies-part-2-8f0d2535096a
Best regards,
Signature · 1 line
Easwar Hariharan <[email protected]>
PATCH v2 1/2 net/smc: convert timeouts to secs_to_jiffies()
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)
--- net/smc/af_smc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/smc/af_smc.c +1 -2
@@ -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;
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 1/2] net/smc: convert timeouts to secs_to_jiffies()
Quoted 17 lines · Easwar Hariharan
Commit
b35108a51cf7("jiffies: Definesecs_to_jiffies()") introducedsecs_to_jiffies(). As the value here is a multiple of 1000, usesecs_to_jiffies()instead ofmsecs_to_jiffiesto avoid the multiplication.This is converted using
scripts/coccinelle/misc/secs_to_jiffies.cocciwith the following Coccinelle rules:@depends on patch@
expression E;
@@(quoted diff) +2
-2-msecs_to_jiffies(E * 1000) +secs_to_jiffies(E) -msecs_to_jiffies(E * MSEC_PER_SEC) +secs_to_jiffies(E)
Quoted 1 line
Signed-off-by Easwar Hariharan <[email protected]>
Best regards,
Dust
Sidraya Jayagond
maintainerRe: [PATCH net-next v2 1/2] net/smc: convert timeouts to secs_to_jiffies()
In reply to Easwar HariharanQuoted 28 lines · Easwar Hariharan
Commit
b35108a51cf7("jiffies: Definesecs_to_jiffies()") introducedsecs_to_jiffies(). As the value here is a multiple of 1000, usesecs_to_jiffies()instead ofmsecs_to_jiffiesto avoid the multiplication.This is converted using
scripts/coccinelle/misc/secs_to_jiffies.cocciwith the following Coccinelle rules:@depends on patch@
expression E;
@@(quoted diff) +2
-2-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 <[email protected]>--- net/smc/af_smc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/smc/af_smc.c +0
-0
net/smc/af_smc.c int smc_accept(struct socket *sock, struct socket *new_sock, · line 2741
Quoted 9 lines
net/smc/af_smc.c +1
-2@@ -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 <[email protected]>
Re: [PATCH net-next v2 1/2] net/smc: convert timeouts to secs_to_jiffies()
In reply to Easwar HariharanQuoted 28 lines · Easwar Hariharan
Commit
b35108a51cf7("jiffies: Definesecs_to_jiffies()") introducedsecs_to_jiffies(). As the value here is a multiple of 1000, usesecs_to_jiffies()instead ofmsecs_to_jiffiesto avoid the multiplication.This is converted using
scripts/coccinelle/misc/secs_to_jiffies.cocciwith the following Coccinelle rules:@depends on patch@
expression E;
@@(quoted diff) +2
-2-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 <[email protected]>--- net/smc/af_smc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/smc/af_smc.c +0
-0
net/smc/af_smc.c int smc_accept(struct socket *sock, struct socket *new_sock, · line 2741
Quoted 9 lines
net/smc/af_smc.c +1
-2@@ -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.
PATCH v2 2/2 net: ipconfig: convert timeouts to secs_to_jiffies()
In reply to Easwar HariharanCommit 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)
While here, manually convert a couple timeouts denominated in seconds
--- net/ipv4/ipconfig.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv4/ipconfig.c +3 -3
@@ -274,9 +274,9 @@ static int __init ic_open_devs(void)/* wait for a carrier on at least one device */ start = jiffies; - next_msg = start +msecs_to_jiffies (20000 ); + next_msg = start +secs_to_jiffies (20 );while (time_before (jiffies, start + -msecs_to_jiffies (carrier_timeout *1000 ))) { +secs_to_jiffies (carrier_timeout))) {int wait, elapsed;rtnl_lock ();
@@ -295,7 +295,7 @@ static int __init ic_open_devs(void) elapsed =jiffies_to_msecs (jiffies - start); wait = (carrier_timeout *1000 - elapsed +500 ) /1000 ;pr_info ("Waiting up to %d more seconds for network.\n" , wait); - next_msg = jiffies +msecs_to_jiffies (20000 ); + next_msg = jiffies +secs_to_jiffies (20 ); } have_carrier:
Signature · 1 line
2.43.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 07 Jul 2025 15:03:31 -0700 you wrote:
This is the second series (part 1*) that 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.
[...]
Here is the summary with links:
- [net-next,v2,1/2] net/smc: convert timeouts to secs_to_jiffies()
https://git.kernel.org/netdev/net-next/c/4814f9110ec6 - [net-next,v2,2/2] net: ipconfig: convert timeouts to secs_to_jiffies() https://git.kernel.org/netdev/net-next/c/31326d98416e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html