Skip to contentSkip to conversation

Converge on using secs_to_jiffies() part two

PATCH Superseded Easwar Hariharan 14 participants 43 messages Jan 28, 2025 – Feb 13, 2025

Subsystems (22)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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.

Andrew has kindly agreed to take the series through mm.git modulo the patches maintainers want to pick through their own trees.

This series is based on next-20250128

* https://lore.kernel.org/all/20241210-converge-secs-to-jiffies-v3-0-ddfefd7e9f2a@linux.microsoft.com/

---
Easwar Hariharan (16):
coccinelle: misc: secs_to_jiffies: Patch expressions too
scsi: lpfc: convert timeouts to secs_to_jiffies() accel/habanalabs: convert timeouts to secs_to_jiffies()
ALSA: ac97: convert timeouts to secs_to_jiffies()
btrfs: convert timeouts to secs_to_jiffies()
rbd: convert timeouts to secs_to_jiffies()
libceph: convert timeouts to secs_to_jiffies()
libata: zpodd: convert timeouts to secs_to_jiffies()
xfs: convert timeouts to secs_to_jiffies()
power: supply: da9030: convert timeouts to secs_to_jiffies()
nvme: convert timeouts to secs_to_jiffies()
spi: spi-fsl-lpspi: convert timeouts to secs_to_jiffies()
spi: spi-imx: convert timeouts to secs_to_jiffies() platform/x86/amd/pmf: convert timeouts to secs_to_jiffies() platform/x86: thinkpad_acpi: convert timeouts to secs_to_jiffies() RDMA/bnxt_re: convert timeouts to secs_to_jiffies()

 .../accel/habanalabs/common/command_submission.c   |  2 +-
 drivers/accel/habanalabs/common/debugfs.c          |  2 +-
 drivers/accel/habanalabs/common/device.c           |  2 +-
 drivers/accel/habanalabs/common/habanalabs_drv.c   |  2 +-
 drivers/ata/libata-zpodd.c                         |  3 +--
 drivers/block/rbd.c                                |  6 +++---
 drivers/infiniband/hw/bnxt_re/qplib_rcfw.c         |  2 +-
 drivers/nvme/host/core.c                           |  6 ++----
 drivers/platform/x86/amd/pmf/acpi.c                |  3 ++-
 drivers/platform/x86/thinkpad_acpi.c               |  2 +-
 drivers/power/supply/da9030_battery.c              |  3 +--
 drivers/scsi/lpfc/lpfc_init.c                      |  4 ++--
 drivers/scsi/lpfc/lpfc_scsi.c                      | 12 +++++------
 drivers/scsi/lpfc/lpfc_sli.c                       | 24 ++++++++--------------
 drivers/scsi/lpfc/lpfc_vport.c                     |  2 +-
 drivers/spi/spi-fsl-lpspi.c                        |  2 +-
 drivers/spi/spi-imx.c                              |  2 +-
 fs/btrfs/disk-io.c                                 |  6 +++---
 fs/xfs/xfs_icache.c                                |  2 +-
 fs/xfs/xfs_sysfs.c                                 |  7 +++----
 net/ceph/ceph_common.c                             | 10 ++++-----
 net/ceph/osd_client.c                              |  3 +--
 scripts/coccinelle/misc/secs_to_jiffies.cocci      | 22 ++++++++++++++------
 sound/pci/ac97/ac97_codec.c                        |  3 +--
 24 files changed, 63 insertions(+), 69 deletions(-)

---
base-commit: 9a87ce288fe30f268b3a598422fe76af9bb2c2d2
change-id: 20241217-converge-secs-to-jiffies-part-two-f44017aa6f67

Best regards,

Signature · 1 line
Easwar Hariharan <[email protected]>
#1 lore raw

PATCH 1/16 coccinelle: misc: secs_to_jiffies: Patch expressions too

Teach the script to suggest conversions for timeout patterns where the arguments to msecs_to_jiffies() are expressions as well.

---
 scripts/coccinelle/misc/secs_to_jiffies.cocci | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
scripts/coccinelle/misc/secs_to_jiffies.cocci +16 -6
index 8bbb2884ea5db939c63fd4513cf5ca8c977aa8cb..ab9880d239f7d2a8d56a481a2710369e1082e16e 100644
@@ -11,12 +11,22 @@
 
 virtual patch
 
-@depends on patch@ constant C; @@
+@depends on patch@
+constant C;
+@@
 
-- msecs_to_jiffies(C * 1000)
-+ secs_to_jiffies(C)
+-msecs_to_jiffies
++secs_to_jiffies
+ (C
+- * \( 1000 \| MSEC_PER_SEC \)
+ )
 
-@depends on patch@ constant C; @@
+@depends on patch@
+expression E;
+@@
 
-- msecs_to_jiffies(C * MSEC_PER_SEC)
-+ secs_to_jiffies(C)
+-msecs_to_jiffies
++secs_to_jiffies
+ (E
+- * \( 1000 \| MSEC_PER_SEC \)
+ )
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 01/16] coccinelle: misc: secs_to_jiffies: Patch expressions too

Quoted 2 lines

Teach the script to suggest conversions for timeout patterns where the arguments to msecs_to_jiffies() are expressions as well.

I propose to take another look at implementation details for such a script variant according to the semantic patch language.

…

Quoted 4 lines

+++ b/scripts/coccinelle/misc/secs_to_jiffies.cocci

scripts/coccinelle/misc/secs_to_jiffies.cocci +0 -0
@@ -11,12 +11,22 @@
 
 virtual patch

…

Quoted 5 lines

-@depends on patch@ constant C; @@
+@depends on patch@
+expression E;
+@@

Quoted 7 lines

-- msecs_to_jiffies(C * MSEC_PER_SEC)
-+ secs_to_jiffies(C)
+-msecs_to_jiffies
++secs_to_jiffies
+ (E
+- * \( 1000 \| MSEC_PER_SEC \)
+ )

1. I do not see a need to keep an SmPL rule for the handling of constants (or literals) after the suggested extension for expressions.

2. I find it nice that you indicate an attempt to make the shown SmPL code a bit more succinct.
Unfortunately, further constraints should be taken better into account for the current handling of isomorphisms (and corresponding SmPL disjunctions). Thus I would find an SmPL rule (like the following) more appropriate.

@adjustment@
expression e;
@@
-msecs_to_jiffies
+secs_to_jiffies
(
(
-e * 1000
|
-e * MSEC_PER_SEC
)
+e
)

3. It seems that you would like to support only a single operation mode so far. This system aspect can trigger further software development challenges.

Regards,
Markus

#3 lore raw

Re: [PATCH 01/16] coccinelle: misc: secs_to_jiffies: Patch expressions too

Quoted 26 lines · Markus Elfring
Quoted 2 lines

Teach the script to suggest conversions for timeout patterns where the arguments to msecs_to_jiffies() are expressions as well.

I propose to take another look at implementation details for such a script variant according to the semantic patch language.

…

Quoted 4 lines

+++ b/scripts/coccinelle/misc/secs_to_jiffies.cocci

scripts/coccinelle/misc/secs_to_jiffies.cocci +0 -0
@@ -11,12 +11,22 @@
 
 virtual patch

…

Quoted 5 lines

-@depends on patch@ constant C; @@
+@depends on patch@
+expression E;
+@@

Quoted 7 lines

-- msecs_to_jiffies(C * MSEC_PER_SEC)
-+ secs_to_jiffies(C)
+-msecs_to_jiffies
++secs_to_jiffies
+ (E
+- * \( 1000 \| MSEC_PER_SEC \)
+ )

Quoted 2 lines

1. I do not see a need to keep an SmPL rule for the handling of constants (or literals) after the suggested extension for expressions.

Can you explain why? Would the expression rule also address the cases where it's a constant or literal?

Quoted 6 lines

2. I find it nice that you indicate an attempt to make the shown SmPL code a bit more succinct.
Unfortunately, further constraints should be taken better into account for the current handling of isomorphisms (and corresponding SmPL disjunctions). Thus I would find an SmPL rule (like the following) more appropriate.

Sorry, I couldn't follow your sentence construction or reasoning here. I don't see how my patch is deficient, or different from your suggestion below, especially given that it follows your feedback from part 1:
https://lore.kernel.org/all/[email protected]/

Can you point out specifically what SmPL isomorphisms or disjunctions are broken with the patch in its current state?

Thanks,
Easwar

#4 lore raw

Re: [01/16] coccinelle: misc: secs_to_jiffies: Patch expressions too

Quoted 19 lines
Quoted 19 lines

…

Quoted 4 lines

+++ b/scripts/coccinelle/misc/secs_to_jiffies.cocci

scripts/coccinelle/misc/secs_to_jiffies.cocci +0 -0
@@ -11,12 +11,22 @@
 
 virtual patch

…

Quoted 12 lines

-@depends on patch@ constant C; @@
+@depends on patch@
+expression E;
+@@

-- msecs_to_jiffies(C * MSEC_PER_SEC)
-+ secs_to_jiffies(C)
+-msecs_to_jiffies
++secs_to_jiffies
+ (E
+- * \( 1000 \| MSEC_PER_SEC \)
+ )

Quoted 5 lines
Quoted 2 lines

1. I do not see a need to keep an SmPL rule for the handling of constants (or literals) after the suggested extension for expressions.

Can you explain why? Would the expression rule also address the cases where it's a constant or literal?

Probably, yes.

Quoted 11 lines
Quoted 6 lines

2. I find it nice that you indicate an attempt to make the shown SmPL code a bit more succinct.
Unfortunately, further constraints should be taken better into account for the current handling of isomorphisms (and corresponding SmPL disjunctions). Thus I would find an SmPL rule (like the following) more appropriate.

Sorry, I couldn't follow your sentence construction or reasoning here. I don't see how my patch is deficient, or different from your suggestion below, especially given that it follows your feedback from part 1:
https://lore.kernel.org/all/[email protected]/

I tend also to present possibilities for succinct SmPL code. Unfortunately, software dependencies can trigger corresponding target conflicts.

Quoted 2 lines

Can you point out specifically what SmPL isomorphisms or disjunctions are broken with the patch in its current state?

Please take another look at related information sources.
Would you like to achieve any benefits from commutativity (for multiplications)?
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/bd08cad3f802229dc629a13eefef2018c620e905/standard.iso#L241
https://github.com/coccinelle/coccinelle/blob/cca22217d1b4316224e80a18d0b08dd351234497/standard.iso#L241

Regards,
Markus

#5 lore raw

Re: [01/16] coccinelle: misc: secs_to_jiffies: Patch expressions too

Quoted 2 lines

I tend also to present possibilities for succinct SmPL code. Unfortunately, software dependencies can trigger corresponding target conflicts.

@adjustment@
expression e;
@@
-msecs_to_jiffies
+secs_to_jiffies
(
(
-e * 1000
|
-e * MSEC_PER_SEC
)
+e
)

A command (like the following) can indicate how isomorphisms are applied for the transformation of some data into SmPL disjunctions.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/bd08cad3f802229dc629a13eefef2018c620e905/standard.iso#L252-257

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci suggestion3_for_Easwar_Hariharan-20250128.cocci …
@adjustment@
expression e;
@@

(
-msecs_to_jiffies

Quoted 1 line
Quoted 1 line
Quoted 1 line

secs_to_jiffies

(-e -* -1000
<<< e
)
|
-msecs_to_jiffies

Quoted 1 line
Quoted 1 line
Quoted 1 line

secs_to_jiffies

(-1000 -* -e
<<< e
)
|
-msecs_to_jiffies

Quoted 1 line
Quoted 1 line
Quoted 1 line

secs_to_jiffies

(-e -* -MSEC_PER_SEC
<<< e
)
|
-msecs_to_jiffies

Quoted 1 line
Quoted 1 line
Quoted 1 line

secs_to_jiffies

(-MSEC_PER_SEC -* -e
<<< e
)
)

Grep query
msecs_to_jiffies

I find parts of such a data representation improvable.
I would usually expect here that parentheses for the selection of call parameters will not appear in the first text column
(so that confusion will be avoided for the usage of delimiters according to SmPL disjunctions).

The isomorphism specifications represent also a software development status. It seems that they do not contain direct support for SmPL disjunctions so far (as an explicit entity).

The identifier “HZ” is used by the referenced macro.
https://elixir.bootlin.com/linux/v6.13/source/include/linux/jiffies.h#L530-L540
https://lore.kernel.org/linux-kernel/173831299312.31546.8797889985487965830.tip-bot2@tip-bot2/

Is there a need to take further (preprocessor symbol) variations better into account?

How do you think about the handling of multiplication factors within bigger expressions (and not only at the beginning or end of a term)?

Would you be looking for further restrictions on expression combinations?

Regards,
Markus

#6 lore raw

Re: [PATCH 01/16] coccinelle: misc: secs_to_jiffies: Patch expressions too

In reply to Easwar Hariharan
Quoted 2 lines

Teach the script to suggest conversions for timeout patterns where the arguments to msecs_to_jiffies() are expressions as well.

Does anything hinder to benefit any more from a source code analysis approach (like the following by the extended means of the semantic patch language)?

// SPDX-License-Identifier: GPL-2.0
/// Simplify statements by using a known wrapper macro. /// Replace selected msecs_to_jiffies() calls by secs_to_jiffies(). //
// Keywords: wrapper macro conversion secs seconds jiffies // Confidence: High
// Options: --no-includes --include-headers

virtual context, patch, report, org

@depends on context@
expression e;
@@
*msecs_to_jiffies
(
(e * 1000
|e * MSEC_PER_SEC
)
)

@depends on patch@
expression e;
@@
-msecs_to_jiffies
+secs_to_jiffies
(
(
-e * 1000
|
-e * MSEC_PER_SEC
)
+e
)

@x depends on org || report@
expression e;
position p;
@@
msecs_to_jiffies@p
(
(e * 1000
|e * MSEC_PER_SEC
)
)

@script:python depends on org@
p << x.p;
@@
coccilib.org.print_todo(p[0], "WARNING: opportunity for secs_to_jiffies()")

@script:python depends on report@
p << x.p;
@@
coccilib.report.print_report(p[0], "WARNING: opportunity for secs_to_jiffies()")

Regards,
Markus

#7 lore raw

Re: [PATCH 01/16] coccinelle: misc: secs_to_jiffies: Patch expressions too

Quoted 6 lines · Markus Elfring
Quoted 2 lines

Teach the script to suggest conversions for timeout patterns where the arguments to msecs_to_jiffies() are expressions as well.

Does anything hinder to benefit any more from a source code analysis approach (like the following by the extended means of the semantic patch language)?

Thank you, this is much more useful feedback, specifically due to the suggested patch below. I did intend to learn about the other modes and progressively upgrade secs_to_jiffies.cocci with them in the future once the existing instances were resolved, to help with future code submissions. The patch below will be super helpful in that.

As it stands, I'll fix up the current rules in v2 following your suggestion to keep the multiplication in each line to allow Coccinelle to use the commutativity properties and find more instances.

I'll refrain from implementing the report mode until current instances have been fixed because of the issue we have already seen[1] with CI builds being broken. I would not want to break a strict CI build that is looking for coccicheck REPORT to return 0 results.

[1]:
https://lore.kernel.org/all/[email protected]/

<snip>

Thanks,
Easwar (he/him)

#8 lore raw

Re: [01/16] coccinelle: misc: secs_to_jiffies: Patch expressions too

Quoted 3 lines

As it stands, I'll fix up the current rules in v2 following your suggestion to keep the multiplication in each line to allow Coccinelle to use the commutativity properties and find more instances.

Corresponding software development challenges can eventually be clarified further.

Quoted 4 lines

I'll refrain from implementing the report mode until current instances have been fixed because of the issue we have already seen[1] with CI builds being broken. I would not want to break a strict CI build that is looking for coccicheck REPORT to return 0 results.

You got into the mood to test support for an information in the software documentation.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/dev-tools/coccinelle.rst?h=v6.13#n92
“…
Note that not all semantic patches implement all modes.
…”

Regards,
Markus

#9 lore raw

PATCH 2/16 scsi: lpfc: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/scsi/lpfc/lpfc_init.c  |  4 ++--
 drivers/scsi/lpfc/lpfc_scsi.c  | 12 +++++-------
 drivers/scsi/lpfc/lpfc_sli.c   | 24 +++++++++---------------
 drivers/scsi/lpfc/lpfc_vport.c |  2 +-
 4 files changed, 17 insertions(+), 25 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +2 -2
index bcadf11414c8a41d6fc99d03586d55c26d0a6a0f..783ba9c6a81cdc560b8c901d383c3c4d55eedbc7 100644
@@ -3361,8 +3361,8 @@ lpfc_block_mgmt_io(struct lpfc_hba *phba, int mbx_action)
 		/* Determine how long we might wait for the active mailbox
 		 * command to be gracefully completed by firmware.
 		 */
-		timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
-				phba->sli.mbox_active) * 1000) + jiffies;
+		timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba,
+				phba->sli.mbox_active)) + jiffies;
 	}
 	spin_unlock_irqrestore(&phba->hbalock, iflag);
 
drivers/scsi/lpfc/lpfc_scsi.c +5 -7
index 055ed632c14df51376126a285df728269ca1da6c..f0158fc00f783239db615b0978b6785de064535f 100644
@@ -5645,9 +5645,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
 	 * cmd_flag is set to LPFC_DRIVER_ABORTED before we wait
 	 * for abort to complete.
 	 */
-	wait_event_timeout(waitq,
-			  (lpfc_cmd->pCmd != cmnd),
-			   msecs_to_jiffies(2*vport->cfg_devloss_tmo*1000));
+	wait_event_timeout(waitq, (lpfc_cmd->pCmd != cmnd),
+			   secs_to_jiffies(2*vport->cfg_devloss_tmo));
 
 	spin_lock(&lpfc_cmd->buf_lock);
 
@@ -5911,7 +5910,7 @@ lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct fc_rport *rport)
 	 * If target is not in a MAPPED state, delay until
 	 * target is rediscovered or devloss timeout expires.
 	 */
-	later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
+	later = secs_to_jiffies(2 * vport->cfg_devloss_tmo) + jiffies;
 	while (time_after(later, jiffies)) {
 		if (!pnode)
 			return FAILED;
@@ -5957,7 +5956,7 @@ lpfc_reset_flush_io_context(struct lpfc_vport *vport, uint16_t tgt_id,
 		lpfc_sli_abort_taskmgmt(vport,
 					&phba->sli.sli3_ring[LPFC_FCP_RING],
 					tgt_id, lun_id, context);
-	later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
+	later = secs_to_jiffies(2 * vport->cfg_devloss_tmo) + jiffies;
 	while (time_after(later, jiffies) && cnt) {
 		schedule_timeout_uninterruptible(msecs_to_jiffies(20));
 		cnt = lpfc_sli_sum_iocb(vport, tgt_id, lun_id, context);
@@ -6137,8 +6136,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
 			wait_event_timeout(waitq,
 					   !test_bit(NLP_WAIT_FOR_LOGO,
 						     &pnode->save_flags),
-					   msecs_to_jiffies(dev_loss_tmo *
-							    1000));
+					   secs_to_jiffies(dev_loss_tmo));
 
 			if (test_and_clear_bit(NLP_WAIT_FOR_LOGO,
 					       &pnode->save_flags))
drivers/scsi/lpfc/lpfc_sli.c +9 -15
index 3fd9723cd271c8a024b6f34e583668e973404e6f..3ccc444c018c51f7c78a8acdb9d12ead8697fbcb 100644
@@ -9504,8 +9504,7 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
 			goto out_not_finished;
 		}
 		/* timeout active mbox command */
-		timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox) *
-					   1000);
+		timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox));
 		mod_timer(&psli->mbox_tmo, jiffies + timeout);
 	}
 
@@ -9629,8 +9628,7 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
 						       drvr_flag);
 			goto out_not_finished;
 		}
-		timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox) *
-							1000) + jiffies;
+		timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox)) + jiffies;
 		i = 0;
 		/* Wait for command to complete */
 		while (((word0 & OWN_CHIP) == OWN_CHIP) ||
@@ -9756,9 +9754,8 @@ lpfc_sli4_async_mbox_block(struct lpfc_hba *phba)
 	 * command to be gracefully completed by firmware.
 	 */
 	if (phba->sli.mbox_active)
-		timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
-						phba->sli.mbox_active) *
-						1000) + jiffies;
+		timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba,
+						phba->sli.mbox_active)) + jiffies;
 	spin_unlock_irq(&phba->hbalock);
 
 	/* Make sure the mailbox is really active */
@@ -9881,8 +9878,7 @@ lpfc_sli4_wait_bmbx_ready(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 		}
 	}
 
-	timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, mboxq)
-				   * 1000) + jiffies;
+	timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba, mboxq)) + jiffies;
 
 	do {
 		bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr);
@@ -13159,7 +13155,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba,
 	retval = lpfc_sli_issue_iocb(phba, ring_number, piocb,
 				     SLI_IOCB_RET_IOCB);
 	if (retval == IOCB_SUCCESS) {
-		timeout_req = msecs_to_jiffies(timeout * 1000);
+		timeout_req = secs_to_jiffies(timeout);
 		timeleft = wait_event_timeout(done_q,
 				lpfc_chk_iocb_flg(phba, piocb, LPFC_IO_WAKE),
 				timeout_req);
@@ -13275,8 +13271,7 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq,
 	/* now issue the command */
 	retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
 	if (retval == MBX_BUSY || retval == MBX_SUCCESS) {
-		wait_for_completion_timeout(&mbox_done,
-					    msecs_to_jiffies(timeout * 1000));
+		wait_for_completion_timeout(&mbox_done, secs_to_jiffies(timeout));
 
 		spin_lock_irqsave(&phba->hbalock, flag);
 		pmboxq->ctx_u.mbox_wait = NULL;
@@ -13336,9 +13331,8 @@ lpfc_sli_mbox_sys_shutdown(struct lpfc_hba *phba, int mbx_action)
 		 * command to be gracefully completed by firmware.
 		 */
 		if (phba->sli.mbox_active)
-			timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
-						phba->sli.mbox_active) *
-						1000) + jiffies;
+			timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba,
+						phba->sli.mbox_active)) + jiffies;
 		spin_unlock_irq(&phba->hbalock);
 
 		/* Enable softirqs again, done with phba->hbalock */
drivers/scsi/lpfc/lpfc_vport.c +1 -1
index 3d70cc5175730b31eeaf46c89d65c0dc09367d44..cc56a73343195a263c307fab6870a0012899060a 100644
@@ -246,7 +246,7 @@ static void lpfc_discovery_wait(struct lpfc_vport *vport)
 	 * fabric RA_TOV value and dev_loss tmo.  The driver's
 	 * devloss_tmo is 10 giving this loop a 3x multiplier minimally.
 	 */
-	wait_time_max = msecs_to_jiffies(((phba->fc_ratov * 3) + 3) * 1000);
+	wait_time_max = secs_to_jiffies((phba->fc_ratov * 3) + 3);
 	wait_time_max += jiffies;
 	start_time = jiffies;
 	while (time_before(jiffies, wait_time_max)) {
Signature · 1 line
2.43.0
#10 lore raw

PATCH 3/16 accel/habanalabs: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/accel/habanalabs/common/command_submission.c | 2 +-
 drivers/accel/habanalabs/common/debugfs.c            | 2 +-
 drivers/accel/habanalabs/common/device.c             | 2 +-
 drivers/accel/habanalabs/common/habanalabs_drv.c     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/accel/habanalabs/common/command_submission.c +1 -1
index 59823e3c3bf7a4fafc0b112fd7b4b2209149973c..dee487724918554c24c3e78df4e8715dd1c73acd 100644
@@ -2586,7 +2586,7 @@ int hl_cs_ioctl(struct drm_device *ddev, void *data, struct drm_file *file_priv)
 		cs_seq = args->in.seq;
 
 	timeout = flags & HL_CS_FLAGS_CUSTOM_TIMEOUT
-			? msecs_to_jiffies(args->in.timeout * 1000)
+			? secs_to_jiffies(args->in.timeout)
 			: hpriv->hdev->timeout_jiffies;
 
 	switch (cs_type) {
drivers/accel/habanalabs/common/debugfs.c +1 -1
index ca7677293a55822f703a3a1cbf947c4c44fdc569..4b391807e5f2e2a2570a38b9dfdf6be4299dbfb6 100644
@@ -1403,7 +1403,7 @@ static ssize_t hl_timeout_locked_write(struct file *f, const char __user *buf,
 		return rc;
 
 	if (value)
-		hdev->timeout_jiffies = msecs_to_jiffies(value * 1000);
+		hdev->timeout_jiffies = secs_to_jiffies(value);
 	else
 		hdev->timeout_jiffies = MAX_SCHEDULE_TIMEOUT;
 
drivers/accel/habanalabs/common/device.c +1 -1
index 30277ae410d4b742ffb7bddc35498564ff96fe62..68eebed3b050f72f81e55b86da869b56b4cdeadf 100644
@@ -2091,7 +2091,7 @@ int hl_device_cond_reset(struct hl_device *hdev, u32 flags, u64 event_mask)
 	dev_dbg(hdev->dev, "Device is going to be hard-reset in %u sec unless being released\n",
 		hdev->device_release_watchdog_timeout_sec);
 	schedule_delayed_work(&hdev->device_release_watchdog_work.reset_work,
-				msecs_to_jiffies(hdev->device_release_watchdog_timeout_sec * 1000));
+				secs_to_jiffies(hdev->device_release_watchdog_timeout_sec));
 	hdev->reset_info.watchdog_active = 1;
 out:
 	spin_unlock(&hdev->reset_info.lock);
drivers/accel/habanalabs/common/habanalabs_drv.c +1 -1
index 596c52e8aa266bf48e2be45e719adb202604577b..0035748f3228246da235f227b2cf3939d64af350 100644
@@ -386,7 +386,7 @@ static int fixup_device_params(struct hl_device *hdev)
 	hdev->fw_comms_poll_interval_usec = HL_FW_STATUS_POLL_INTERVAL_USEC;
 
 	if (tmp_timeout)
-		hdev->timeout_jiffies = msecs_to_jiffies(tmp_timeout * MSEC_PER_SEC);
+		hdev->timeout_jiffies = secs_to_jiffies(tmp_timeout);
 	else
 		hdev->timeout_jiffies = MAX_SCHEDULE_TIMEOUT;
 
Signature · 1 line
2.43.0
#11 lore raw

PATCH 4/16 ALSA: ac97: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 sound/pci/ac97/ac97_codec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/pci/ac97/ac97_codec.c +1 -2
index 6e710dce5c6068ec20c2da751b6f5372ad1df211..88ac37739b7653f69af430dd0163f5ab4ddf0d0c 100644
@@ -2461,8 +2461,7 @@ int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup)
 		 * (for avoiding loud click noises for many (OSS) apps
 		 *  that open/close frequently)
 		 */
-		schedule_delayed_work(&ac97->power_work,
-				      msecs_to_jiffies(power_save * 1000));
+		schedule_delayed_work(&ac97->power_work, secs_to_jiffies(power_save));
 	else {
 		cancel_delayed_work(&ac97->power_work);
 		update_power_regs(ac97);
Signature · 1 line
2.43.0
Acked-by on v1 4/16
#12 lore raw

Re: [PATCH 04/16] ALSA: ac97: convert timeouts to secs_to_jiffies()

Quoted 18 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

Quoted 1 line

thanks,

Takashi

Quoted 22 lines
---
 sound/pci/ac97/ac97_codec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/pci/ac97/ac97_codec.c +1 -2
index 6e710dce5c6068ec20c2da751b6f5372ad1df211..88ac37739b7653f69af430dd0163f5ab4ddf0d0c 100644
@@ -2461,8 +2461,7 @@ int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup)
 		 * (for avoiding loud click noises for many (OSS) apps
 		 *  that open/close frequently)
 		 */
-		schedule_delayed_work(&ac97->power_work,
-				      msecs_to_jiffies(power_save * 1000));
+		schedule_delayed_work(&ac97->power_work, secs_to_jiffies(power_save));
 	else {
 		cancel_delayed_work(&ac97->power_work);
 		update_power_regs(ac97);
Signature · 2 lines
-- 
2.43.0
#13 lore raw

PATCH 5/16 btrfs: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 fs/btrfs/disk-io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +3 -3
index f09db62e61a1b0e2b8b319f9605883fe0c86cf9d..ed2772d2791997b1e1d15e71d01d818b325f5173 100644
@@ -1568,7 +1568,7 @@ static int transaction_kthread(void *arg)
 
 	do {
 		cannot_commit = false;
-		delay = msecs_to_jiffies(fs_info->commit_interval * 1000);
+		delay = secs_to_jiffies(fs_info->commit_interval);
 		mutex_lock(&fs_info->transaction_kthread_mutex);
 
 		spin_lock(&fs_info->trans_lock);
@@ -1583,9 +1583,9 @@ static int transaction_kthread(void *arg)
 		    cur->state < TRANS_STATE_COMMIT_PREP &&
 		    delta < fs_info->commit_interval) {
 			spin_unlock(&fs_info->trans_lock);
-			delay -= msecs_to_jiffies((delta - 1) * 1000);
+			delay -= secs_to_jiffies(delta - 1);
 			delay = min(delay,
-				    msecs_to_jiffies(fs_info->commit_interval * 1000));
+				    secs_to_jiffies(fs_info->commit_interval));
 			goto sleep;
 		}
 		transid = cur->transid;
Signature · 1 line
2.43.0
Acked-by on v1 5/16
#14 lore raw

Re: [PATCH 05/16] btrfs: convert timeouts to secs_to_jiffies()

Quoted 17 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

Quoted 1 line
#15 lore raw

PATCH 6/16 rbd: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/block/rbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/rbd.c +3 -3
index 5b393e4a1ddfc4eba1a821b9bf8e04585bdf2190..c2389500076643b8e1e9caa75431693d12e59a5e 100644
@@ -4162,7 +4162,7 @@ static void rbd_acquire_lock(struct work_struct *work)
 		dout("%s rbd_dev %p requeuing lock_dwork\n", __func__,
 		     rbd_dev);
 		mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork,
-		    msecs_to_jiffies(2 * RBD_NOTIFY_TIMEOUT * MSEC_PER_SEC));
+		    secs_to_jiffies(2 * RBD_NOTIFY_TIMEOUT));
 	}
 }
 
@@ -6283,9 +6283,9 @@ static int rbd_parse_param(struct fs_parameter *param,
 		break;
 	case Opt_lock_timeout:
 		/* 0 is "wait forever" (i.e. infinite timeout) */
-		if (result.uint_32 > INT_MAX / 1000)
+		if (result.uint_32 > INT_MAX)
 			goto out_of_range;
-		opt->lock_timeout = msecs_to_jiffies(result.uint_32 * 1000);
+		opt->lock_timeout = secs_to_jiffies(result.uint_32);
 		break;
 	case Opt_pool_ns:
 		kfree(pctx->spec->pool_ns);
Signature · 1 line
2.43.0
#16 lore raw

Re: [PATCH 06/16] rbd: convert timeouts to secs_to_jiffies()

Quoted 22 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/block/rbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

<snip>

drivers/block/rbd.c static int rbd_parse_param(struct fs_parameter *param, · line 6291

Quoted 13 lines
drivers/block/rbd.c +2 -2
@@ -6283,9 +6283,9 @@ static int rbd_parse_param(struct fs_parameter *param,
 		break;
 	case Opt_lock_timeout:
 		/* 0 is "wait forever" (i.e. infinite timeout) */
-		if (result.uint_32 > INT_MAX / 1000)
+		if (result.uint_32 > INT_MAX)
 			goto out_of_range;
-		opt->lock_timeout = msecs_to_jiffies(result.uint_32 * 1000);
+		opt->lock_timeout = secs_to_jiffies(result.uint_32);
 		break;
 	case Opt_pool_ns:
 		kfree(pctx->spec->pool_ns);

Hi Ilya, Dongsheng, Jens, others,

Could you please review this hunk and confirm the correct range check here? I figure this is here because of the multiplier to msecs_to_jiffies() and therefore unneeded after the conversion. If so, I noticed patch 07 has similar range checks that I neglected to fix and can do in a v2.

Thanks,
Easwar (he/him)

maintainer
#17 lore raw

Re: [PATCH 06/16] rbd: convert timeouts to secs_to_jiffies()

Quoted 43 lines · Easwar Hariharan
Quoted 22 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/block/rbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

<snip>

drivers/block/rbd.c static int rbd_parse_param(struct fs_parameter *param, · line 6291

Quoted 13 lines
drivers/block/rbd.c +2 -2
@@ -6283,9 +6283,9 @@ static int rbd_parse_param(struct fs_parameter *param,
              break;
      case Opt_lock_timeout:
              /* 0 is "wait forever" (i.e. infinite timeout) */
-             if (result.uint_32 > INT_MAX / 1000)
+             if (result.uint_32 > INT_MAX)
                      goto out_of_range;
-             opt->lock_timeout = msecs_to_jiffies(result.uint_32 * 1000);
+             opt->lock_timeout = secs_to_jiffies(result.uint_32);
              break;
      case Opt_pool_ns:
              kfree(pctx->spec->pool_ns);

Hi Ilya, Dongsheng, Jens, others,

Quoted 3 lines

Could you please review this hunk and confirm the correct range check here? I figure this is here because of the multiplier to msecs_to_jiffies() and therefore unneeded after the conversion. If so, I

Hi Easwar,

I'm not sure why INT_MAX / 1000 was used for an option which is defined as fsparam_u32 and accessed through result.uint_32, but yes, this check appears to be unneeded after the conversion to me.

Quoted 2 lines

noticed patch 07 has similar range checks that I neglected to fix and can do in a v2.

Go ahead but note that two of them also reject 0 -- that part needs to stay ;)

Thanks,

Ilya

#18 lore raw

PATCH 7/16 libceph: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 net/ceph/ceph_common.c | 10 ++++------
 net/ceph/osd_client.c  |  3 +--
 2 files changed, 5 insertions(+), 8 deletions(-)
net/ceph/ceph_common.c +4 -6
index 4c6441536d55b6323f4b9d93b5d4837cd4ec880c..0d1e303c0212cc9f70f7c54ca422b0b3ea01bf32 100644
@@ -529,27 +529,25 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
 		/* 0 isn't well defined right now, reject it */
 		if (result.uint_32 < 1 || result.uint_32 > INT_MAX / 1000)
 			goto out_of_range;
-		opt->osd_keepalive_timeout =
-		    msecs_to_jiffies(result.uint_32 * 1000);
+		opt->osd_keepalive_timeout = secs_to_jiffies(result.uint_32);
 		break;
 	case Opt_osd_idle_ttl:
 		/* 0 isn't well defined right now, reject it */
 		if (result.uint_32 < 1 || result.uint_32 > INT_MAX / 1000)
 			goto out_of_range;
-		opt->osd_idle_ttl = msecs_to_jiffies(result.uint_32 * 1000);
+		opt->osd_idle_ttl = secs_to_jiffies(result.uint_32);
 		break;
 	case Opt_mount_timeout:
 		/* 0 is "wait forever" (i.e. infinite timeout) */
 		if (result.uint_32 > INT_MAX / 1000)
 			goto out_of_range;
-		opt->mount_timeout = msecs_to_jiffies(result.uint_32 * 1000);
+		opt->mount_timeout = secs_to_jiffies(result.uint_32);
 		break;
 	case Opt_osd_request_timeout:
 		/* 0 is "wait forever" (i.e. infinite timeout) */
 		if (result.uint_32 > INT_MAX / 1000)
 			goto out_of_range;
-		opt->osd_request_timeout =
-		    msecs_to_jiffies(result.uint_32 * 1000);
+		opt->osd_request_timeout = secs_to_jiffies(result.uint_32);
 		break;
 
 	case Opt_share:
net/ceph/osd_client.c +1 -2
index b24afec241382b60d775dd12a6561fa23a7eca45..ba61a48b4388c2eceb5b7a299906e7f90191dd5d 100644
@@ -4989,8 +4989,7 @@ int ceph_osdc_notify(struct ceph_osd_client *osdc,
 	linger_submit(lreq);
 	ret = linger_reg_commit_wait(lreq);
 	if (!ret)
-		ret = linger_notify_finish_wait(lreq,
-				 msecs_to_jiffies(2 * timeout * MSEC_PER_SEC));
+		ret = linger_notify_finish_wait(lreq, secs_to_jiffies(2 * timeout));
 	else
 		dout("lreq %p failed to initiate notify %d\n", lreq, ret);
 
Signature · 1 line
2.43.0
#19 lore raw

PATCH 8/16 libata: zpodd: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/ata/libata-zpodd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/ata/libata-zpodd.c +1 -2
index 4b83b517caec66c82b126666f6dffd09729bf845..799531218ea2d5cc1b7e693a2b2aff7f376f7d76 100644
@@ -160,8 +160,7 @@ void zpodd_on_suspend(struct ata_device *dev)
 		return;
 	}
 
-	expires = zpodd->last_ready +
-		  msecs_to_jiffies(zpodd_poweroff_delay * 1000);
+	expires = zpodd->last_ready + secs_to_jiffies(zpodd_poweroff_delay);
 	if (time_before(jiffies, expires))
 		return;
 
Signature · 1 line
2.43.0
maintainer Acked-by on v1 8/16
#20 lore raw

Re: [PATCH 08/16] libata: zpodd: convert timeouts to secs_to_jiffies()

Quoted 17 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

Quoted 1 line

The subject line should be:

ata: libata-zpodd: convert timeouts to secs_to_jiffies()

Other than that, looks good to me.

Quoted 19 lines
---
 drivers/ata/libata-zpodd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/ata/libata-zpodd.c +1 -2
index 4b83b517caec66c82b126666f6dffd09729bf845..799531218ea2d5cc1b7e693a2b2aff7f376f7d76 100644
@@ -160,8 +160,7 @@ void zpodd_on_suspend(struct ata_device *dev)
 		return;
 	}
 
-	expires = zpodd->last_ready +
-		  msecs_to_jiffies(zpodd_poweroff_delay * 1000);
+	expires = zpodd->last_ready + secs_to_jiffies(zpodd_poweroff_delay);
 	if (time_before(jiffies, expires))
 		return;
 
Signature · 2 lines
Damien Le Moal
Western Digital Research
#21 lore raw

Re: [PATCH 08/16] libata: zpodd: convert timeouts to secs_to_jiffies()

Quoted 22 lines · Damien Le Moal
Quoted 17 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

Quoted 1 line

The subject line should be:

Quoted 6 lines

ata: libata-zpodd: convert timeouts to secs_to_jiffies()

Other than that, looks good to me.

Thanks for the review and ack! I'll fix the subject line in v2.

- Easwar (he/him)

#22 lore raw

PATCH 9/16 xfs: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 fs/xfs/xfs_icache.c | 2 +-
 fs/xfs/xfs_sysfs.c  | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)
fs/xfs/xfs_icache.c +1 -1
index 7b6c026d01a1fc020a41a678964cdbf7a8113323..7a1feb8dc21f6f71d04f88de866e5a95925e0c54 100644
@@ -230,7 +230,7 @@ xfs_blockgc_queue(
 	rcu_read_lock();
 	if (radix_tree_tagged(&pag->pag_ici_root, XFS_ICI_BLOCKGC_TAG))
 		queue_delayed_work(mp->m_blockgc_wq, &pag->pag_blockgc_work,
-				   msecs_to_jiffies(xfs_blockgc_secs * 1000));
+				   secs_to_jiffies(xfs_blockgc_secs));
 	rcu_read_unlock();
 }
 
fs/xfs/xfs_sysfs.c +3 -4
index 60cb5318fdae3cc246236fd988b4749df57f8bfc..eed0f28afe97ead762a9539e45f292db7d0d0c4a 100644
@@ -568,8 +568,8 @@ retry_timeout_seconds_store(
 	if (val == -1)
 		cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
 	else {
-		cfg->retry_timeout = msecs_to_jiffies(val * MSEC_PER_SEC);
-		ASSERT(msecs_to_jiffies(val * MSEC_PER_SEC) < LONG_MAX);
+		cfg->retry_timeout = secs_to_jiffies(val);
+		ASSERT(secs_to_jiffies(val) < LONG_MAX);
 	}
 	return count;
 }
@@ -686,8 +686,7 @@ xfs_error_sysfs_init_class(
 		if (init[i].retry_timeout == XFS_ERR_RETRY_FOREVER)
 			cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
 		else
-			cfg->retry_timeout = msecs_to_jiffies(
-					init[i].retry_timeout * MSEC_PER_SEC);
+			cfg->retry_timeout = secs_to_jiffies(init[i].retry_timeout);
 	}
 	return 0;
 
Signature · 1 line
2.43.0
Acked-by on v1 9/16
#23 lore raw

Re: [PATCH 09/16] xfs: convert timeouts to secs_to_jiffies()

Quoted 17 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

Quoted 1 line

Looks good to me,

--D

Quoted 48 lines
---
 fs/xfs/xfs_icache.c | 2 +-
 fs/xfs/xfs_sysfs.c  | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)
fs/xfs/xfs_icache.c +1 -1
index 7b6c026d01a1fc020a41a678964cdbf7a8113323..7a1feb8dc21f6f71d04f88de866e5a95925e0c54 100644
@@ -230,7 +230,7 @@ xfs_blockgc_queue(
 	rcu_read_lock();
 	if (radix_tree_tagged(&pag->pag_ici_root, XFS_ICI_BLOCKGC_TAG))
 		queue_delayed_work(mp->m_blockgc_wq, &pag->pag_blockgc_work,
-				   msecs_to_jiffies(xfs_blockgc_secs * 1000));
+				   secs_to_jiffies(xfs_blockgc_secs));
 	rcu_read_unlock();
 }
 
fs/xfs/xfs_sysfs.c +3 -4
index 60cb5318fdae3cc246236fd988b4749df57f8bfc..eed0f28afe97ead762a9539e45f292db7d0d0c4a 100644
@@ -568,8 +568,8 @@ retry_timeout_seconds_store(
 	if (val == -1)
 		cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
 	else {
-		cfg->retry_timeout = msecs_to_jiffies(val * MSEC_PER_SEC);
-		ASSERT(msecs_to_jiffies(val * MSEC_PER_SEC) < LONG_MAX);
+		cfg->retry_timeout = secs_to_jiffies(val);
+		ASSERT(secs_to_jiffies(val) < LONG_MAX);
 	}
 	return count;
 }
@@ -686,8 +686,7 @@ xfs_error_sysfs_init_class(
 		if (init[i].retry_timeout == XFS_ERR_RETRY_FOREVER)
 			cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
 		else
-			cfg->retry_timeout = msecs_to_jiffies(
-					init[i].retry_timeout * MSEC_PER_SEC);
+			cfg->retry_timeout = secs_to_jiffies(init[i].retry_timeout);
 	}
 	return 0;
 
Signature · 2 lines
-- 
2.43.0
#24 lore raw

Re: [PATCH 09/16] xfs: convert timeouts to secs_to_jiffies()

In reply to Easwar Hariharan

fs/xfs/xfs_sysfs.c xfs_error_sysfs_init_class( · line 689

Quoted 4 lines · Easwar Hariharan
fs/xfs/xfs_sysfs.c +1 -2
 		else
-			cfg->retry_timeout = msecs_to_jiffies(
-					init[i].retry_timeout * MSEC_PER_SEC);
+			cfg->retry_timeout = secs_to_jiffies(init[i].retry_timeout);

This messes up the formatting by introducing an overly long line.

Otherwise the change looks fine.

#25 lore raw

Re: [PATCH 09/16] xfs: convert timeouts to secs_to_jiffies()

Quoted 9 lines · Christoph Hellwig

fs/xfs/xfs_sysfs.c xfs_error_sysfs_init_class( · line 689

Quoted 4 lines · Easwar Hariharan
fs/xfs/xfs_sysfs.c +1 -2
 		else
-			cfg->retry_timeout = msecs_to_jiffies(
-					init[i].retry_timeout * MSEC_PER_SEC);
+			cfg->retry_timeout = secs_to_jiffies(init[i].retry_timeout);

This messes up the formatting by introducing an overly long line.

Otherwise the change looks fine.

I'll fix this in v2. Thanks for the review!

- Easwar (he/him)

#26 lore raw

Re: [PATCH 09/16] xfs: convert timeouts to secs_to_jiffies()

Quoted 9 lines · Easwar Hariharan
Quoted 8 lines · Christoph Hellwig

fs/xfs/xfs_sysfs.c xfs_error_sysfs_init_class( · line 689

Quoted 4 lines · Easwar Hariharan
fs/xfs/xfs_sysfs.c +1 -2
 		else
-			cfg->retry_timeout = msecs_to_jiffies(
-					init[i].retry_timeout * MSEC_PER_SEC);
+			cfg->retry_timeout = secs_to_jiffies(init[i].retry_timeout);

This messes up the formatting by introducing an overly long line.

Quoted 5 lines
Quoted 1 line

Otherwise the change looks fine.

I'll fix this in v2. Thanks for the review!

- Easwar (he/him)

Andrew seems to have fixed it up in his copy, so I'll skip this change in v2. Thanks Andrew!

- Easwar

maintainer Reviewed-by on v1 9/16
#27 lore raw

Re: [PATCH 09/16] xfs: convert timeouts to secs_to_jiffies()

In reply to Easwar Hariharan
Quoted 52 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 fs/xfs/xfs_icache.c | 2 +-
 fs/xfs/xfs_sysfs.c  | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)
fs/xfs/xfs_icache.c +1 -1
index 7b6c026d01a1fc020a41a678964cdbf7a8113323..7a1feb8dc21f6f71d04f88de866e5a95925e0c54 100644
@@ -230,7 +230,7 @@ xfs_blockgc_queue(
 	rcu_read_lock();
 	if (radix_tree_tagged(&pag->pag_ici_root, XFS_ICI_BLOCKGC_TAG))
 		queue_delayed_work(mp->m_blockgc_wq, &pag->pag_blockgc_work,
-				   msecs_to_jiffies(xfs_blockgc_secs * 1000));
+				   secs_to_jiffies(xfs_blockgc_secs));
 	rcu_read_unlock();
 }
 
fs/xfs/xfs_sysfs.c +2 -2
index 60cb5318fdae3cc246236fd988b4749df57f8bfc..eed0f28afe97ead762a9539e45f292db7d0d0c4a 100644
@@ -568,8 +568,8 @@ retry_timeout_seconds_store(
 	if (val == -1)
 		cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
 	else {
-		cfg->retry_timeout = msecs_to_jiffies(val * MSEC_PER_SEC);
-		ASSERT(msecs_to_jiffies(val * MSEC_PER_SEC) < LONG_MAX);
+		cfg->retry_timeout = secs_to_jiffies(val);
+		ASSERT(secs_to_jiffies(val) < LONG_MAX);
 	}
 	return count;
 }

fs/xfs/xfs_sysfs.c xfs_error_sysfs_init_class( · line 691

Quoted 8 lines
fs/xfs/xfs_sysfs.c +1 -2
@@ -686,8 +686,7 @@ xfs_error_sysfs_init_class(
 		if (init[i].retry_timeout == XFS_ERR_RETRY_FOREVER)
 			cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
 		else
-			cfg->retry_timeout = msecs_to_jiffies(
-					init[i].retry_timeout * MSEC_PER_SEC);
+			cfg->retry_timeout = secs_to_jiffies(init[i].retry_timeout);
 	}
 	return 0;

Looks fine to me.

Quoted 6 lines
fs/xfs/xfs_sysfs.c +0 -1
--

2.43.0

#28 lore raw

Re: [PATCH 09/16] xfs: convert timeouts to secs_to_jiffies()

In reply to Easwar Hariharan
kernel test robot noticed the following build warnings:

Hi Easwar,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 9a87ce288fe30f268b3a598422fe76af9bb2c2d2]

url:    https://github.com/intel-lab-lkp/linux/commits/Easwar-Hariharan/coccinelle-misc-secs_to_jiffies-Patch-expressions-too/20250129-022410
base:   9a87ce288fe30f268b3a598422fe76af9bb2c2d2
patch link:    https://lore.kernel.org/r/20250128-converge-secs-to-jiffies-part-two-v1-9-9a6ecf0b2308%40linux.microsoft.com
patch subject: [PATCH 09/16] xfs: convert timeouts to secs_to_jiffies()
config: x86_64-buildonly-randconfig-006-20250129 (https://download.01.org/0day-ci/archive/20250130/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250130/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> fs/xfs/xfs_sysfs.c:572:31: warning: result of comparison of constant 9223372036854775807 with expression of type 'int' is always true [-Wtautological-constant-out-of-range-compare]
     572 |                 ASSERT(secs_to_jiffies(val) < LONG_MAX);
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
   fs/xfs/xfs_linux.h:224:10: note: expanded from macro 'ASSERT'
     224 |         (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
         |          ~~~~~~~^~~~~
   include/linux/compiler.h:76:40: note: expanded from macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^

1 warning generated.

vim +/int +572 fs/xfs/xfs_sysfs.c

549
550 static ssize_t
551 retry_timeout_seconds_store(
552 struct kobject *kobject,
553 const char *buf,
554 size_t count)
555 {
556 struct xfs_error_cfg *cfg = to_error_cfg(kobject);
557 int ret;
558 int val;
559
560 ret = kstrtoint(buf, 0, &val);
561 if (ret)
562 return ret;
563
564 /* 1 day timeout maximum, -1 means infinite */
565 if (val < -1 || val > 86400)
566 return -EINVAL;
567
568 if (val == -1)
569 cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
570 else {
571 cfg->retry_timeout = secs_to_jiffies(val);

 > 572			ASSERT(secs_to_jiffies(val) < LONG_MAX);

573 }
574 return count;
575 }
576 XFS_SYSFS_ATTR_RW(retry_timeout_seconds);
577

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#29 lore raw

PATCH 10/16 power: supply: da9030: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/power/supply/da9030_battery.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/power/supply/da9030_battery.c +1 -2
index ac2e319e95179039279dacaed1744136f679fbac..d25279c260308b6c82acb2aabf44f3749f71b703 100644
@@ -502,8 +502,7 @@ static int da9030_battery_probe(struct platform_device *pdev)
 
 	/* 10 seconds between monitor runs unless platform defines other
 	   interval */
-	charger->interval = msecs_to_jiffies(
-		(pdata->batmon_interval ? : 10) * 1000);
+	charger->interval = secs_to_jiffies(pdata->batmon_interval ? : 10);
 
 	charger->charge_milliamp = pdata->charge_milliamp;
 	charger->charge_millivolt = pdata->charge_millivolt;
Signature · 1 line
2.43.0
#30 lore raw

PATCH 11/16 nvme: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/nvme/host/core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +2 -4
index 76b615d4d5b91e163e5a6e7baf451c959a2c3cab..87498215ede4bcaf48660b89c901075dfcfaf041 100644
@@ -4459,11 +4459,9 @@ static void nvme_fw_act_work(struct work_struct *work)
 	nvme_auth_stop(ctrl);
 
 	if (ctrl->mtfa)
-		fw_act_timeout = jiffies +
-				msecs_to_jiffies(ctrl->mtfa * 100);
+		fw_act_timeout = jiffies + msecs_to_jiffies(ctrl->mtfa * 100);
 	else
-		fw_act_timeout = jiffies +
-				msecs_to_jiffies(admin_timeout * 1000);
+		fw_act_timeout = jiffies + secs_to_jiffies(admin_timeout);
 
 	nvme_quiesce_io_queues(ctrl);
 	while (nvme_ctrl_pp_status(ctrl)) {
Signature · 1 line
2.43.0
maintainer Acked-by on v1 11/16
#31 lore raw

Re: [PATCH 11/16] nvme: convert timeouts to secs_to_jiffies()

Quoted 42 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/nvme/host/core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +2 -4
index 76b615d4d5b91e163e5a6e7baf451c959a2c3cab..87498215ede4bcaf48660b89c901075dfcfaf041 100644
@@ -4459,11 +4459,9 @@ static void nvme_fw_act_work(struct work_struct *work)
 	nvme_auth_stop(ctrl);
 
 	if (ctrl->mtfa)
-		fw_act_timeout = jiffies +
-				msecs_to_jiffies(ctrl->mtfa * 100);
+		fw_act_timeout = jiffies + msecs_to_jiffies(ctrl->mtfa * 100);
 	else
-		fw_act_timeout = jiffies +
-				msecs_to_jiffies(admin_timeout * 1000);
+		fw_act_timeout = jiffies + secs_to_jiffies(admin_timeout);
 
 	nvme_quiesce_io_queues(ctrl);
 	while (nvme_ctrl_pp_status(ctrl)) {
Signature · 1 line
-- 
#32 lore raw

PATCH 12/16 spi: spi-fsl-lpspi: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/spi/spi-fsl-lpspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-fsl-lpspi.c +1 -1
index 40f5c8fdba765a1334710a696966232a459316e6..5e381844523440c03b1d0bbe4a044f28fbfbc738 100644
@@ -572,7 +572,7 @@ static int fsl_lpspi_calculate_timeout(struct fsl_lpspi_data *fsl_lpspi,
 	timeout += 1;
 
 	/* Double calculated timeout */
-	return msecs_to_jiffies(2 * timeout * MSEC_PER_SEC);
+	return secs_to_jiffies(2 * timeout);
 }
 
 static int fsl_lpspi_dma_transfer(struct spi_controller *controller,
Signature · 1 line
2.43.0
maintainer Acked-by on v1 12/16
#33 lore raw

Re: [PATCH 12/16] spi: spi-fsl-lpspi: convert timeouts to secs_to_jiffies()

Quoted 3 lines · 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.

#34 lore raw

PATCH 13/16 spi: spi-imx: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/spi/spi-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-imx.c +1 -1
index eeb7d082c2472f954001045295b349bc2eb53197..832d6e9009ebe741779acd58c3a9450c231151bb 100644
@@ -1449,7 +1449,7 @@ static int spi_imx_calculate_timeout(struct spi_imx_data *spi_imx, int size)
 	timeout += 1;
 
 	/* Double calculated timeout */
-	return msecs_to_jiffies(2 * timeout * MSEC_PER_SEC);
+	return secs_to_jiffies(2 * timeout);
 }
 
 static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
Signature · 1 line
2.43.0
maintainer Acked-by on v1 13/16
#35 lore raw

Re: [PATCH 13/16] spi: spi-imx: convert timeouts to secs_to_jiffies()

Quoted 3 lines · 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.

#36 lore raw

PATCH 14/16 platform/x86/amd/pmf: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/platform/x86/amd/pmf/acpi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/amd/pmf/acpi.c +2 -1
index dd5780a1d06e1dc979fcff5bafd6729bc4937eab..6b7effe80b78b7389b320ee65fa5d2373f782a2f 100644
@@ -220,7 +220,8 @@ static void apmf_sbios_heartbeat_notify(struct work_struct *work)
 	if (!info)
 		return;
 
-	schedule_delayed_work(&dev->heart_beat, msecs_to_jiffies(dev->hb_interval * 1000));
+	schedule_delayed_work(&dev->heart_beat,
+			      secs_to_jiffies(dev->hb_interval));
 	kfree(info);
 }
 
Signature · 1 line
2.43.0
maintainer
#37 lore raw

Re: [PATCH 14/16] platform/x86/amd/pmf: convert timeouts to secs_to_jiffies()

Quoted 27 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/platform/x86/amd/pmf/acpi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/amd/pmf/acpi.c +0 -0
index dd5780a1d06e1dc979fcff5bafd6729bc4937eab..6b7effe80b78b7389b320ee65fa5d2373f782a2f 100644

drivers/platform/x86/amd/pmf/acpi.c static void apmf_sbios_heartbeat_notify(struct work_struct *work) · line 226

Quoted 8 lines
drivers/platform/x86/amd/pmf/acpi.c +2 -1
@@ -220,7 +220,8 @@ static void apmf_sbios_heartbeat_notify(struct work_struct *work)
 	if (!info)
 		return;
 
-	schedule_delayed_work(&dev->heart_beat, msecs_to_jiffies(dev->hb_interval * 1000));
+	schedule_delayed_work(&dev->heart_beat,
+			      secs_to_jiffies(dev->hb_interval));
 	kfree(info);
 }

Hi,

So you made the line shorter but still added the newline char for some reason even if the original didn't have one?? Please don't enforce 80 chars limit with patches like this.

Signature · 1 line
 i.
#38 lore raw

Re: [PATCH 14/16] platform/x86/amd/pmf: convert timeouts to secs_to_jiffies()

Quoted 40 lines · Ilpo Järvinen
Quoted 27 lines · 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;
@@

(quoted diff) +1 -1
-msecs_to_jiffies
+secs_to_jiffies

(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/platform/x86/amd/pmf/acpi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/amd/pmf/acpi.c +0 -0
index dd5780a1d06e1dc979fcff5bafd6729bc4937eab..6b7effe80b78b7389b320ee65fa5d2373f782a2f 100644

drivers/platform/x86/amd/pmf/acpi.c static void apmf_sbios_heartbeat_notify(struct work_struct *work) · line 226

Quoted 8 lines
drivers/platform/x86/amd/pmf/acpi.c +2 -1
@@ -220,7 +220,8 @@ static void apmf_sbios_heartbeat_notify(struct work_struct *work)
 	if (!info)
 		return;
 
-	schedule_delayed_work(&dev->heart_beat, msecs_to_jiffies(dev->hb_interval * 1000));
+	schedule_delayed_work(&dev->heart_beat,
+			      secs_to_jiffies(dev->hb_interval));
 	kfree(info);
 }

Hi,

Quoted 4 lines

So you made the line shorter but still added the newline char for some reason even if the original didn't have one?? Please don't enforce 80 chars limit with patches like this.

Sorry about that, I can fix that in v2.

Thanks for the review!

- Easwar (he/him)

#39 lore raw

PATCH 15/16 platform/x86: thinkpad_acpi: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/platform/x86/thinkpad_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/thinkpad_acpi.c +1 -1
index 1fcb0f99695a78d392ed000b0831eb4d45eff55f..500b497c3f375f463f014ed3f3361afc9d6f3329 100644
@@ -8505,7 +8505,7 @@ static void fan_watchdog_reset(void)
 	if (fan_watchdog_maxinterval > 0 &&
 	    tpacpi_lifecycle != TPACPI_LIFE_EXITING)
 		mod_delayed_work(tpacpi_wq, &fan_watchdog_task,
-			msecs_to_jiffies(fan_watchdog_maxinterval * 1000));
+			secs_to_jiffies(fan_watchdog_maxinterval));
 	else
 		cancel_delayed_work(&fan_watchdog_task);
 }
Signature · 1 line
2.43.0
#40 lore raw

PATCH 16/16 RDMA/bnxt_re: convert timeouts to secs_to_jiffies()

In reply to 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
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

---
 drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +1 -1
index 17e62f22683b14a3571188e25fe0df3cbf1d8360..b1a18c9cb7f6c248548bc38fcb98781a3030a1b6 100644
@@ -160,7 +160,7 @@ static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
 		wait_event_timeout(cmdq->waitq,
 				   !crsqe->is_in_used ||
 				   test_bit(ERR_DEVICE_DETACHED, &cmdq->flags),
-				   msecs_to_jiffies(rcfw->max_timeout * 1000));
+				   secs_to_jiffies(rcfw->max_timeout));
 
 		if (!crsqe->is_in_used)
 			return 0;
Signature · 1 line
2.43.0
#41 lore raw
In reply to Easwar Hariharan
Quoted 5 lines · On Tue, 28 Jan 2025 18:21:45 +0000 Easwar Hariharan…

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)

Quoted 8 lines

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.

Andrew has kindly agreed to take the series through mm.git modulo the patches maintainers want to pick through their own trees.

I added patches 2-16 to mm.git. If any of these later get merged into a subsystem tree, Stephen will tell us and I'll drop the mm.git copy.

#42 lore raw
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Tue, 28 Jan 2025 18:21:45 +0000 Easwar Hariharan…

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.

Quoted 5 lines
Quoted 2 lines

Andrew has kindly agreed to take the series through mm.git modulo the patches maintainers want to pick through their own trees.

I added patches 2-16 to mm.git. If any of these later get merged into a subsystem tree, Stephen will tell us and I'll drop the mm.git copy.

Hi Andrew, I don't see these in mm-nonmm-unstable. Did these get dropped in the confusion around casting secs_to_jiffies() to unsigned long[1]? That has since been merged in 6.14-rc2 via tglx' tree, and I have a v2 for just the ceph patches that needed some fixups at [2].

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com/

Thanks,
Easwar (he/him)