live-patching.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Converge on using secs_to_jiffies()
@ 2024-12-17 23:09 Easwar Hariharan
  2024-12-17 23:09 ` [PATCH v4 1/2] s390: kernel: Convert timeouts to use secs_to_jiffies() Easwar Hariharan
  2024-12-17 23:09 ` [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies() Easwar Hariharan
  0 siblings, 2 replies; 8+ messages in thread
From: Easwar Hariharan @ 2024-12-17 23:09 UTC (permalink / raw)
  To: Andrew Morton, Alexander Gordeev, Christophe Leroy,
	Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, Josh Poimboeuf, Jiri Kosina,
	Miroslav Benes, Petr Mladek, Joe Lawrence
  Cc: linux-s390, linux-kernel, live-patching, Easwar Hariharan

Fixups for a couple of patches that received review after the series was
queued into mm.

Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
Changes in v4:
- Replace schedule_delayed_work() that had a 0 timeout with
  schedule_work() in livepatch (Christophe Leroy)
- Added requested hunk in s390 (Alexander Gordeev)
- Link to v3: https://lore.kernel.org/r/20241210-converge-secs-to-jiffies-v3-0-ddfefd7e9f2a@linux.microsoft.com
Changes in v3:
- Rebase on next-20241210
- Fix typo'ed timeout in net/netfilter/nf_conntrack_proto_sctp.c (Stephen Rothwell)
- Use Coccinelle operation modes for Coccinelle script (Markus Elfring)
- Remove redundant comments in arch/arm/mach-pxa/sharpsl_pm.c (Christophe Leroy)
- Remove excess line breaks (Heiko Carstens, Christophe Leroy)
- Add more detail into the commit messages throughout (Christophe Leroy)
- Pick up Reviewed-by Thomas Hellstrom for drm/xe
- Drop drm/etnaviv patch already queued into etnaviv/next
- Replace call to [m]secs_to_jiffies(0) with just 0 for livepatch (Dan Carpenter, Christophe Leroy)
- Split out nfp patch to send to net-next (Christophe Leroy)
- Pick up Acked-by from Jeff Johnson for ath11k
- Link to v2: https://lore.kernel.org/r/20241115-converge-secs-to-jiffies-v2-0-911fb7595e79@linux.microsoft.com
Changes in v2:
- Exclude already accepted patch adding secs_to_jiffies() https://git.kernel.org/tip/b35108a51cf7bab58d7eace1267d7965978bcdb8
- Link to v1: https://lore.kernel.org/r/20241115-converge-secs-to-jiffies-v1-0-19aadc34941b@linux.microsoft.com

Easwar Hariharan (2):
  s390: kernel: Convert timeouts to use secs_to_jiffies()
  livepatch: Convert timeouts to secs_to_jiffies()

 arch/s390/kernel/lgr.c                          |  2 +-
 arch/s390/kernel/time.c                         |  4 ++--
 arch/s390/kernel/topology.c                     |  2 +-
 arch/s390/mm/cmm.c                              |  2 +-
 samples/livepatch/livepatch-callbacks-busymod.c |  3 +--
 samples/livepatch/livepatch-shadow-fix1.c       |  3 +--
 samples/livepatch/livepatch-shadow-mod.c        | 15 +++++----------
 7 files changed, 12 insertions(+), 19 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 1/2] s390: kernel: Convert timeouts to use secs_to_jiffies()
  2024-12-17 23:09 [PATCH v4 0/2] Converge on using secs_to_jiffies() Easwar Hariharan
@ 2024-12-17 23:09 ` Easwar Hariharan
  2024-12-17 23:09 ` [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies() Easwar Hariharan
  1 sibling, 0 replies; 8+ messages in thread
From: Easwar Hariharan @ 2024-12-17 23:09 UTC (permalink / raw)
  To: Andrew Morton, Alexander Gordeev, Christophe Leroy,
	Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, Josh Poimboeuf, Jiri Kosina,
	Miroslav Benes, Petr Mladek, Joe Lawrence
  Cc: linux-s390, linux-kernel, live-patching, Easwar Hariharan

Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies(). As the values here are 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)

While here, manually convert the one other remaining instance as
requested.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
 arch/s390/kernel/lgr.c      | 2 +-
 arch/s390/kernel/time.c     | 4 ++--
 arch/s390/kernel/topology.c | 2 +-
 arch/s390/mm/cmm.c          | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kernel/lgr.c b/arch/s390/kernel/lgr.c
index 6652e54cf3db..6d1ffca5f798 100644
--- a/arch/s390/kernel/lgr.c
+++ b/arch/s390/kernel/lgr.c
@@ -166,7 +166,7 @@ static struct timer_list lgr_timer;
  */
 static void lgr_timer_set(void)
 {
-	mod_timer(&lgr_timer, jiffies + msecs_to_jiffies(LGR_TIMER_INTERVAL_SECS * MSEC_PER_SEC));
+	mod_timer(&lgr_timer, jiffies + secs_to_jiffies(LGR_TIMER_INTERVAL_SECS));
 }
 
 /*
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 34a65c141ea0..e9f47c3a6197 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -662,12 +662,12 @@ static void stp_check_leap(void)
 		if (ret < 0)
 			pr_err("failed to set leap second flags\n");
 		/* arm Timer to clear leap second flags */
-		mod_timer(&stp_timer, jiffies + msecs_to_jiffies(14400 * MSEC_PER_SEC));
+		mod_timer(&stp_timer, jiffies + secs_to_jiffies(14400));
 	} else {
 		/* The day the leap second is scheduled for hasn't been reached. Retry
 		 * in one hour.
 		 */
-		mod_timer(&stp_timer, jiffies + msecs_to_jiffies(3600 * MSEC_PER_SEC));
+		mod_timer(&stp_timer, jiffies + secs_to_jiffies(3600));
 	}
 }
 
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 4f9c301a705b..0fd56a1cadbd 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -371,7 +371,7 @@ static void set_topology_timer(void)
 	if (atomic_add_unless(&topology_poll, -1, 0))
 		mod_timer(&topology_timer, jiffies + msecs_to_jiffies(100));
 	else
-		mod_timer(&topology_timer, jiffies + msecs_to_jiffies(60 * MSEC_PER_SEC));
+		mod_timer(&topology_timer, jiffies + secs_to_jiffies(60));
 }
 
 void topology_expect_change(void)
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index d01724a715d0..7bf0f691827b 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -204,7 +204,7 @@ static void cmm_set_timer(void)
 			del_timer(&cmm_timer);
 		return;
 	}
-	mod_timer(&cmm_timer, jiffies + msecs_to_jiffies(cmm_timeout_seconds * MSEC_PER_SEC));
+	mod_timer(&cmm_timer, jiffies + secs_to_jiffies(cmm_timeout_seconds));
 }
 
 static void cmm_timer_fn(struct timer_list *unused)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies()
  2024-12-17 23:09 [PATCH v4 0/2] Converge on using secs_to_jiffies() Easwar Hariharan
  2024-12-17 23:09 ` [PATCH v4 1/2] s390: kernel: Convert timeouts to use secs_to_jiffies() Easwar Hariharan
@ 2024-12-17 23:09 ` Easwar Hariharan
  2024-12-18  6:30   ` Christophe Leroy
  2024-12-18  8:38   ` Petr Mladek
  1 sibling, 2 replies; 8+ messages in thread
From: Easwar Hariharan @ 2024-12-17 23:09 UTC (permalink / raw)
  To: Andrew Morton, Alexander Gordeev, Christophe Leroy,
	Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, Josh Poimboeuf, Jiri Kosina,
	Miroslav Benes, Petr Mladek, Joe Lawrence
  Cc: linux-s390, linux-kernel, live-patching, 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:

@@ constant C; @@

- msecs_to_jiffies(C * 1000)
+ secs_to_jiffies(C)

@@ constant C; @@

- msecs_to_jiffies(C * MSEC_PER_SEC)
+ secs_to_jiffies(C)

While here, replace the schedule_delayed_work() call with a 0 timeout
with an immediate schedule_work() call.

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 378e2d40271a..0220f7715fcc 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_work(&work);
 	return 0;
 }
 
diff --git a/samples/livepatch/livepatch-shadow-fix1.c b/samples/livepatch/livepatch-shadow-fix1.c
index 6701641bf12d..f3f153895d6c 100644
--- a/samples/livepatch/livepatch-shadow-fix1.c
+++ b/samples/livepatch/livepatch-shadow-fix1.c
@@ -72,8 +72,7 @@ static struct dummy *livepatch_fix1_dummy_alloc(void)
 	if (!d)
 		return NULL;
 
-	d->jiffies_expire = jiffies +
-		msecs_to_jiffies(1000 * EXPIRE_PERIOD);
+	d->jiffies_expire = jiffies + secs_to_jiffies(EXPIRE_PERIOD);
 
 	/*
 	 * Patch: save the extra memory location into a SV_LEAK shadow
diff --git a/samples/livepatch/livepatch-shadow-mod.c b/samples/livepatch/livepatch-shadow-mod.c
index 7e753b0d2fa6..5d83ad5a8118 100644
--- a/samples/livepatch/livepatch-shadow-mod.c
+++ b/samples/livepatch/livepatch-shadow-mod.c
@@ -101,8 +101,7 @@ static __used noinline struct dummy *dummy_alloc(void)
 	if (!d)
 		return NULL;
 
-	d->jiffies_expire = jiffies +
-		msecs_to_jiffies(1000 * EXPIRE_PERIOD);
+	d->jiffies_expire = jiffies + secs_to_jiffies(EXPIRE_PERIOD);
 
 	/* Oops, forgot to save leak! */
 	leak = kzalloc(sizeof(*leak), GFP_KERNEL);
@@ -152,8 +151,7 @@ static void alloc_work_func(struct work_struct *work)
 	list_add(&d->list, &dummy_list);
 	mutex_unlock(&dummy_list_mutex);
 
-	schedule_delayed_work(&alloc_dwork,
-		msecs_to_jiffies(1000 * ALLOC_PERIOD));
+	schedule_delayed_work(&alloc_dwork, secs_to_jiffies(ALLOC_PERIOD));
 }
 
 /*
@@ -184,16 +182,13 @@ static void cleanup_work_func(struct work_struct *work)
 	}
 	mutex_unlock(&dummy_list_mutex);
 
-	schedule_delayed_work(&cleanup_dwork,
-		msecs_to_jiffies(1000 * CLEANUP_PERIOD));
+	schedule_delayed_work(&cleanup_dwork, secs_to_jiffies(CLEANUP_PERIOD));
 }
 
 static int livepatch_shadow_mod_init(void)
 {
-	schedule_delayed_work(&alloc_dwork,
-		msecs_to_jiffies(1000 * ALLOC_PERIOD));
-	schedule_delayed_work(&cleanup_dwork,
-		msecs_to_jiffies(1000 * CLEANUP_PERIOD));
+	schedule_delayed_work(&alloc_dwork, secs_to_jiffies(ALLOC_PERIOD));
+	schedule_delayed_work(&cleanup_dwork, secs_to_jiffies(CLEANUP_PERIOD));
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies()
  2024-12-17 23:09 ` [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies() Easwar Hariharan
@ 2024-12-18  6:30   ` Christophe Leroy
  2024-12-18  8:38   ` Petr Mladek
  1 sibling, 0 replies; 8+ messages in thread
From: Christophe Leroy @ 2024-12-18  6:30 UTC (permalink / raw)
  To: Easwar Hariharan, Andrew Morton, Alexander Gordeev,
	Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, Josh Poimboeuf, Jiri Kosina,
	Miroslav Benes, Petr Mladek, Joe Lawrence
  Cc: linux-s390, linux-kernel, live-patching



Le 18/12/2024 à 00:09, 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)
> 
> While here, replace the schedule_delayed_work() call with a 0 timeout
> with an immediate schedule_work() call.
> 
> Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   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 378e2d40271a..0220f7715fcc 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_work(&work);
>   	return 0;
>   }
>   
> diff --git a/samples/livepatch/livepatch-shadow-fix1.c b/samples/livepatch/livepatch-shadow-fix1.c
> index 6701641bf12d..f3f153895d6c 100644
> --- a/samples/livepatch/livepatch-shadow-fix1.c
> +++ b/samples/livepatch/livepatch-shadow-fix1.c
> @@ -72,8 +72,7 @@ static struct dummy *livepatch_fix1_dummy_alloc(void)
>   	if (!d)
>   		return NULL;
>   
> -	d->jiffies_expire = jiffies +
> -		msecs_to_jiffies(1000 * EXPIRE_PERIOD);
> +	d->jiffies_expire = jiffies + secs_to_jiffies(EXPIRE_PERIOD);
>   
>   	/*
>   	 * Patch: save the extra memory location into a SV_LEAK shadow
> diff --git a/samples/livepatch/livepatch-shadow-mod.c b/samples/livepatch/livepatch-shadow-mod.c
> index 7e753b0d2fa6..5d83ad5a8118 100644
> --- a/samples/livepatch/livepatch-shadow-mod.c
> +++ b/samples/livepatch/livepatch-shadow-mod.c
> @@ -101,8 +101,7 @@ static __used noinline struct dummy *dummy_alloc(void)
>   	if (!d)
>   		return NULL;
>   
> -	d->jiffies_expire = jiffies +
> -		msecs_to_jiffies(1000 * EXPIRE_PERIOD);
> +	d->jiffies_expire = jiffies + secs_to_jiffies(EXPIRE_PERIOD);
>   
>   	/* Oops, forgot to save leak! */
>   	leak = kzalloc(sizeof(*leak), GFP_KERNEL);
> @@ -152,8 +151,7 @@ static void alloc_work_func(struct work_struct *work)
>   	list_add(&d->list, &dummy_list);
>   	mutex_unlock(&dummy_list_mutex);
>   
> -	schedule_delayed_work(&alloc_dwork,
> -		msecs_to_jiffies(1000 * ALLOC_PERIOD));
> +	schedule_delayed_work(&alloc_dwork, secs_to_jiffies(ALLOC_PERIOD));
>   }
>   
>   /*
> @@ -184,16 +182,13 @@ static void cleanup_work_func(struct work_struct *work)
>   	}
>   	mutex_unlock(&dummy_list_mutex);
>   
> -	schedule_delayed_work(&cleanup_dwork,
> -		msecs_to_jiffies(1000 * CLEANUP_PERIOD));
> +	schedule_delayed_work(&cleanup_dwork, secs_to_jiffies(CLEANUP_PERIOD));
>   }
>   
>   static int livepatch_shadow_mod_init(void)
>   {
> -	schedule_delayed_work(&alloc_dwork,
> -		msecs_to_jiffies(1000 * ALLOC_PERIOD));
> -	schedule_delayed_work(&cleanup_dwork,
> -		msecs_to_jiffies(1000 * CLEANUP_PERIOD));
> +	schedule_delayed_work(&alloc_dwork, secs_to_jiffies(ALLOC_PERIOD));
> +	schedule_delayed_work(&cleanup_dwork, secs_to_jiffies(CLEANUP_PERIOD));
>   
>   	return 0;
>   }


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies()
  2024-12-17 23:09 ` [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies() Easwar Hariharan
  2024-12-18  6:30   ` Christophe Leroy
@ 2024-12-18  8:38   ` Petr Mladek
  2024-12-18  8:48     ` Christophe Leroy
  1 sibling, 1 reply; 8+ messages in thread
From: Petr Mladek @ 2024-12-18  8:38 UTC (permalink / raw)
  To: Easwar Hariharan
  Cc: Andrew Morton, Alexander Gordeev, Christophe Leroy,
	Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, Josh Poimboeuf, Jiri Kosina,
	Miroslav Benes, Joe Lawrence, linux-s390, linux-kernel,
	live-patching

On Tue 2024-12-17 23:09:59, Easwar Hariharan wrote:
> 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)
> 
> While here, replace the schedule_delayed_work() call with a 0 timeout
> with an immediate schedule_work() call.
> 
> --- 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_work(&work);

Is it safe to use schedule_work() for struct delayed_work?

It might work in theory but I do not feel comfortable with it.
Also I would expect a compiler warning.

If you really want to use schedule_work() then please
also define the structure with DECLARE_WORK()
and use cancel_work_sync() in livepatch_callbacks_mod_exit().

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies()
  2024-12-18  8:38   ` Petr Mladek
@ 2024-12-18  8:48     ` Christophe Leroy
  2024-12-18 17:35       ` Easwar Hariharan
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe Leroy @ 2024-12-18  8:48 UTC (permalink / raw)
  To: Petr Mladek, Easwar Hariharan
  Cc: Andrew Morton, Alexander Gordeev, Gerald Schaefer, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Sven Schnelle,
	Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Joe Lawrence,
	linux-s390, linux-kernel, live-patching



Le 18/12/2024 à 09:38, Petr Mladek a écrit :
> On Tue 2024-12-17 23:09:59, Easwar Hariharan wrote:
>> 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)
>>
>> While here, replace the schedule_delayed_work() call with a 0 timeout
>> with an immediate schedule_work() call.
>>
>> --- 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_work(&work);
> 
> Is it safe to use schedule_work() for struct delayed_work?

Should be, but you are right it should then be a standard work not a 
delayed work.

So probably the easiest is to keep

	schedule_delayed_work(&work, 0)

And eventually changing it to a not delayed work could be a follow-up patch.

> 
> It might work in theory but I do not feel comfortable with it.
> Also I would expect a compiler warning.

__queue_delayed_work() does :

	if (!delay) {
		__queue_work(cpu, wq, &dwork->work);
		return;
	}


> 
> If you really want to use schedule_work() then please
> also define the structure with DECLARE_WORK()
> and use cancel_work_sync() in livepatch_callbacks_mod_exit().
> 
> Best Regards,
> Petr


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies()
  2024-12-18  8:48     ` Christophe Leroy
@ 2024-12-18 17:35       ` Easwar Hariharan
  2025-01-02 15:27         ` Petr Mladek
  0 siblings, 1 reply; 8+ messages in thread
From: Easwar Hariharan @ 2024-12-18 17:35 UTC (permalink / raw)
  To: Christophe Leroy, Petr Mladek, Andrew Morton
  Cc: eahariha, Alexander Gordeev, Gerald Schaefer, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, Sven Schnelle,
	Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Joe Lawrence,
	linux-s390, linux-kernel, live-patching

On 12/18/2024 12:48 AM, Christophe Leroy wrote:
> 
> 
> Le 18/12/2024 à 09:38, Petr Mladek a écrit :
>> On Tue 2024-12-17 23:09:59, Easwar Hariharan wrote:
>>> 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)
>>>
>>> While here, replace the schedule_delayed_work() call with a 0 timeout
>>> with an immediate schedule_work() call.
>>>
>>> --- 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_work(&work);
>>
>> Is it safe to use schedule_work() for struct delayed_work?
> 
> Should be, but you are right it should then be a standard work not a
> delayed work.
> 
> So probably the easiest is to keep
> 
>     schedule_delayed_work(&work, 0)
> 
> And eventually changing it to a not delayed work could be a follow-up
> patch.
> 
>>

Thanks for the catch, Petr! This suggestion would effectively revert
this patch to the v3 version, albeit with some extra explanation in the
commit message. I'd propose just keeping the v3 in the next branch where
it is.

Andrew, Petr, Christophe, what do you think?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies()
  2024-12-18 17:35       ` Easwar Hariharan
@ 2025-01-02 15:27         ` Petr Mladek
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Mladek @ 2025-01-02 15:27 UTC (permalink / raw)
  To: Easwar Hariharan
  Cc: Christophe Leroy, Andrew Morton, Alexander Gordeev,
	Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, Josh Poimboeuf, Jiri Kosina,
	Miroslav Benes, Joe Lawrence, linux-s390, linux-kernel,
	live-patching

On Wed 2024-12-18 09:35:46, Easwar Hariharan wrote:
> On 12/18/2024 12:48 AM, Christophe Leroy wrote:
> > 
> > 
> > Le 18/12/2024 à 09:38, Petr Mladek a écrit :
> >> On Tue 2024-12-17 23:09:59, Easwar Hariharan wrote:
> >>> 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)
> >>>
> >>> While here, replace the schedule_delayed_work() call with a 0 timeout
> >>> with an immediate schedule_work() call.
> >>>
> >>> --- 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_work(&work);
> >>
> >> Is it safe to use schedule_work() for struct delayed_work?
> > 
> > Should be, but you are right it should then be a standard work not a
> > delayed work.
> > 
> > So probably the easiest is to keep
> > 
> >     schedule_delayed_work(&work, 0)
> > 
> > And eventually changing it to a not delayed work could be a follow-up
> > patch.
> > 
> >>
> 
> Thanks for the catch, Petr! This suggestion would effectively revert
> this patch to the v3 version, albeit with some extra explanation in the
> commit message. I'd propose just keeping the v3 in the next branch where
> it is.
> 
> Andrew, Petr, Christophe, what do you think?

I am fine with keeping v3 in next.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-01-02 15:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-17 23:09 [PATCH v4 0/2] Converge on using secs_to_jiffies() Easwar Hariharan
2024-12-17 23:09 ` [PATCH v4 1/2] s390: kernel: Convert timeouts to use secs_to_jiffies() Easwar Hariharan
2024-12-17 23:09 ` [PATCH v4 2/2] livepatch: Convert timeouts to secs_to_jiffies() Easwar Hariharan
2024-12-18  6:30   ` Christophe Leroy
2024-12-18  8:38   ` Petr Mladek
2024-12-18  8:48     ` Christophe Leroy
2024-12-18 17:35       ` Easwar Hariharan
2025-01-02 15:27         ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).