[printk,v3,01/40] rcu: implement lockdep_rcu_enabled for !CONFIG_DEBUG_LOCK_ALLOC

Message ID 20221107141638.3790965-2-john.ogness@linutronix.de
State New
Headers
Series reduce console_lock scope |

Commit Message

John Ogness Nov. 7, 2022, 2:15 p.m. UTC
  Provide an implementation for debug_lockdep_rcu_enabled() when
CONFIG_DEBUG_LOCK_ALLOC is not enabled. This allows code to check
if rcu lockdep debugging is available without needing an extra
check if CONFIG_DEBUG_LOCK_ALLOC is enabled.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 I also sent this patch to Paul as a suggestion. If it is not
 acceptable, I just need to add an ifdef CONFIG_DEBUG_LOCK_ALLOC
 into console_list_lock() of patch 21.

 include/linux/rcupdate.h | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Paul E. McKenney Nov. 7, 2022, 6:01 p.m. UTC | #1
On Mon, Nov 07, 2022 at 03:21:59PM +0106, John Ogness wrote:
> Provide an implementation for debug_lockdep_rcu_enabled() when
> CONFIG_DEBUG_LOCK_ALLOC is not enabled. This allows code to check
> if rcu lockdep debugging is available without needing an extra
> check if CONFIG_DEBUG_LOCK_ALLOC is enabled.
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

If you would like me to take this one, please let me know.

Otherwise:

Acked-by: Paul E. McKenney <paulmck@kernel.org>

> ---
>  I also sent this patch to Paul as a suggestion. If it is not
>  acceptable, I just need to add an ifdef CONFIG_DEBUG_LOCK_ALLOC
>  into console_list_lock() of patch 21.
> 
>  include/linux/rcupdate.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 08605ce7379d..65178c40ab6f 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -340,6 +340,11 @@ static inline int rcu_read_lock_any_held(void)
>  	return !preemptible();
>  }
>  
> +static inline int debug_lockdep_rcu_enabled(void)
> +{
> +	return 0;
> +}
> +
>  #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
>  
>  #ifdef CONFIG_PROVE_RCU
> -- 
> 2.30.2
>
  
John Ogness Nov. 7, 2022, 7:23 p.m. UTC | #2
On 2022-11-07, "Paul E. McKenney" <paulmck@kernel.org> wrote:
>> Provide an implementation for debug_lockdep_rcu_enabled() when
>> CONFIG_DEBUG_LOCK_ALLOC is not enabled. This allows code to check
>> if rcu lockdep debugging is available without needing an extra
>> check if CONFIG_DEBUG_LOCK_ALLOC is enabled.
>> 
>> Signed-off-by: John Ogness <john.ogness@linutronix.de>
>
> If you would like me to take this one, please let me know.

Yes, it would be great if you would carry this in the rcu tree. This
printk series is already relying on the rcu tree for the NMI-safe
work. Thanks!

John
  
Petr Mladek Nov. 8, 2022, 10:29 a.m. UTC | #3
On Mon 2022-11-07 15:21:59, John Ogness wrote:
> Provide an implementation for debug_lockdep_rcu_enabled() when
> CONFIG_DEBUG_LOCK_ALLOC is not enabled. This allows code to check
> if rcu lockdep debugging is available without needing an extra
> check if CONFIG_DEBUG_LOCK_ALLOC is enabled.
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Reviewed-by: Petr Mladek <pmladek@suse.com>

Just a small nit below.

> ---
>  I also sent this patch to Paul as a suggestion. If it is not
>  acceptable, I just need to add an ifdef CONFIG_DEBUG_LOCK_ALLOC
>  into console_list_lock() of patch 21.
> 
>  include/linux/rcupdate.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 08605ce7379d..65178c40ab6f 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -340,6 +340,11 @@ static inline int rcu_read_lock_any_held(void)
>  	return !preemptible();
>  }
>  
> +static inline int debug_lockdep_rcu_enabled(void)
> +{
> +	return 0;
> +}
> +

It would make sense to move this up before rcu_read_lock_held()
definition so that the declarations and definitions are in
the same order in both #ifdef CONFIG_DEBUG_LOCK_ALLOC branches.

>  #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
>  
>  #ifdef CONFIG_PROVE_RCU

Best Regards,
PEtr
  
Paul E. McKenney Nov. 8, 2022, 7:27 p.m. UTC | #4
On Mon, Nov 07, 2022 at 08:29:01PM +0106, John Ogness wrote:
> On 2022-11-07, "Paul E. McKenney" <paulmck@kernel.org> wrote:
> >> Provide an implementation for debug_lockdep_rcu_enabled() when
> >> CONFIG_DEBUG_LOCK_ALLOC is not enabled. This allows code to check
> >> if rcu lockdep debugging is available without needing an extra
> >> check if CONFIG_DEBUG_LOCK_ALLOC is enabled.
> >> 
> >> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> >
> > If you would like me to take this one, please let me know.
> 
> Yes, it would be great if you would carry this in the rcu tree. This
> printk series is already relying on the rcu tree for the NMI-safe
> work. Thanks!

Very good, I have queued it.  It is currently on -rcu branch "dev",
but will find its way to srcunmisafe.2022.10.21a in the next day or two.

							Thanx, Paul
  
Paul E. McKenney Nov. 9, 2022, 5:49 p.m. UTC | #5
On Tue, Nov 08, 2022 at 11:27:24AM -0800, Paul E. McKenney wrote:
> On Mon, Nov 07, 2022 at 08:29:01PM +0106, John Ogness wrote:
> > On 2022-11-07, "Paul E. McKenney" <paulmck@kernel.org> wrote:
> > >> Provide an implementation for debug_lockdep_rcu_enabled() when
> > >> CONFIG_DEBUG_LOCK_ALLOC is not enabled. This allows code to check
> > >> if rcu lockdep debugging is available without needing an extra
> > >> check if CONFIG_DEBUG_LOCK_ALLOC is enabled.
> > >> 
> > >> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> > >
> > > If you would like me to take this one, please let me know.
> > 
> > Yes, it would be great if you would carry this in the rcu tree. This
> > printk series is already relying on the rcu tree for the NMI-safe
> > work. Thanks!
> 
> Very good, I have queued it.  It is currently on -rcu branch "dev",
> but will find its way to srcunmisafe.2022.10.21a in the next day or two.

But make that srcunmisafe.2022.11.09a, where it now resides.

The old srcunmisafe.2022.10.21a remains in its previous location, just
in case someone else is using it.  Branches are cheap...

							Thanx, Paul
  

Patch

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 08605ce7379d..65178c40ab6f 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -340,6 +340,11 @@  static inline int rcu_read_lock_any_held(void)
 	return !preemptible();
 }
 
+static inline int debug_lockdep_rcu_enabled(void)
+{
+	return 0;
+}
+
 #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
 
 #ifdef CONFIG_PROVE_RCU