Thread (39 messages) 39 messages, 8 authors, 2024-12-17

Re: [PATCH v3 02/19] coccinelle: misc: Add secs_to_jiffies script

From: Alexander Gordeev <agordeev@linux.ibm.com>
Date: 2024-12-17 17:31:06
Also in: ath11k, ceph-devel, dri-devel, intel-xe, linux-block, linux-bluetooth, linux-mm, linux-s390, linux-scsi, linux-sound, linux-staging, linux-wireless, live-patching, lkml, netdev, netfilter-devel, xen-devel

On Tue, Dec 10, 2024 at 10:02:33PM +0000, Easwar Hariharan wrote:

Hi Easwar,
quoted hunk ↗ jump to hunk
This script finds and suggests conversions of timeout patterns that
result in seconds-denominated timeouts to use the new secs_to_jiffies()
API in include/linux/jiffies.h for better readability.

Suggested-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Easwar Hariharan <redacted>
---
 scripts/coccinelle/misc/secs_to_jiffies.cocci | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff --git a/scripts/coccinelle/misc/secs_to_jiffies.cocci b/scripts/coccinelle/misc/secs_to_jiffies.cocci
new file mode 100644
index 0000000000000000000000000000000000000000..8bbb2884ea5db939c63fd4513cf5ca8c977aa8cb
--- /dev/null
+++ b/scripts/coccinelle/misc/secs_to_jiffies.cocci
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0-only
+///
+/// Find usages of:
+/// - msecs_to_jiffies(value*1000)
+/// - msecs_to_jiffies(value*MSEC_PER_SEC)
+///
+// Confidence: High
+// Copyright: (C) 2024 Easwar Hariharan, Microsoft
+// Keywords: secs, seconds, jiffies
+//
+
+virtual patch
+
+@depends on patch@ constant C; @@
+
+- msecs_to_jiffies(C * 1000)
++ secs_to_jiffies(C)
+
+@depends on patch@ constant C; @@
+
+- msecs_to_jiffies(C * MSEC_PER_SEC)
++ secs_to_jiffies(C)
If you used this script only, then it did not seem to recognize line arch/s390/mm/cmm.c:207

	mod_timer(&cmm_timer, jiffies + msecs_to_jiffies(cmm_timeout_seconds * MSEC_PER_SEC));

Thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help