Re: [PATCH v3 18/19] livepatch: Convert timeouts to secs_to_jiffies()

Christophe Leroy
2024-12-11T07:00:15Z

Le 10/12/2024 à 23:02, Easwar Hariharan a écrit :
> 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:
>
> @@ constant C; @@
>
> - msecs_to_jiffies(C * 1000)
> + secs_to_jiffies(C)
>
> @@ constant C; @@
>
> - msecs_to_jiffies(C * MSEC_PER_SEC)
> + secs_to_jiffies(C)
>
> Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
> ---
> samples/livepatch/livepatch-callbacks-busymod.c | 3 +--
> samples/livepatch/livepatch-shadow-fix1.c | 3 +--
> samples/livepatch/livepatch-shadow-mod.c | 15 +++++----------
> 3 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/samples/livepatch/livepatch-callbacks-busymod.c b/samples/livepatch/livepatch-callbacks-busymod.c
> index 378e2d40271a9717d09eff51d3d3612c679736fc..69105596e72e6826aa2815cb2599eea56a0055ba 100644
> --- a/samples/livepatch/livepatch-callbacks-busymod.c
> +++ b/samples/livepatch/livepatch-callbacks-busymod.c
> @@ -44,8 +44,7 @@ static void busymod_work_func(struct work_struct *work)
> static int livepatch_callbacks_mod_init(void)
> {
> pr_info("%s\n", __func__);
> - schedule_delayed_work(&work,
> - msecs_to_jiffies(1000 * 0));
> + schedule_delayed_work(&work, 0);

This hunk is not in line with the patch description.

This is probably OK to have in this patch, but you should add additional
description to mention that special case with a 0 delay.

Allthough you should probably change it to schedule_work() instead of
using a 0 delay.

Christophe