mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH] Cleanup: preempt notifiers: disallow hlist_del within unsafe iteration
@ 2015-05-17 16:53 Mathieu Desnoyers
  2015-06-19 18:00 ` [tip:sched/core] sched/preempt: Fix preempt notifiers documentation about hlist_del() " tip-bot for Mathieu Desnoyers
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Desnoyers @ 2015-05-17 16:53 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Mathieu Desnoyers, Peter Zijlstra, Avi Kivity

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.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Ingo Molnar <mingo@redhat.com>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Avi Kivity <avi@qumranet.com>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 57bd333..9edefec 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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)
 {
-- 
2.1.4


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

* [tip:sched/core] sched/preempt: Fix preempt notifiers documentation about hlist_del() within unsafe iteration
  2015-05-17 16:53 [RFC PATCH] Cleanup: preempt notifiers: disallow hlist_del within unsafe iteration Mathieu Desnoyers
@ 2015-06-19 18:00 ` tip-bot for Mathieu Desnoyers
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Mathieu Desnoyers @ 2015-06-19 18:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, akpm, torvalds, tglx, bp, mathieu.desnoyers, hpa,
	linux-kernel, mingo

Commit-ID:  d84525a845cc2617d638349f8756a9fec9ac8113
Gitweb:     http://git.kernel.org/tip/d84525a845cc2617d638349f8756a9fec9ac8113
Author:     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
AuthorDate: Sun, 17 May 2015 12:53:10 -0400
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1431881590-1456-1-git-send-email-mathieu.desnoyers@efficios.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index af0a5a6..bdb7aa6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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/

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-17 16:53 [RFC PATCH] Cleanup: preempt notifiers: disallow hlist_del within unsafe iteration Mathieu Desnoyers
2015-06-19 18:00 ` [tip:sched/core] sched/preempt: Fix preempt notifiers documentation about hlist_del() " tip-bot for Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome