linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] kernel: time: posix-timers: Pass lockdep expression to RCU lists
@ 2020-02-16  7:43 Amol Grover
  2020-02-17 15:40 ` [tip: timers/core] " tip-bot2 for Amol Grover
  2020-02-17 19:18 ` tip-bot2 for Amol Grover
  0 siblings, 2 replies; 3+ messages in thread
From: Amol Grover @ 2020-02-16  7:43 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-kernel, linux-kernel-mentees, Joel Fernandes,
	Madhuparna Bhowmik, Paul E . McKenney, Amol Grover

head is traversed using hlist_for_each_entry_rcu outside an
RCU read-side critical section but under the protection
of hash_lock.

Hence, add corresponding lockdep expression to silence false-positive
lockdep warnings, and harden RCU lists.

Add macro for the corresponding lockdep expression.

Signed-off-by: Amol Grover <frextrite@gmail.com>
---
 kernel/time/posix-timers.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 0ec5b7a1d769..2ccce00af177 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -50,6 +50,8 @@ static struct kmem_cache *posix_timers_cache;
 
 static DEFINE_HASHTABLE(posix_timers_hashtable, 9);
 static DEFINE_SPINLOCK(hash_lock);
+#define hash_lock_held() \
+	lockdep_is_held(&hash_lock)
 
 static const struct k_clock * const posix_clocks[];
 static const struct k_clock *clockid_to_kclock(const clockid_t id);
@@ -120,7 +122,7 @@ static struct k_itimer *__posix_timers_find(struct hlist_head *head,
 {
 	struct k_itimer *timer;
 
-	hlist_for_each_entry_rcu(timer, head, t_hash) {
+	hlist_for_each_entry_rcu(timer, head, t_hash, hash_lock_held()) {
 		if ((timer->it_signal == sig) && (timer->it_id == id))
 			return timer;
 	}
-- 
2.24.1


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

* [tip: timers/core] posix-timers: Pass lockdep expression to RCU lists
  2020-02-16  7:43 [PATCH RESEND] kernel: time: posix-timers: Pass lockdep expression to RCU lists Amol Grover
@ 2020-02-17 15:40 ` tip-bot2 for Amol Grover
  2020-02-17 19:18 ` tip-bot2 for Amol Grover
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Amol Grover @ 2020-02-17 15:40 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Amol Grover, Thomas Gleixner, x86, LKML

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     9ea9c60fc23c35f865725ab390ca4308de919bb0
Gitweb:        https://git.kernel.org/tip/9ea9c60fc23c35f865725ab390ca4308de919bb0
Author:        Amol Grover <frextrite@gmail.com>
AuthorDate:    Sun, 16 Feb 2020 13:13:30 +05:30
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 17 Feb 2020 16:39:28 +01:00

posix-timers: Pass lockdep expression to RCU lists

head is traversed using hlist_for_each_entry_rcu outside an RCU read-side
critical section but under the protection of hash_lock.

Hence, add corresponding lockdep expression to silence false-positive
lockdep warnings, and harden RCU lists.

[ tglx: Removed the macro and put the condition right where it's used ]

Signed-off-by: Amol Grover <frextrite@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200216074330.GA14025@workstation-portable

---
 kernel/time/posix-timers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ff0eb30..07709ac 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -121,7 +121,8 @@ static struct k_itimer *__posix_timers_find(struct hlist_head *head,
 {
 	struct k_itimer *timer;
 
-	hlist_for_each_entry_rcu(timer, head, t_hash) {
+	hlist_for_each_entry_rcu(timer, head, t_hash,
+				 lockdep_is_held(&hash_lock)) {
 		if ((timer->it_signal == sig) && (timer->it_id == id))
 			return timer;
 	}

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

* [tip: timers/core] posix-timers: Pass lockdep expression to RCU lists
  2020-02-16  7:43 [PATCH RESEND] kernel: time: posix-timers: Pass lockdep expression to RCU lists Amol Grover
  2020-02-17 15:40 ` [tip: timers/core] " tip-bot2 for Amol Grover
@ 2020-02-17 19:18 ` tip-bot2 for Amol Grover
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Amol Grover @ 2020-02-17 19:18 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Amol Grover, Thomas Gleixner, x86, LKML

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     5fb1c2a5bbf79ccca8d17cf97f66085be5808027
Gitweb:        https://git.kernel.org/tip/5fb1c2a5bbf79ccca8d17cf97f66085be5808027
Author:        Amol Grover <frextrite@gmail.com>
AuthorDate:    Sun, 16 Feb 2020 13:13:30 +05:30
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 17 Feb 2020 20:12:19 +01:00

posix-timers: Pass lockdep expression to RCU lists

head is traversed using hlist_for_each_entry_rcu outside an RCU read-side
critical section but under the protection of hash_lock.

Hence, add corresponding lockdep expression to silence false-positive
lockdep warnings, and harden RCU lists.

[ tglx: Removed the macro and put the condition right where it's used ]

Signed-off-by: Amol Grover <frextrite@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200216074330.GA14025@workstation-portable


---
 kernel/time/posix-timers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ff0eb30..07709ac 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -121,7 +121,8 @@ static struct k_itimer *__posix_timers_find(struct hlist_head *head,
 {
 	struct k_itimer *timer;
 
-	hlist_for_each_entry_rcu(timer, head, t_hash) {
+	hlist_for_each_entry_rcu(timer, head, t_hash,
+				 lockdep_is_held(&hash_lock)) {
 		if ((timer->it_signal == sig) && (timer->it_id == id))
 			return timer;
 	}

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

end of thread, other threads:[~2020-02-17 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-16  7:43 [PATCH RESEND] kernel: time: posix-timers: Pass lockdep expression to RCU lists Amol Grover
2020-02-17 15:40 ` [tip: timers/core] " tip-bot2 for Amol Grover
2020-02-17 19:18 ` tip-bot2 for Amol Grover

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