rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cgroup.c: Use built-in RCU list checking
@ 2020-01-18  3:10 madhuparnabhowmik10
  2020-01-29 14:22 ` Michal Koutný
  2020-02-12 22:12 ` Tejun Heo
  0 siblings, 2 replies; 4+ messages in thread
From: madhuparnabhowmik10 @ 2020-01-18  3:10 UTC (permalink / raw)
  To: tj, lizefan
  Cc: cgroups, linux-kernel, joel, rcu, frextrite, Madhuparna Bhowmik

From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>

list_for_each_entry_rcu has built-in RCU and lock checking.
Pass cond argument to list_for_each_entry_rcu() to silence
false lockdep warning when  CONFIG_PROVE_RCU_LIST is enabled
by default.

Even though the function css_next_child() already checks if
cgroup_mutex or rcu_read_lock() is held using
cgroup_assert_mutex_or_rcu_locked(), there is a need to pass
cond to list_for_each_entry_rcu() to avoid false positive
lockdep warning.

Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
---
 kernel/cgroup/cgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 735af8f15f95..c2959764ad95 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4152,7 +4152,8 @@ struct cgroup_subsys_state *css_next_child(struct cgroup_subsys_state *pos,
 	} else if (likely(!(pos->flags & CSS_RELEASED))) {
 		next = list_entry_rcu(pos->sibling.next, struct cgroup_subsys_state, sibling);
 	} else {
-		list_for_each_entry_rcu(next, &parent->children, sibling)
+		list_for_each_entry_rcu(next, &parent->children, sibling,
+					lockdep_is_held(&cgroup_mutex))
 			if (next->serial_nr > pos->serial_nr)
 				break;
 	}
-- 
2.17.1


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

* Re: [PATCH] cgroup.c: Use built-in RCU list checking
  2020-01-18  3:10 [PATCH] cgroup.c: Use built-in RCU list checking madhuparnabhowmik10
@ 2020-01-29 14:22 ` Michal Koutný
  2020-01-29 16:07   ` Madhuparna Bhowmik
  2020-02-12 22:12 ` Tejun Heo
  1 sibling, 1 reply; 4+ messages in thread
From: Michal Koutný @ 2020-01-29 14:22 UTC (permalink / raw)
  To: madhuparnabhowmik10
  Cc: tj, lizefan, cgroups, linux-kernel, joel, rcu, frextrite

Hello.

On Sat, Jan 18, 2020 at 08:40:51AM +0530, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> list_for_each_entry_rcu has built-in RCU and lock checking.
> Pass cond argument to list_for_each_entry_rcu() to silence
> false lockdep warning when  CONFIG_PROVE_RCU_LIST is enabled
> by default.
I assume if you've seen the RCU warning, you haven't seen the warning
from cgroup_assert_mutex_or_rcu_locked() above. 

The patch makes sense to me from the consistency POV.

Acked-by: Michal Koutný <mkoutny@suse.com>

Michal

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

* Re: [PATCH] cgroup.c: Use built-in RCU list checking
  2020-01-29 14:22 ` Michal Koutný
@ 2020-01-29 16:07   ` Madhuparna Bhowmik
  0 siblings, 0 replies; 4+ messages in thread
From: Madhuparna Bhowmik @ 2020-01-29 16:07 UTC (permalink / raw)
  To: Michal Koutný
  Cc: madhuparnabhowmik10, tj, lizefan, cgroups, linux-kernel, joel,
	rcu, frextrite

On Wed, Jan 29, 2020 at 03:22:55PM +0100, Michal Koutný wrote:
> Hello.
> 
> On Sat, Jan 18, 2020 at 08:40:51AM +0530, madhuparnabhowmik10@gmail.com wrote:
> > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > 
> > list_for_each_entry_rcu has built-in RCU and lock checking.
> > Pass cond argument to list_for_each_entry_rcu() to silence
> > false lockdep warning when  CONFIG_PROVE_RCU_LIST is enabled
> > by default.
> I assume if you've seen the RCU warning, you haven't seen the warning
> from cgroup_assert_mutex_or_rcu_locked() above. 
>
No, I haven't seen any warning from cgroup_assert_mutex_or_rcu_locked(),
I am just doing the conversions to prevent any false lockdep warnings
because of CONFIG_PROVE_RCU_LIST in the future.

> The patch makes sense to me from the consistency POV.
> 
Thank you,
Madhuparna

> Acked-by: Michal Koutný <mkoutny@suse.com>
> 
> Michal

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

* Re: [PATCH] cgroup.c: Use built-in RCU list checking
  2020-01-18  3:10 [PATCH] cgroup.c: Use built-in RCU list checking madhuparnabhowmik10
  2020-01-29 14:22 ` Michal Koutný
@ 2020-02-12 22:12 ` Tejun Heo
  1 sibling, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2020-02-12 22:12 UTC (permalink / raw)
  To: madhuparnabhowmik10; +Cc: lizefan, cgroups, linux-kernel, joel, rcu, frextrite

On Sat, Jan 18, 2020 at 08:40:51AM +0530, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> list_for_each_entry_rcu has built-in RCU and lock checking.
> Pass cond argument to list_for_each_entry_rcu() to silence
> false lockdep warning when  CONFIG_PROVE_RCU_LIST is enabled
> by default.
> 
> Even though the function css_next_child() already checks if
> cgroup_mutex or rcu_read_lock() is held using
> cgroup_assert_mutex_or_rcu_locked(), there is a need to pass
> cond to list_for_each_entry_rcu() to avoid false positive
> lockdep warning.
> 
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>

Applied to cgroup/for-5.7.

Thanks.

-- 
tejun

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

end of thread, other threads:[~2020-02-12 22:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-18  3:10 [PATCH] cgroup.c: Use built-in RCU list checking madhuparnabhowmik10
2020-01-29 14:22 ` Michal Koutný
2020-01-29 16:07   ` Madhuparna Bhowmik
2020-02-12 22:12 ` Tejun Heo

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