Skip to contentSkip to conversation

mac80211: Fix possible race between sta_unblock and network softirq

RFC In review Helmut Schaa 2 participants 5 messages Jan 16, 2012 mac80211

lore
Share & tools
lore
#0 lore raw

RFC 1/1 mac80211: Fix possible race between sta_unblock and network softirq

---

I'm currently writing some code for rt2800 that requires the driver to stop sending to a specific station for a short period of time (until all AMPDUs are finished to work around a hw issue that affects rate sampling with minstrel_ht). I decided to give ieee80211_sta_block_awake a try, however, the machine sometimes locked up while running some performance tests but due to a hw watchdog I wasn't able to get any sort of backtrace :(

So, while doing some review of the ieee80211_sta_block_awake I came across this and wondered if softirqs should be disabled when delivering the buffered frames in sta_unblock.

Using this patch I cannot reproduce the lockup anymore.

So, is there any special reason this single code path in sta_unblock doesn't disable softirqs?

Thanks,
Helmut

 net/mac80211/sta_info.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
net/mac80211/sta_info.c +4 -2
index 24d321f..5b4ab21 100644
@@ -238,9 +238,11 @@ static void sta_unblock(struct work_struct *wk)
 	if (sta->dead)
 		return;
 
-	if (!test_sta_flag(sta, WLAN_STA_PS_STA))
+	if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
+		local_bh_disable();
 		ieee80211_sta_ps_deliver_wakeup(sta);
-	else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) {
+		local_bh_enable();
+	} else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) {
 		clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
 
 		local_bh_disable();
Signature · 1 line
1.7.7
maintainer
#1 lore raw
Quoted 11 lines · Helmut Schaa

---

I'm currently writing some code for rt2800 that requires the driver to stop sending to a specific station for a short period of time (until all AMPDUs are finished to work around a hw issue that affects rate sampling with minstrel_ht). I decided to give ieee80211_sta_block_awake a try, however, the machine sometimes locked up while running some performance tests but due to a hw watchdog I wasn't able to get any sort of backtrace :(

Quoted 8 lines

So, while doing some review of the ieee80211_sta_block_awake I came across this and wondered if softirqs should be disabled when delivering the buffered frames in sta_unblock.

Using this patch I cannot reproduce the lockup anymore.

So, is there any special reason this single code path in sta_unblock doesn't disable softirqs?

This seems right -- not sure where the lockup would be though.

johannes

Quoted 24 lines

Thanks,
Helmut

 net/mac80211/sta_info.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
net/mac80211/sta_info.c +4 -2
index 24d321f..5b4ab21 100644
@@ -238,9 +238,11 @@ static void sta_unblock(struct work_struct *wk)
 	if (sta->dead)
 		return;
 
-	if (!test_sta_flag(sta, WLAN_STA_PS_STA))
+	if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
+		local_bh_disable();
 		ieee80211_sta_ps_deliver_wakeup(sta);
-	else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) {
+		local_bh_enable();
+	} else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) {
 		clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
 
 		local_bh_disable();
#2 lore raw

Am Montag, 16. Januar 2012, 17:51:33 schrieb Johannes Berg:

Quoted 16 lines · Helmut Schaa
Quoted 15 lines

---

I'm currently writing some code for rt2800 that requires the driver to stop sending to a specific station for a short period of time (until all AMPDUs are finished to work around a hw issue that affects rate sampling with minstrel_ht). I decided to give ieee80211_sta_block_awake a try, however, the machine sometimes locked up while running some performance tests but due to a hw watchdog I wasn't able to get any sort of backtrace :(

So, while doing some review of the ieee80211_sta_block_awake I came across this and wondered if softirqs should be disabled when delivering the buffered frames in sta_unblock.

Quoted 6 lines
Quoted 4 lines

Using this patch I cannot reproduce the lockup anymore.

So, is there any special reason this single code path in sta_unblock doesn't disable softirqs?

This seems right

The patch or the current approach without disable_bh?

Quoted 1 line

-- not sure where the lockup would be though.

Not sure either :( unfortunately I cannot disable the hw watchdog (and that has a timeout of only 2 seconds). Maybe I can reproduce it with a regular rt2800 PCI card ...

Helmut

maintainer
#3 lore raw
Quoted 17 lines · Helmut Schaa

Am Montag, 16. Januar 2012, 17:51:33 schrieb Johannes Berg:

Quoted 16 lines · Helmut Schaa
Quoted 15 lines

---

I'm currently writing some code for rt2800 that requires the driver to stop sending to a specific station for a short period of time (until all AMPDUs are finished to work around a hw issue that affects rate sampling with minstrel_ht). I decided to give ieee80211_sta_block_awake a try, however, the machine sometimes locked up while running some performance tests but due to a hw watchdog I wasn't able to get any sort of backtrace :(

So, while doing some review of the ieee80211_sta_block_awake I came across this and wondered if softirqs should be disabled when delivering the buffered frames in sta_unblock.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Using this patch I cannot reproduce the lockup anymore.

So, is there any special reason this single code path in sta_unblock doesn't disable softirqs?

This seems right

The patch or the current approach without disable_bh?

The patch.

johannes

#4 lore raw

Am Montag, 16. Januar 2012, 20:25:14 schrieb Johannes Berg:

Quoted 20 lines · Helmut Schaa
Quoted 19 lines

Am Montag, 16. Januar 2012, 17:51:33 schrieb Johannes Berg:

Quoted 18 lines · Helmut Schaa
Quoted 17 lines

---

I'm currently writing some code for rt2800 that requires the driver to stop sending to a specific station for a short period of time (until all AMPDUs are finished to work around a hw issue that affects rate sampling with minstrel_ht). I decided to give ieee80211_sta_block_awake a try, however, the machine sometimes locked up while running some performance tests but due to a hw watchdog I wasn't able to get any sort of backtrace :(

So, while doing some review of the ieee80211_sta_block_awake I came across this and wondered if softirqs should be disabled when delivering the buffered frames in sta_unblock.

Using this patch I cannot reproduce the lockup anymore.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

So, is there any special reason this single code path in sta_unblock doesn't disable softirqs?

This seems right

The patch or the current approach without disable_bh?

The patch.

Thanks :)