stable-rt.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RT 0/1] Linux v4.19.312-rt134-rc2
@ 2024-05-06 10:46 Daniel Wagner
  2024-05-06 10:46 ` [PATCH RT 1/1] Linux 4.19.312-rt134 Daniel Wagner
  2024-05-06 11:00 ` [PATCH RT 0/1] Linux v4.19.312-rt134-rc2 Daniel Wagner
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Wagner @ 2024-05-06 10:46 UTC (permalink / raw)
  To: LKML, linux-rt-users, stable-rt, Steven Rostedt, Thomas Gleixner,
	Sebastian Andrzej Siewior, Tom Zanussi, Clark Williams
  Cc: Daniel Wagner

Dear RT Folks,

This is the RT stable review cycle of patch 4.19.312-rt134-rc2.

Please scream at me if I messed something up. Please test the patches
too.

The -rc release is also available on kernel.org

  https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git

on the v4.19-rt-next branch.

If all goes well, this patch will be converted to the next main
release on 2024-05-13.

Signing key fingerprint:

  5BF6 7BC5 0826 72CA BB45  ACAE 587C 5ECA 5D0A 306C

All keys used for the above files and repositories can be found on the
following git repository:

   git://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git

Enjoy!
Daniel

Changes from v4.19.307-rt133:


Daniel Wagner (1):
  Linux 4.19.312-rt134

 localversion-rt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.44.0


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

* [PATCH RT 1/1] Linux 4.19.312-rt134
  2024-05-06 10:46 [PATCH RT 0/1] Linux v4.19.312-rt134-rc2 Daniel Wagner
@ 2024-05-06 10:46 ` Daniel Wagner
  2024-05-06 11:00 ` [PATCH RT 0/1] Linux v4.19.312-rt134-rc2 Daniel Wagner
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Wagner @ 2024-05-06 10:46 UTC (permalink / raw)
  To: LKML, linux-rt-users, stable-rt, Steven Rostedt, Thomas Gleixner,
	Sebastian Andrzej Siewior, Tom Zanussi, Clark Williams
  Cc: Daniel Wagner

v4.19.312-rt134-rc2 stable review patch.
If anyone has any objections, please let me know.

-----------


Signed-off-by: Daniel Wagner <wagi@monom.org>
---
 localversion-rt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/localversion-rt b/localversion-rt
index c2c7e0fb6685..6067da4c8c99 100644
--- a/localversion-rt
+++ b/localversion-rt
@@ -1 +1 @@
--rt133
+-rt134
-- 
2.44.0


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

* Re: [PATCH RT 0/1] Linux v4.19.312-rt134-rc2
  2024-05-06 10:46 [PATCH RT 0/1] Linux v4.19.312-rt134-rc2 Daniel Wagner
  2024-05-06 10:46 ` [PATCH RT 1/1] Linux 4.19.312-rt134 Daniel Wagner
@ 2024-05-06 11:00 ` Daniel Wagner
  2024-05-07  9:54   ` Sebastian Andrzej Siewior
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Wagner @ 2024-05-06 11:00 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: stable-rt, Steven Rostedt, Thomas Gleixner, linux-rt-users, LKML,
	Tom Zanussi, Clark Williams

Hi Sebastian,

On 06.05.24 12:46, Daniel Wagner wrote:
> Dear RT Folks,
> 
> This is the RT stable review cycle of patch 4.19.312-rt134-rc2.
> 
> Please scream at me if I messed something up. Please test the patches
> too.

My announce script is not attaching any conflict resolve diffs
(eventually, I'll fix this). Could have a look if I got the
kernel/time/timer.c upddate right? This was caused by stable
including the 030dcdd197d7 ("timers: Prepare support for
PREEMPT_RT") patch.

commit 2c1a32c5e05fd75885186793bc0d26e0a65b473d
Merge: 4790d0210f19 3d86e7f5bdf3
Author: Daniel Wagner <wagi@monom.org>
Date:   Wed Apr 17 16:31:21 2024 +0200

     Merge tag 'v4.19.312' into v4.19-rt-next

     This is the 4.19.312 stable release

     Conflicts:
             include/linux/timer.h
             kernel/time/timer.c

diff --git a/include/linux/timer.h b/include/linux/timer.h
remerge CONFLICT (content): Merge conflict in include/linux/timer.h
index b70c5168a346..aef40cac2add 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -173,13 +173,6 @@ extern void add_timer(struct timer_list *timer);
  extern int try_to_del_timer_sync(struct timer_list *timer);
  extern int timer_delete_sync(struct timer_list *timer);

-<<<<<<< 4790d0210f19 (Linux 4.19.307-rt133)
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
-  extern int del_timer_sync(struct timer_list *timer);
-#else
-# define del_timer_sync(t)		del_timer(t)
-#endif
-=======
  /**
   * del_timer_sync - Delete a pending timer and wait for a running callback
   * @timer:	The timer to be deleted
@@ -192,7 +185,6 @@ static inline int del_timer_sync(struct timer_list 
*timer)
  {
  	return timer_delete_sync(timer);
  }
->>>>>>> 3d86e7f5bdf3 (Linux 4.19.312)

  #define del_singleshot_timer_sync(t) del_timer_sync(t)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
remerge CONFLICT (content): Merge conflict in kernel/time/timer.c
index 911191916df1..bc5ce0cf9488 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1250,6 +1250,25 @@ int del_timer(struct timer_list *timer)
  }
  EXPORT_SYMBOL(del_timer);

+static int __try_to_del_timer_sync(struct timer_list *timer,
+				   struct timer_base **basep)
+{
+	struct timer_base *base;
+	unsigned long flags;
+	int ret = -1;
+
+	debug_assert_init(timer);
+
+	*basep = base = lock_timer_base(timer, &flags);
+
+	if (base->running_timer != timer)
+		ret = detach_if_pending(timer, base, true);
+
+	raw_spin_unlock_irqrestore(&base->lock, flags);
+
+	return ret;
+}
+
  /**
   * try_to_del_timer_sync - Try to deactivate a timer
   * @timer:	Timer to deactivate
@@ -1269,19 +1288,8 @@ EXPORT_SYMBOL(del_timer);
  int try_to_del_timer_sync(struct timer_list *timer)
  {
  	struct timer_base *base;
-	unsigned long flags;
-	int ret = -1;
-
-	debug_assert_init(timer);
-
-	base = lock_timer_base(timer, &flags);
-
-	if (base->running_timer != timer)
-		ret = detach_if_pending(timer, base, true);
-
-	raw_spin_unlock_irqrestore(&base->lock, flags);

-	return ret;
+	return __try_to_del_timer_sync(timer, &base);
  }
  EXPORT_SYMBOL(try_to_del_timer_sync);

@@ -1303,7 +1311,6 @@ static inline void timer_base_unlock_expiry(struct 
timer_base *base)

  /*
   * The counterpart to del_timer_wait_running().
-<<<<<<< 4790d0210f19 (Linux 4.19.307-rt133)
   *
   * If there is a waiter for base->expiry_lock, then it was waiting for the
   * timer callback to finish. Drop expiry_lock and reaquire it. That allows
@@ -1359,64 +1366,35 @@ static inline void 
timer_sync_wait_running(struct timer_base *base) { }
  static inline void del_timer_wait_running(struct timer_list *timer) { }
  #endif

-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
-/**
- * del_timer_sync - deactivate a timer and wait for the handler to finish.
- * @timer: the timer to be deactivated
-=======
->>>>>>> 3d86e7f5bdf3 (Linux 4.19.312)
- *
- * If there is a waiter for base->expiry_lock, then it was waiting for the
- * timer callback to finish. Drop expiry_lock and reaquire it. That allows
- * the waiter to acquire the lock and make progress.
- */
-static void timer_sync_wait_running(struct timer_base *base)
+static int __del_timer_sync(struct timer_list *timer)
  {
-	if (atomic_read(&base->timer_waiters)) {
-		spin_unlock(&base->expiry_lock);
-		spin_lock(&base->expiry_lock);
-	}
-}
+	struct timer_base *base;
+	int ret;

-/*
- * This function is called on PREEMPT_RT kernels when the fast path
- * deletion of a timer failed because the timer callback function was
- * running.
- *
- * This prevents priority inversion, if the softirq thread on a remote CPU
- * got preempted, and it prevents a life lock when the task which tries to
- * delete a timer preempted the softirq thread running the timer callback
- * function.
- */
-static void del_timer_wait_running(struct timer_list *timer)
-{
-	u32 tf;
+	/*
+	 * Must be able to sleep on PREEMPT_RT because of the slowpath in
+	 * del_timer_wait_running().
+	 */
+#if 0
+	if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(timer->flags & TIMER_IRQSAFE))
+		lockdep_assert_preemption_enabled();
+#endif

-	tf = READ_ONCE(timer->flags);
-	if (!(tf & TIMER_MIGRATING)) {
-		struct timer_base *base = get_timer_base(tf);
+	for (;;) {
+		ret = __try_to_del_timer_sync(timer, &base);
+		if (ret >= 0)
+			return ret;
+
+		if (READ_ONCE(timer->flags) & TIMER_IRQSAFE)
+			continue;

  		/*
-		 * Mark the base as contended and grab the expiry lock,
-		 * which is held by the softirq across the timer
-		 * callback. Drop the lock immediately so the softirq can
-		 * expire the next timer. In theory the timer could already
-		 * be running again, but that's more than unlikely and just
-		 * causes another wait loop.
+		 * When accessing the lock, timers of base are no longer expired
+		 * and so timer is no longer running.
  		 */
-		atomic_inc(&base->timer_waiters);
-		spin_lock_bh(&base->expiry_lock);
-		atomic_dec(&base->timer_waiters);
-		spin_unlock_bh(&base->expiry_lock);
+		timer_sync_wait_running(base);
  	}
  }
-#else
-static inline void timer_base_init_expiry_lock(struct timer_base *base) { }
-static inline void timer_base_lock_expiry(struct timer_base *base) { }
-static inline void timer_base_unlock_expiry(struct timer_base *base) { }
-static inline void timer_sync_wait_running(struct timer_base *base) { }
-static inline void del_timer_wait_running(struct timer_list *timer) { }
-#endif

  /**
   * timer_delete_sync - Deactivate a timer and wait for the handler to 
finish.
@@ -1459,8 +1437,6 @@ static inline void del_timer_wait_running(struct 
timer_list *timer) { }
   */
  int timer_delete_sync(struct timer_list *timer)
  {
-	int ret;
-
  #ifdef CONFIG_LOCKDEP
  	unsigned long flags;

@@ -1478,43 +1454,14 @@ int timer_delete_sync(struct timer_list *timer)
  	 * could lead to deadlock.
  	 */
  	WARN_ON(in_irq() && !(timer->flags & TIMER_IRQSAFE));
-<<<<<<< 4790d0210f19 (Linux 4.19.307-rt133)
-
  	/*
  	 * Must be able to sleep on PREEMPT_RT because of the slowpath in
-	 * del_timer_wait_running().
+	 * __del_timer_sync().
  	 */
-#if 0
  	if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(timer->flags & TIMER_IRQSAFE))
-		lockdep_assert_preemption_enabled();
-#endif
-
-	do {
-		ret = try_to_del_timer_sync(timer);
+		might_sleep();

-		if (unlikely(ret < 0)) {
-			del_timer_wait_running(timer);
-			cpu_relax();
-		}
-	} while (ret < 0);
-
-	return ret;
-}
-EXPORT_SYMBOL(del_timer_sync);
-#endif
-=======
->>>>>>> 3d86e7f5bdf3 (Linux 4.19.312)
-
-	do {
-		ret = try_to_del_timer_sync(timer);
-
-		if (unlikely(ret < 0)) {
-			del_timer_wait_running(timer);
-			cpu_relax();
-		}
-	} while (ret < 0);
-
-	return ret;
+	return __del_timer_sync(timer);
  }
  EXPORT_SYMBOL(timer_delete_sync);

@@ -1585,14 +1532,11 @@ static void expire_timers(struct timer_base 
*base, struct hlist_head *head)
  		if (timer->flags & TIMER_IRQSAFE) {
  			raw_spin_unlock(&base->lock);
  			call_timer_fn(timer, fn, baseclk);
-			base->running_timer = NULL;
  			raw_spin_lock(&base->lock);
  			base->running_timer = NULL;
  		} else {
  			raw_spin_unlock_irq(&base->lock);
  			call_timer_fn(timer, fn, baseclk);
-			base->running_timer = NULL;
-			timer_sync_wait_running(base);
  			raw_spin_lock_irq(&base->lock);
  			base->running_timer = NULL;
  			timer_sync_wait_running(base);

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

* Re: [PATCH RT 0/1] Linux v4.19.312-rt134-rc2
  2024-05-06 11:00 ` [PATCH RT 0/1] Linux v4.19.312-rt134-rc2 Daniel Wagner
@ 2024-05-07  9:54   ` Sebastian Andrzej Siewior
  2024-05-07 11:11     ` Daniel Wagner
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-05-07  9:54 UTC (permalink / raw)
  To: Daniel Wagner
  Cc: stable-rt, Steven Rostedt, Thomas Gleixner, linux-rt-users, LKML,
	Tom Zanussi, Clark Williams

On 2024-05-06 13:00:39 [+0200], Daniel Wagner wrote:
> Hi Sebastian,
Hi Daniel,

> On 06.05.24 12:46, Daniel Wagner wrote:
> > Dear RT Folks,
> > 
> > This is the RT stable review cycle of patch 4.19.312-rt134-rc2.
> > 
> > Please scream at me if I messed something up. Please test the patches
> > too.
> 
> My announce script is not attaching any conflict resolve diffs
> (eventually, I'll fix this). Could have a look if I got the
> kernel/time/timer.c upddate right? This was caused by stable
> including the 030dcdd197d7 ("timers: Prepare support for
> PREEMPT_RT") patch.

I compared mine outcome vs v4.19-rt-next and the diff at the bottom came
out:

- timer_delete_sync() used to have "#if 0" block around
  lockdep_assert_preemption_enabled() because the function is not part
  of v4.19. You ended up with might_sleep() which is a minor change.
  Your queue as of a previous release had the if0 block (in
  __del_timer_sync()).
  I would say this is minor but looks like a miss-merge. Therefore I
  would say it should go back for consistency vs previous release and
  not change it due to conflicts.

- The timer_delete_sync() is structured differently with
  __del_timer_sync(). That function invokes timer_sync_wait_running()
  which drops two locks which are not acquired. That is wrong. It should
  have been del_timer_wait_running().

I suggest you apply the diff below to align it with later versions. It
also gets rid of the basep argument in __try_to_del_timer_sync() which
is not really used.

As an alternative I can send you my rebased queue if this makes it
easier for you.

Sebastian

------------------>8-----------------

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1250,25 +1250,6 @@ int del_timer(struct timer_list *timer)
 }
 EXPORT_SYMBOL(del_timer);
 
-static int __try_to_del_timer_sync(struct timer_list *timer,
-				   struct timer_base **basep)
-{
-	struct timer_base *base;
-	unsigned long flags;
-	int ret = -1;
-
-	debug_assert_init(timer);
-
-	*basep = base = lock_timer_base(timer, &flags);
-
-	if (base->running_timer != timer)
-		ret = detach_if_pending(timer, base, true);
-
-	raw_spin_unlock_irqrestore(&base->lock, flags);
-
-	return ret;
-}
-
 /**
  * try_to_del_timer_sync - Try to deactivate a timer
  * @timer:	Timer to deactivate
@@ -1288,8 +1269,19 @@ static int __try_to_del_timer_sync(struct timer_list *timer,
 int try_to_del_timer_sync(struct timer_list *timer)
 {
 	struct timer_base *base;
+	unsigned long flags;
+	int ret = -1;
 
-	return __try_to_del_timer_sync(timer, &base);
+	debug_assert_init(timer);
+
+	base = lock_timer_base(timer, &flags);
+
+	if (base->running_timer != timer)
+		ret = detach_if_pending(timer, base, true);
+
+	raw_spin_unlock_irqrestore(&base->lock, flags);
+
+	return ret;
 }
 EXPORT_SYMBOL(try_to_del_timer_sync);
 
@@ -1366,36 +1358,6 @@ static inline void timer_sync_wait_running(struct timer_base *base) { }
 static inline void del_timer_wait_running(struct timer_list *timer) { }
 #endif
 
-static int __del_timer_sync(struct timer_list *timer)
-{
-	struct timer_base *base;
-	int ret;
-
-	/*
-	 * Must be able to sleep on PREEMPT_RT because of the slowpath in
-	 * del_timer_wait_running().
-	 */
-#if 0
-	if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(timer->flags & TIMER_IRQSAFE))
-		lockdep_assert_preemption_enabled();
-#endif
-
-	for (;;) {
-		ret = __try_to_del_timer_sync(timer, &base);
-		if (ret >= 0)
-			return ret;
-
-		if (READ_ONCE(timer->flags) & TIMER_IRQSAFE)
-			continue;
-
-		/*
-		 * When accessing the lock, timers of base are no longer expired
-		 * and so timer is no longer running.
-		 */
-		timer_sync_wait_running(base);
-	}
-}
-
 /**
  * timer_delete_sync - Deactivate a timer and wait for the handler to finish.
  * @timer:	The timer to be deactivated
@@ -1437,6 +1399,8 @@ static int __del_timer_sync(struct timer_list *timer)
  */
 int timer_delete_sync(struct timer_list *timer)
 {
+	int ret;
+
 #ifdef CONFIG_LOCKDEP
 	unsigned long flags;
 
@@ -1454,14 +1418,26 @@ int timer_delete_sync(struct timer_list *timer)
 	 * could lead to deadlock.
 	 */
 	WARN_ON(in_irq() && !(timer->flags & TIMER_IRQSAFE));
+
 	/*
 	 * Must be able to sleep on PREEMPT_RT because of the slowpath in
-	 * __del_timer_sync().
+	 * del_timer_wait_running().
 	 */
+#if 0
 	if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(timer->flags & TIMER_IRQSAFE))
-		might_sleep();
+		lockdep_assert_preemption_enabled();
+#endif
 
-	return __del_timer_sync(timer);
+	do {
+		ret = try_to_del_timer_sync(timer);
+
+		if (unlikely(ret < 0)) {
+			del_timer_wait_running(timer);
+			cpu_relax();
+		}
+	} while (ret < 0);
+
+	return ret;
 }
 EXPORT_SYMBOL(timer_delete_sync);
 

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

* Re: [PATCH RT 0/1] Linux v4.19.312-rt134-rc2
  2024-05-07  9:54   ` Sebastian Andrzej Siewior
@ 2024-05-07 11:11     ` Daniel Wagner
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Wagner @ 2024-05-07 11:11 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: stable-rt, Steven Rostedt, Thomas Gleixner, linux-rt-users, LKML,
	Tom Zanussi, Clark Williams

Hi Sebastian,

On Tue, May 07, 2024 at 11:54:07AM GMT, Sebastian Andrzej Siewior wrote:
> I compared mine outcome vs v4.19-rt-next and the diff at the bottom came
> out:
> 
> - timer_delete_sync() used to have "#if 0" block around
>   lockdep_assert_preemption_enabled() because the function is not part
>   of v4.19. You ended up with might_sleep() which is a minor change.
>   Your queue as of a previous release had the if0 block (in
>   __del_timer_sync()).
>   I would say this is minor but looks like a miss-merge. Therefore I
>   would say it should go back for consistency vs previous release and
>   not change it due to conflicts.

Makes sense.

> - The timer_delete_sync() is structured differently with
>   __del_timer_sync(). That function invokes timer_sync_wait_running()
>   which drops two locks which are not acquired. That is wrong. It should
>   have been del_timer_wait_running().

Understood. I was a bit strungling here. Glad you caught this error.

> I suggest you apply the diff below to align it with later versions. It
> also gets rid of the basep argument in __try_to_del_timer_sync() which
> is not really used.

Will do.

> As an alternative I can send you my rebased queue if this makes it
> easier for you.

Yes please, this makes it easy to sync the rebase branch.

Thanks a lot!

Cheers,
Daniel

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

end of thread, other threads:[~2024-05-07 11:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 10:46 [PATCH RT 0/1] Linux v4.19.312-rt134-rc2 Daniel Wagner
2024-05-06 10:46 ` [PATCH RT 1/1] Linux 4.19.312-rt134 Daniel Wagner
2024-05-06 11:00 ` [PATCH RT 0/1] Linux v4.19.312-rt134-rc2 Daniel Wagner
2024-05-07  9:54   ` Sebastian Andrzej Siewior
2024-05-07 11:11     ` Daniel Wagner

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).