[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52cc0733-49fc-4452-99c6-8c18bf20dde7@linux.microsoft.com>
Date: Mon, 18 Nov 2024 10:09:17 -0800
From: Easwar Hariharan <eahariha@...ux.microsoft.com>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc: eahariha@...ux.microsoft.com, James.Bottomley@...senPartnership.com,
Julia.Lawall@...ia.fr, agordeev@...ux.ibm.com, airlied@...il.com,
akpm@...ux-foundation.org, andrew+netdev@...n.ch, anna-maria@...utronix.de,
ath11k@...ts.infradead.org, axboe@...nel.dk,
bcm-kernel-feedback-list@...adcom.com, borntraeger@...ux.ibm.com,
catalin.marinas@....com, ceph-devel@...r.kernel.org,
christian.gmeiner@...il.com, christophe.leroy@...roup.eu, cocci@...ia.fr,
coreteam@...filter.org, daniel@...que.org, davem@...emloft.net,
dick.kennedy@...adcom.com, dri-devel@...ts.freedesktop.org,
edumazet@...gle.com, etnaviv@...ts.freedesktop.org,
florian.fainelli@...adcom.com, gor@...ux.ibm.com,
gregkh@...uxfoundation.org, haojian.zhuang@...il.com, hca@...ux.ibm.com,
horms@...nel.org, idryomov@...il.com, intel-xe@...ts.freedesktop.org,
james.smart@...adcom.com, jeroendb@...gle.com, jikos@...nel.org,
jinpu.wang@...ud.ionos.com, jjohnson@...nel.org, joe.lawrence@...hat.com,
johan.hedberg@...il.com, jpoimboe@...nel.org, kadlec@...filter.org,
kuba@...nel.org, kvalo@...nel.org, l.stach@...gutronix.de,
linux+etnaviv@...linux.org.uk, linux-arm-kernel@...ts.infradead.org,
linux-block@...r.kernel.org, linux-bluetooth@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-rpi-kernel@...ts.infradead.org, linux-s390@...r.kernel.org,
linux-scsi@...r.kernel.org, linux-sound@...r.kernel.org,
linux-staging@...ts.linux.dev, linux-wireless@...r.kernel.org,
linux@...linux.org.uk, linuxppc-dev@...ts.ozlabs.org,
live-patching@...r.kernel.org, louis.peens@...igine.com,
lucas.demarchi@...el.com, luiz.dentz@...il.com,
maarten.lankhorst@...ux.intel.com, maddy@...ux.ibm.com, marcel@...tmann.org,
martin.petersen@...cle.com, mbenes@...e.cz, mpe@...erman.id.au,
mripard@...nel.org, naveen@...nel.org, netdev@...r.kernel.org,
netfilter-devel@...r.kernel.org, nicolas.palix@...g.fr, npiggin@...il.com,
obitton@...ana.ai, ogabbay@...nel.org, oss-drivers@...igine.com,
pabeni@...hat.com, pablo@...filter.org, perex@...ex.cz,
pkaligineedi@...gle.com, pmladek@...e.com, rjui@...adcom.com,
robert.jarzmik@...e.fr, rodrigo.vivi@...el.com, roger.pau@...rix.com,
sbranden@...adcom.com, shailend@...gle.com, simona@...ll.ch,
svens@...ux.ibm.com, thomas.hellstrom@...ux.intel.com, tiwai@...e.com,
tzimmermann@...e.de, xen-devel@...ts.xenproject.org, xiubli@...hat.com
Subject: Re: [PATCH v2 02/21] coccinelle: misc: Add secs_to_jiffies script
On 11/15/2024 10:05 PM, Christophe JAILLET wrote:
> Le 15/11/2024 à 22:26, Easwar Hariharan a écrit :
>> Suggested-by: Anna-Maria Behnsen <anna-maria@...utronix.de>
>> Signed-off-by: Easwar Hariharan <eahariha@...ux.microsoft.com>
>> ---
>> scripts/coccinelle/misc/secs_to_jiffies.cocci | 21 +++++++++++++++++++++
>> 1 file changed, 21 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..af762b1c0aac8f044f21150bfaafd9efc834ee87
>> --- /dev/null
>> +++ b/scripts/coccinelle/misc/secs_to_jiffies.cocci
>> @@ -0,0 +1,21 @@
>> +// 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
>> +//
>> +
>> +@@ constant C; @@
>> +
>> +- msecs_to_jiffies(C * 1000)
>> ++ secs_to_jiffies(C)
>> +
>> +@@ constant C; @@
>> +
>> +- msecs_to_jiffies(C * MSEC_PER_SEC)
>> ++ secs_to_jiffies(C)
>>
> Hi,
>
> @@ constant C =~ "000"; @@
>
> * msecs_to_jiffies(C)
>
> also spots things like msecs_to_jiffies(1000)
>
> I'm not sure that coccinelle is enable to capture part of the regex to automate the removal of the 000 when converting from ms to s.
>
> Just my 2c,
>
> CJ
Thank you, I'll try that rule for the later parts. Thank you all for
helping with writing Coccinelle rules, I'm not familiar with
metaprogramming in general and Coccinelle in particular, so these are
super helpful.
- Easwar
Powered by blists - more mailing lists