All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rcu: Force inlining of rcu_read_lock()
@ 2019-05-21 20:48 Waiman Long
  2019-05-22 18:18 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Waiman Long @ 2019-05-21 20:48 UTC (permalink / raw)
  To: Paul E. McKenney, Josh Triplett, Steven Rostedt,
	Mathieu Desnoyers, Lai Jiangshan, Joel Fernandes
  Cc: rcu, linux-kernel, Waiman Long

It is found that when debugging options are turned on, the
rcu_read_lock() function may not be inlined at all. That will make
it harder to debug RCU related problem as the print_lock() function
in lockdep will print "rcu_read_lock()" instead of the caller of
rcu_read_lock() function. For example,

[   10.579995] =============================
[   10.584033] WARNING: suspicious RCU usage
[   10.588074] 4.18.0.memcg_v2+ #1 Not tainted
[   10.593162] -----------------------------
[   10.597203] include/linux/rcupdate.h:281 Illegal context switch in
RCU read-side critical section!
[   10.606220]
[   10.606220] other info that might help us debug this:
[   10.606220]
[   10.614280]
[   10.614280] rcu_scheduler_active = 2, debug_locks = 1
[   10.620853] 3 locks held by systemd/1:
[   10.624632]  #0: (____ptrval____) (&type->i_mutex_dir_key#5){.+.+}, at: lookup_slow+0x42/0x70
[   10.633232]  #1: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
[   10.640954]  #2: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70

To make sure that the proper caller of rcu_read_lock() is shown, we
have to force the inlining of the rcu_read_lock() function.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 include/linux/rcupdate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 922bb6848813..44f80aced02b 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -588,7 +588,7 @@ static inline void rcu_preempt_sleep_check(void) { }
  * read-side critical sections may be preempted and they may also block, but
  * only when acquiring spinlocks that are subject to priority inheritance.
  */
-static inline void rcu_read_lock(void)
+static __always_inline void rcu_read_lock(void)
 {
 	__rcu_read_lock();
 	__acquire(RCU);
-- 
2.18.1


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

* Re: [PATCH] rcu: Force inlining of rcu_read_lock()
  2019-05-21 20:48 [PATCH] rcu: Force inlining of rcu_read_lock() Waiman Long
@ 2019-05-22 18:18 ` Paul E. McKenney
  2019-05-22 18:41   ` Waiman Long
  0 siblings, 1 reply; 3+ messages in thread
From: Paul E. McKenney @ 2019-05-22 18:18 UTC (permalink / raw)
  To: Waiman Long
  Cc: Josh Triplett, Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan,
	Joel Fernandes, rcu, linux-kernel

On Tue, May 21, 2019 at 04:48:43PM -0400, Waiman Long wrote:
> It is found that when debugging options are turned on, the
> rcu_read_lock() function may not be inlined at all. That will make
> it harder to debug RCU related problem as the print_lock() function
> in lockdep will print "rcu_read_lock()" instead of the caller of
> rcu_read_lock() function. For example,
> 
> [   10.579995] =============================
> [   10.584033] WARNING: suspicious RCU usage
> [   10.588074] 4.18.0.memcg_v2+ #1 Not tainted
> [   10.593162] -----------------------------
> [   10.597203] include/linux/rcupdate.h:281 Illegal context switch in
> RCU read-side critical section!
> [   10.606220]
> [   10.606220] other info that might help us debug this:
> [   10.606220]
> [   10.614280]
> [   10.614280] rcu_scheduler_active = 2, debug_locks = 1
> [   10.620853] 3 locks held by systemd/1:
> [   10.624632]  #0: (____ptrval____) (&type->i_mutex_dir_key#5){.+.+}, at: lookup_slow+0x42/0x70
> [   10.633232]  #1: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
> [   10.640954]  #2: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
> 
> To make sure that the proper caller of rcu_read_lock() is shown, we
> have to force the inlining of the rcu_read_lock() function.
> 
> Signed-off-by: Waiman Long <longman@redhat.com>

Good point, queued!  I reworked the commit log as follows, is this OK?

							Thanx, Paul

------------------------------------------------------------------------

commit c006ffd7b607f8ee216f6a7a6d845b9514881e92
Author: Waiman Long <longman@redhat.com>
Date:   Tue May 21 16:48:43 2019 -0400

    rcu: Force inlining of rcu_read_lock()
    
    When debugging options are turned on, the rcu_read_lock() function
    might not be inlined. This results in lockdep's print_lock() function
    printing "rcu_read_lock+0x0/0x70" instead of rcu_read_lock()'s caller.
    For example:
    
    [   10.579995] =============================
    [   10.584033] WARNING: suspicious RCU usage
    [   10.588074] 4.18.0.memcg_v2+ #1 Not tainted
    [   10.593162] -----------------------------
    [   10.597203] include/linux/rcupdate.h:281 Illegal context switch in
    RCU read-side critical section!
    [   10.606220]
    [   10.606220] other info that might help us debug this:
    [   10.606220]
    [   10.614280]
    [   10.614280] rcu_scheduler_active = 2, debug_locks = 1
    [   10.620853] 3 locks held by systemd/1:
    [   10.624632]  #0: (____ptrval____) (&type->i_mutex_dir_key#5){.+.+}, at: lookup_slow+0x42/0x70
    [   10.633232]  #1: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
    [   10.640954]  #2: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
    
    These "rcu_read_lock+0x0/0x70" strings are not providing any useful
    information.  This commit therefore forces inlining of the rcu_read_lock()
    function so that rcu_read_lock()'s caller is instead shown.
    
    Signed-off-by: Waiman Long <longman@redhat.com>
    Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 534c05d529b5..a8ed624da555 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -588,7 +588,7 @@ static inline void rcu_preempt_sleep_check(void) { }
  * read-side critical sections may be preempted and they may also block, but
  * only when acquiring spinlocks that are subject to priority inheritance.
  */
-static inline void rcu_read_lock(void)
+static __always_inline void rcu_read_lock(void)
 {
 	__rcu_read_lock();
 	__acquire(RCU);


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

* Re: [PATCH] rcu: Force inlining of rcu_read_lock()
  2019-05-22 18:18 ` Paul E. McKenney
@ 2019-05-22 18:41   ` Waiman Long
  0 siblings, 0 replies; 3+ messages in thread
From: Waiman Long @ 2019-05-22 18:41 UTC (permalink / raw)
  To: paulmck
  Cc: Josh Triplett, Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan,
	Joel Fernandes, rcu, linux-kernel

On 5/22/19 2:18 PM, Paul E. McKenney wrote:
> On Tue, May 21, 2019 at 04:48:43PM -0400, Waiman Long wrote:
>> It is found that when debugging options are turned on, the
>> rcu_read_lock() function may not be inlined at all. That will make
>> it harder to debug RCU related problem as the print_lock() function
>> in lockdep will print "rcu_read_lock()" instead of the caller of
>> rcu_read_lock() function. For example,
>>
>> [   10.579995] =============================
>> [   10.584033] WARNING: suspicious RCU usage
>> [   10.588074] 4.18.0.memcg_v2+ #1 Not tainted
>> [   10.593162] -----------------------------
>> [   10.597203] include/linux/rcupdate.h:281 Illegal context switch in
>> RCU read-side critical section!
>> [   10.606220]
>> [   10.606220] other info that might help us debug this:
>> [   10.606220]
>> [   10.614280]
>> [   10.614280] rcu_scheduler_active = 2, debug_locks = 1
>> [   10.620853] 3 locks held by systemd/1:
>> [   10.624632]  #0: (____ptrval____) (&type->i_mutex_dir_key#5){.+.+}, at: lookup_slow+0x42/0x70
>> [   10.633232]  #1: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
>> [   10.640954]  #2: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
>>
>> To make sure that the proper caller of rcu_read_lock() is shown, we
>> have to force the inlining of the rcu_read_lock() function.
>>
>> Signed-off-by: Waiman Long <longman@redhat.com>
> Good point, queued!  I reworked the commit log as follows, is this OK?
>
> 							Thanx, Paul
>
> ------------------------------------------------------------------------
>
> commit c006ffd7b607f8ee216f6a7a6d845b9514881e92
> Author: Waiman Long <longman@redhat.com>
> Date:   Tue May 21 16:48:43 2019 -0400
>
>     rcu: Force inlining of rcu_read_lock()
>     
>     When debugging options are turned on, the rcu_read_lock() function
>     might not be inlined. This results in lockdep's print_lock() function
>     printing "rcu_read_lock+0x0/0x70" instead of rcu_read_lock()'s caller.
>     For example:
>     
>     [   10.579995] =============================
>     [   10.584033] WARNING: suspicious RCU usage
>     [   10.588074] 4.18.0.memcg_v2+ #1 Not tainted
>     [   10.593162] -----------------------------
>     [   10.597203] include/linux/rcupdate.h:281 Illegal context switch in
>     RCU read-side critical section!
>     [   10.606220]
>     [   10.606220] other info that might help us debug this:
>     [   10.606220]
>     [   10.614280]
>     [   10.614280] rcu_scheduler_active = 2, debug_locks = 1
>     [   10.620853] 3 locks held by systemd/1:
>     [   10.624632]  #0: (____ptrval____) (&type->i_mutex_dir_key#5){.+.+}, at: lookup_slow+0x42/0x70
>     [   10.633232]  #1: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
>     [   10.640954]  #2: (____ptrval____) (rcu_read_lock){....}, at: rcu_read_lock+0x0/0x70
>     
>     These "rcu_read_lock+0x0/0x70" strings are not providing any useful
>     information.  This commit therefore forces inlining of the rcu_read_lock()
>     function so that rcu_read_lock()'s caller is instead shown.
>     

Your modification make sense to me.

Thanks,
Longman


>     Signed-off-by: Waiman Long <longman@redhat.com>
>     Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
>
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 534c05d529b5..a8ed624da555 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -588,7 +588,7 @@ static inline void rcu_preempt_sleep_check(void) { }
>   * read-side critical sections may be preempted and they may also block, but
>   * only when acquiring spinlocks that are subject to priority inheritance.
>   */
> -static inline void rcu_read_lock(void)
> +static __always_inline void rcu_read_lock(void)
>  {
>  	__rcu_read_lock();
>  	__acquire(RCU);
>


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

end of thread, other threads:[~2019-05-22 18:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 20:48 [PATCH] rcu: Force inlining of rcu_read_lock() Waiman Long
2019-05-22 18:18 ` Paul E. McKenney
2019-05-22 18:41   ` Waiman Long

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.