* [PATCH net-next 1/3] net/smc: convert timeouts to secs_to_jiffies()
2025-02-19 20:30 [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two Easwar Hariharan
@ 2025-02-19 20:30 ` Easwar Hariharan
2025-02-19 20:30 ` [PATCH net-next 2/3] netfilter: xt_IDLETIMER: " Easwar Hariharan
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Easwar Hariharan @ 2025-02-19 20:30 UTC (permalink / raw)
To: Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Pablo Neira Ayuso, Jozsef Kadlecsik, David Ahern
Cc: linux-rdma, linux-s390, netdev, linux-kernel, netfilter-devel,
coreteam, 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 ca6984541edbda33a3539a48ed7c2aefecfa690e..dd713b8f783024c46f30bf04cbaad898a631f3f4 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2730,8 +2730,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
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH net-next 2/3] netfilter: xt_IDLETIMER: convert timeouts to secs_to_jiffies()
2025-02-19 20:30 [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two Easwar Hariharan
2025-02-19 20:30 ` [PATCH net-next 1/3] net/smc: convert timeouts to secs_to_jiffies() Easwar Hariharan
@ 2025-02-19 20:30 ` Easwar Hariharan
2025-02-19 20:30 ` [PATCH net-next 3/3] net: ipconfig: " Easwar Hariharan
2025-02-22 0:21 ` [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two Jakub Kicinski
3 siblings, 0 replies; 6+ messages in thread
From: Easwar Hariharan @ 2025-02-19 20:30 UTC (permalink / raw)
To: Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Pablo Neira Ayuso, Jozsef Kadlecsik, David Ahern
Cc: linux-rdma, linux-s390, netdev, linux-kernel, netfilter-devel,
coreteam, 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/netfilter/xt_IDLETIMER.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c
index 9f54819eb52ca28a6ef6544249e864f17ca3de7a..9082155ee558933c640f51f1a6fec8ccdc1f0fa2 100644
--- a/net/netfilter/xt_IDLETIMER.c
+++ b/net/netfilter/xt_IDLETIMER.c
@@ -168,7 +168,7 @@ static int idletimer_tg_create(struct idletimer_tg_info *info)
INIT_WORK(&info->timer->work, idletimer_tg_work);
mod_timer(&info->timer->timer,
- msecs_to_jiffies(info->timeout * 1000) + jiffies);
+ secs_to_jiffies(info->timeout) + jiffies);
return 0;
@@ -229,7 +229,7 @@ static int idletimer_tg_create_v1(struct idletimer_tg_info_v1 *info)
} else {
timer_setup(&info->timer->timer, idletimer_tg_expired, 0);
mod_timer(&info->timer->timer,
- msecs_to_jiffies(info->timeout * 1000) + jiffies);
+ secs_to_jiffies(info->timeout) + jiffies);
}
return 0;
@@ -254,7 +254,7 @@ static unsigned int idletimer_tg_target(struct sk_buff *skb,
info->label, info->timeout);
mod_timer(&info->timer->timer,
- msecs_to_jiffies(info->timeout * 1000) + jiffies);
+ secs_to_jiffies(info->timeout) + jiffies);
return XT_CONTINUE;
}
@@ -275,7 +275,7 @@ static unsigned int idletimer_tg_target_v1(struct sk_buff *skb,
alarm_start_relative(&info->timer->alarm, tout);
} else {
mod_timer(&info->timer->timer,
- msecs_to_jiffies(info->timeout * 1000) + jiffies);
+ secs_to_jiffies(info->timeout) + jiffies);
}
return XT_CONTINUE;
@@ -320,7 +320,7 @@ static int idletimer_tg_checkentry(const struct xt_tgchk_param *par)
if (info->timer) {
info->timer->refcnt++;
mod_timer(&info->timer->timer,
- msecs_to_jiffies(info->timeout * 1000) + jiffies);
+ secs_to_jiffies(info->timeout) + jiffies);
pr_debug("increased refcnt of timer %s to %u\n",
info->label, info->timer->refcnt);
@@ -382,7 +382,7 @@ static int idletimer_tg_checkentry_v1(const struct xt_tgchk_param *par)
}
} else {
mod_timer(&info->timer->timer,
- msecs_to_jiffies(info->timeout * 1000) + jiffies);
+ secs_to_jiffies(info->timeout) + jiffies);
}
pr_debug("increased refcnt of timer %s to %u\n",
info->label, info->timer->refcnt);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH net-next 3/3] net: ipconfig: convert timeouts to secs_to_jiffies()
2025-02-19 20:30 [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two Easwar Hariharan
2025-02-19 20:30 ` [PATCH net-next 1/3] net/smc: convert timeouts to secs_to_jiffies() Easwar Hariharan
2025-02-19 20:30 ` [PATCH net-next 2/3] netfilter: xt_IDLETIMER: " Easwar Hariharan
@ 2025-02-19 20:30 ` Easwar Hariharan
2025-02-22 0:21 ` [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two Jakub Kicinski
3 siblings, 0 replies; 6+ messages in thread
From: Easwar Hariharan @ 2025-02-19 20:30 UTC (permalink / raw)
To: Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Pablo Neira Ayuso, Jozsef Kadlecsik, David Ahern
Cc: linux-rdma, linux-s390, netdev, linux-kernel, netfilter-devel,
coreteam, 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)
While here, manually convert a couple timeouts denominated in seconds
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
net/ipv4/ipconfig.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index c56b6fe6f0d771e9275bb66c159d9abb330bdf4c..22a7889876c1cf7d5233fe8a0ee12e134b20c1cd 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -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:
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two
2025-02-19 20:30 [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two Easwar Hariharan
` (2 preceding siblings ...)
2025-02-19 20:30 ` [PATCH net-next 3/3] net: ipconfig: " Easwar Hariharan
@ 2025-02-22 0:21 ` Jakub Kicinski
2025-03-03 20:57 ` Easwar Hariharan
3 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2025-02-22 0:21 UTC (permalink / raw)
To: Easwar Hariharan
Cc: Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
Pablo Neira Ayuso, Jozsef Kadlecsik, David Ahern, linux-rdma,
linux-s390, netdev, linux-kernel, netfilter-devel, coreteam
On Wed, 19 Feb 2025 20:30:35 +0000 Easwar Hariharan wrote:
> 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.
>
> The non-netdev patches that include the update to secs_to_jiffies.cocci to address
> expressions are here: https://lore.kernel.org/all/20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com
Can the secs_to_jiffies cocci check script finally run in report mode?
I think that needs to be fixed first, before we start "cleaning up"
existing code under net.
--
pw-bot: defer
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two
2025-02-22 0:21 ` [PATCH net-next 0/3] Converge on using secs_to_jiffies() part two Jakub Kicinski
@ 2025-03-03 20:57 ` Easwar Hariharan
0 siblings, 0 replies; 6+ messages in thread
From: Easwar Hariharan @ 2025-03-03 20:57 UTC (permalink / raw)
To: Jakub Kicinski
Cc: eahariha, Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
Pablo Neira Ayuso, Jozsef Kadlecsik, David Ahern, linux-rdma,
linux-s390, netdev, linux-kernel, netfilter-devel, coreteam
On 2/21/2025 4:21 PM, Jakub Kicinski wrote:
> On Wed, 19 Feb 2025 20:30:35 +0000 Easwar Hariharan wrote:
>> 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.
>>
>> The non-netdev patches that include the update to secs_to_jiffies.cocci to address
>> expressions are here: https://lore.kernel.org/all/20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com
>
> Can the secs_to_jiffies cocci check script finally run in report mode?
>
> I think that needs to be fixed first, before we start "cleaning up"
> existing code under net.
It does not, yet. I'm not ignoring this feedback, it's just taking a bit
of wall clock time between commercial commitments. :)
Thanks,
Easwar (he/him)
^ permalink raw reply [flat|nested] 6+ messages in thread