Skip to contentSkip to conversation

Cleanup: preempt notifiers: disallow hlist_del within unsafe iteration

RFC PATCH New Mathieu Desnoyers 2 participants 2 messages May 17, 2015 – Jun 19, 2015 Scheduler

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Cleanup: preempt notifiers: disallow hlist_del within unsafe iteration

preempt_notifier_unregister() documents:

"This is safe to call from within a preemption notifier."

However, both fire_sched_in_preempt_notifiers() and fire_sched_out_preempt_notifiers() are using hlist_for_each_entry(), which is not safe against entry removal during iteration.

Inspection of the kvm code does not reveal any use of preempt_notifier_unregister() within the preempt notifiers.

Therefore, fix the bogus comment.

CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Avi Kivity <[email protected]>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
index 57bd333..9edefec 100644
@@ -2119,7 +2119,7 @@ EXPORT_SYMBOL_GPL(preempt_notifier_register);
  * preempt_notifier_unregister - no longer interested in preemption notifications
  * @notifier: notifier struct to unregister
  *
- * This is safe to call from within a preemption notifier.
+ * This is *not* safe to call from within a preemption notifier.
  */
 void preempt_notifier_unregister(struct preempt_notifier *notifier)
 {
Signature · 1 line
2.1.4
#1 lore raw

[tip:sched/core] sched/preempt: Fix preempt notifiers documentation about hlist_del() within unsafe iteration

sched/preempt: Fix preempt notifiers documentation about hlist_del() within unsafe iteration
Commit-ID:  d84525a845cc2617d638349f8756a9fec9ac8113
Gitweb:     http://git.kernel.org/tip/d84525a845cc2617d638349f8756a9fec9ac8113
Author:     Mathieu Desnoyers <[email protected]>
AuthorDate: Sun, 17 May 2015 12:53:10 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 19 Jun 2015 10:06:44 +0200

sched/preempt: Fix preempt notifiers documentation about hlist_del() within unsafe iteration

preempt_notifier_unregister() documents:

"This is safe to call from within a preemption notifier."

However, both fire_sched_in_preempt_notifiers() and fire_sched_out_preempt_notifiers() are using hlist_for_each_entry(), which is not safe against entry removal during iteration.

Inspection of the KVM code does not reveal any use of preempt_notifier_unregister() within the preempt notifiers.

Therefore, fix the comment.

---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
index af0a5a6..bdb7aa6 100644
@@ -2165,7 +2165,7 @@ EXPORT_SYMBOL_GPL(preempt_notifier_register);
  * preempt_notifier_unregister - no longer interested in preemption notifications
  * @notifier: notifier struct to unregister
  *
- * This is safe to call from within a preemption notifier.
+ * This is *not* safe to call from within a preemption notifier.
  */
 void preempt_notifier_unregister(struct preempt_notifier *notifier)
 {

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/