Skip to contentSkip to conversation

mac80211: Add RTNL warning for workqueue

PATCH In review Ivo van Doorn 2 participants 4 messages Jun 24, 2008 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: Add RTNL warning for workqueue

The workqueue provided by mac80211 should not be used for scheduled tasks that acquire the RTNL lock. This could be done when the driver uses the function ieee80211_iterate_active_interfaces() within the scheduled work. Such behavior will end in locking dependencies problems when an interface is being removed.

This patch will add a notification about the RTNL locking and the mac80211 workqueue to prevent driver developers from blindly using it.

---

include/net/mac80211.h +5 -2
index 19f1e41..02c79e6 100644
@@ -738,8 +738,11 @@ enum ieee80211_hw_flags {
  * @conf: &struct ieee80211_conf, device configuration, don't use.
  *
  * @workqueue: single threaded workqueue available for driver use,
- *	allocated by mac80211 on registration and flushed on
- *	unregistration.
+ *	allocated by mac80211 on registration and flushed when an
+ *	interface is removed.
+ *	NOTICE: All work performed on this workqueue should NEVER
+ *	acquire the RTNL lock (i.e. Don't use the function
+ *	ieee80211_iterate_active_interfaces())
  *
  * @priv: pointer to private area that was allocated for driver use
  *	along with this structure.
maintainer
#1 lore raw
Quoted 18 lines · Ivo van Doorn

The workqueue provided by mac80211 should not be used for scheduled tasks that acquire the RTNL lock. This could be done when the driver uses the function ieee80211_iterate_active_interfaces() within the scheduled work. Such behavior will end in locking dependencies problems when an interface is being removed.

This patch will add a notification about the RTNL locking and the mac80211 workqueue to prevent driver developers from blindly using it.

---

include/net/mac80211.h +0 -0
index 19f1e41..02c79e6 100644

include/net/mac80211.h enum ieee80211_hw_flags { · line 742

Quoted 7 lines
include/net/mac80211.h +2 -2
@@ -738,8 +738,11 @@ enum ieee80211_hw_flags {
  * @conf: &struct ieee80211_conf, device configuration, don't use.
  *
  * @workqueue: single threaded workqueue available for driver use,
- *	allocated by mac80211 on registration and flushed on
- *	unregistration.
+ *	allocated by mac80211 on registration and flushed when an
+ *	interface is removed.

Interesting point. Should it be there or rather be moved down a bit so that it is actually only flushed when _all_ interfaces are stopped, i.e. before ->stop is invoked?

johannes

maintainer Acked-by
#2 lore raw
Quoted 11 lines · Johannes Berg
Quoted 10 lines · Ivo van Doorn

The workqueue provided by mac80211 should not be used for scheduled tasks that acquire the RTNL lock. This could be done when the driver uses the function ieee80211_iterate_active_interfaces() within the scheduled work. Such behavior will end in locking dependencies problems when an interface is being removed.

This patch will add a notification about the RTNL locking and the mac80211 workqueue to prevent driver developers from blindly using it.

Quoted 6 lines
Quoted 2 lines

Interesting point. Should it be there or rather be moved down a bit so that it is actually only flushed when _all_ interfaces are stopped, i.e. before ->stop is invoked?

Either way though, the patch is obviously correct and a follow-up patch can change the behaviour if we want that, so for this one:

johannes

#3 lore raw
In reply to Johannes Berg
Quoted 22 lines · Johannes Berg
Quoted 21 lines · Ivo van Doorn

The workqueue provided by mac80211 should not be used for scheduled tasks that acquire the RTNL lock. This could be done when the driver uses the function ieee80211_iterate_active_interfaces() within the scheduled work. Such behavior will end in locking dependencies problems when an interface is being removed.

This patch will add a notification about the RTNL locking and the mac80211 workqueue to prevent driver developers from blindly using it.

---

include/net/mac80211.h +0 -0
index 19f1e41..02c79e6 100644
@@ -738,8 +738,11 @@ enum ieee80211_hw_flags {
  * @conf: &struct ieee80211_conf, device configuration, don't use.
  *
  * @workqueue: single threaded workqueue available for driver use,
Quoted 8 lines

include/net/mac80211.h enum ieee80211_hw_flags { · line 742

Quoted 4 lines
include/net/mac80211.h +2 -2
- *	allocated by mac80211 on registration and flushed on
- *	unregistration.
+ *	allocated by mac80211 on registration and flushed when an
+ *	interface is removed.

Interesting point. Should it be there or rather be moved down a bit so that it is actually only flushed when _all_ interfaces are stopped, i.e. before ->stop is invoked?

Personally I think it makes most sense when all interfaces are gone, and thus either before or after ->stop(). But I am not sure which drivers currently rely on the current position of flush_workqueue().

Ivo