* [PATCH] mac80211: ath9k: Use RCU protection calling ieee80211_get_tx_rates [not found] ` <1370950926.8356.14.camel@jlt4.sipsolutions.net> @ 2013-06-11 17:13 ` Calvin Owens 2013-06-11 19:55 ` Johannes Berg 0 siblings, 1 reply; 7+ messages in thread From: Calvin Owens @ 2013-06-11 17:13 UTC (permalink / raw) To: Johannes Berg, Luis R. Rodriguez, John W. Linville, Felix Fietkau Cc: linux-wireless, linux-kernel, ath9k-devel, netdev, jcalvinowens Signed-off-by: Calvin Owens <jcalvinowens@gmail.com> --- drivers/net/wireless/ath/ath9k/xmit.c | 2 ++ drivers/net/wireless/mac80211_hwsim.c | 6 ++++++ include/net/mac80211.h | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 1c9b1ba..1d57015 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -142,8 +142,10 @@ static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno) static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ath_buf *bf) { + rcu_read_lock(); ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates, ARRAY_SIZE(bf->rates)); + rcu_read_unlock(); } static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index cb34c78..468a5a6 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -900,9 +900,11 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, hwsim_check_sta_magic(control->sta); if (rctbl) + rcu_read_lock(); ieee80211_get_tx_rates(txi->control.vif, control->sta, skb, txi->control.rates, ARRAY_SIZE(txi->control.rates)); + rcu_read_unlock(); txi->rate_driver_data[0] = channel; mac80211_hwsim_monitor_rx(hw, skb, channel); @@ -1008,9 +1010,11 @@ static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, if (rctbl) { struct ieee80211_tx_info *txi = IEEE80211_SKB_CB(skb); + rcu_read_lock(); ieee80211_get_tx_rates(txi->control.vif, NULL, skb, txi->control.rates, ARRAY_SIZE(txi->control.rates)); + rcu_read_unlock(); } mac80211_hwsim_monitor_rx(hw, skb, chan); @@ -1044,9 +1048,11 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, return; info = IEEE80211_SKB_CB(skb); if (rctbl) + rcu_read_lock(); ieee80211_get_tx_rates(vif, NULL, skb, info->control.rates, ARRAY_SIZE(info->control.rates)); + rcu_read_unlock(); txrate = ieee80211_get_tx_rate(hw, info); diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 885898a..df345c1 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -3175,7 +3175,8 @@ void ieee80211_sta_set_buffered(struct ieee80211_sta *sta, * * Call this function in a driver with per-packet rate selection support * to combine the rate info in the packet tx info with the most recent - * rate selection table for the station entry. + * rate selection table for the station entry. Must be called with RCU + * protection. * * @vif: &struct ieee80211_vif pointer from the add_interface callback. * @sta: the receiver station to which this packet is sent. -- 1.8.2.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mac80211: ath9k: Use RCU protection calling ieee80211_get_tx_rates 2013-06-11 17:13 ` [PATCH] mac80211: ath9k: Use RCU protection calling ieee80211_get_tx_rates Calvin Owens @ 2013-06-11 19:55 ` Johannes Berg [not found] ` <1370980523.8356.70.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org> 2013-06-12 7:56 ` Calvin Owens 0 siblings, 2 replies; 7+ messages in thread From: Johannes Berg @ 2013-06-11 19:55 UTC (permalink / raw) To: Calvin Owens Cc: Luis R. Rodriguez, John W. Linville, Felix Fietkau, linux-wireless, linux-kernel, ath9k-devel, netdev Now the subject should no longer say "mac80211:" :) However... given that ieee80211_get_tx_rates() actually *copies* the rates into the parameter, I guess it should do the rcu_read_lock() internally. I guess I wasn't paying attention previously. Felix? johannes ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1370980523.8356.70.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org>]
* Re: [PATCH] mac80211: ath9k: Use RCU protection calling ieee80211_get_tx_rates [not found] ` <1370980523.8356.70.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org> @ 2013-06-12 6:37 ` Kalle Valo 0 siblings, 0 replies; 7+ messages in thread From: Kalle Valo @ 2013-06-12 6:37 UTC (permalink / raw) To: Johannes Berg Cc: Calvin Owens, Luis R. Rodriguez, John W. Linville, Felix Fietkau, linux-wireless-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, ath9k-devel-xDcbHBWguxHbcTqmT+pZeQ, netdev-u79uwXL29TY76Z2rM5mHXA Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org> writes: > Now the subject should no longer say "mac80211:" :) It did have a change to mac80211.h as well, but IMHO that should be in a separate patch. -- Kalle Valo -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mac80211: ath9k: Use RCU protection calling ieee80211_get_tx_rates 2013-06-11 19:55 ` Johannes Berg [not found] ` <1370980523.8356.70.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org> @ 2013-06-12 7:56 ` Calvin Owens 2013-06-12 8:00 ` [PATCH] mac80211: Use RCU protection in ieee80211_get_tx_rates() Calvin Owens 1 sibling, 1 reply; 7+ messages in thread From: Calvin Owens @ 2013-06-12 7:56 UTC (permalink / raw) To: Johannes Berg Cc: Luis R. Rodriguez, John W. Linville, Felix Fietkau, linux-wireless, linux-kernel, ath9k-devel, netdev On Tuesday 06/11 at 21:55 +0200, Johannes Berg wrote: > Now the subject should no longer say "mac80211:" :) > > However... given that ieee80211_get_tx_rates() actually *copies* the > rates into the parameter, I guess it should do the rcu_read_lock() > internally. I guess I wasn't paying attention previously. Felix? I thought about that, but it seemed too simple, so I assumed I was missing something. ;) I'll send a patch per above. That makes the header file update unnecessary too. > johannes ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] mac80211: Use RCU protection in ieee80211_get_tx_rates() 2013-06-12 7:56 ` Calvin Owens @ 2013-06-12 8:00 ` Calvin Owens 2013-06-12 9:47 ` Felix Fietkau 0 siblings, 1 reply; 7+ messages in thread From: Calvin Owens @ 2013-06-12 8:00 UTC (permalink / raw) To: Johannes Berg Cc: Luis R. Rodriguez, John W. Linville, Felix Fietkau, linux-wireless, linux-kernel, ath9k-devel, netdev, jcalvinowens Copying the rate table should be done in an RCU read-side critical section. Signed-off-by: Calvin Owens <jcalvinowens@gmail.com> --- net/mac80211/rate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index d3f414f..090d9b0 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c @@ -538,6 +538,8 @@ static void rate_control_fill_sta_table(struct ieee80211_sta *sta, struct ieee80211_sta_rates *ratetbl = NULL; int i; + rcu_read_lock(); + if (sta && !info->control.skip_table) ratetbl = rcu_dereference(sta->rates); @@ -566,6 +568,8 @@ static void rate_control_fill_sta_table(struct ieee80211_sta *sta, if (rates[i].idx < 0 || !rates[i].count) break; } + + rcu_read_unlock(); } static void rate_control_apply_mask(struct ieee80211_sub_if_data *sdata, -- 1.8.2.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mac80211: Use RCU protection in ieee80211_get_tx_rates() 2013-06-12 8:00 ` [PATCH] mac80211: Use RCU protection in ieee80211_get_tx_rates() Calvin Owens @ 2013-06-12 9:47 ` Felix Fietkau 2013-06-13 15:27 ` Calvin Owens 0 siblings, 1 reply; 7+ messages in thread From: Felix Fietkau @ 2013-06-12 9:47 UTC (permalink / raw) To: Calvin Owens Cc: Johannes Berg, Luis R. Rodriguez, John W. Linville, linux-wireless, linux-kernel, ath9k-devel, netdev On 2013-06-12 10:00 AM, Calvin Owens wrote: > Copying the rate table should be done in an RCU read-side critical > section. I think this approach is wrong. The sta entry is also under RCU protection (no locking for read access in that part of the code. In a normal driver tx path, no extra rcu_read_lock/rcu_read_unlock is needed. Only if the driver does some scheduling outside of the tx function (which ath9k does), this RCU warning appears. How about this change instead: --- --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -1570,6 +1570,8 @@ void ath_txq_schedule(struct ath_softc * txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) return; + rcu_read_lock(); + ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list); last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list); @@ -1608,8 +1610,10 @@ void ath_txq_schedule(struct ath_softc * if (ac == last_ac || txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) - return; + break; } + + rcu_read_unlock(); } /***********/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mac80211: Use RCU protection in ieee80211_get_tx_rates() 2013-06-12 9:47 ` Felix Fietkau @ 2013-06-13 15:27 ` Calvin Owens 0 siblings, 0 replies; 7+ messages in thread From: Calvin Owens @ 2013-06-13 15:27 UTC (permalink / raw) To: Felix Fietkau Cc: Johannes Berg, Luis R. Rodriguez, John W. Linville, linux-wireless, linux-kernel, ath9k-devel, netdev, jcalvinowens On Wednesday 06/12 at 11:47 +0200, Felix Fietkau wrote: > On 2013-06-12 10:00 AM, Calvin Owens wrote: > > Copying the rate table should be done in an RCU read-side critical > > section. > I think this approach is wrong. The sta entry is also under RCU > protection (no locking for read access in that part of the code. > In a normal driver tx path, no extra rcu_read_lock/rcu_read_unlock is > needed. Only if the driver does some scheduling outside of the tx > function (which ath9k does), this RCU warning appears. > > How about this change instead: > --- > --- a/drivers/net/wireless/ath/ath9k/xmit.c > +++ b/drivers/net/wireless/ath/ath9k/xmit.c > @@ -1570,6 +1570,8 @@ void ath_txq_schedule(struct ath_softc * > txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) > return; > > + rcu_read_lock(); > + > ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list); > last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list); > > @@ -1608,8 +1610,10 @@ void ath_txq_schedule(struct ath_softc * > > if (ac == last_ac || > txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) > - return; > + break; > } > + > + rcu_read_unlock(); > } > > /***********/ > Yep, that stops the RCU warning for me. Tested-by: Calvin Owens <jcalvinowens@gmail.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-06-13 15:27 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20130609225120.GA2789@gmail.com> [not found] ` <20130610042959.GA1902@gmail.com> [not found] ` <1370950926.8356.14.camel@jlt4.sipsolutions.net> 2013-06-11 17:13 ` [PATCH] mac80211: ath9k: Use RCU protection calling ieee80211_get_tx_rates Calvin Owens 2013-06-11 19:55 ` Johannes Berg [not found] ` <1370980523.8356.70.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org> 2013-06-12 6:37 ` Kalle Valo 2013-06-12 7:56 ` Calvin Owens 2013-06-12 8:00 ` [PATCH] mac80211: Use RCU protection in ieee80211_get_tx_rates() Calvin Owens 2013-06-12 9:47 ` Felix Fietkau 2013-06-13 15:27 ` Calvin Owens
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).