Commit f2af2df8 authored by Felix Fietkau's avatar Felix Fietkau Committed by Johannes Berg

mac80211: calculate hash for fq without holding fq->lock in itxq enqueue

Reduces lock contention on enqueue/dequeue of iTXQ packets
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Acked-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent ef618b1b
...@@ -107,21 +107,23 @@ static struct sk_buff *fq_tin_dequeue(struct fq *fq, ...@@ -107,21 +107,23 @@ static struct sk_buff *fq_tin_dequeue(struct fq *fq,
return skb; return skb;
} }
static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb)
{
u32 hash = skb_get_hash_perturb(skb, fq->perturbation);
return reciprocal_scale(hash, fq->flows_cnt);
}
static struct fq_flow *fq_flow_classify(struct fq *fq, static struct fq_flow *fq_flow_classify(struct fq *fq,
struct fq_tin *tin, struct fq_tin *tin, u32 idx,
struct sk_buff *skb, struct sk_buff *skb,
fq_flow_get_default_t get_default_func) fq_flow_get_default_t get_default_func)
{ {
struct fq_flow *flow; struct fq_flow *flow;
u32 hash;
u32 idx;
lockdep_assert_held(&fq->lock); lockdep_assert_held(&fq->lock);
hash = skb_get_hash_perturb(skb, fq->perturbation);
idx = reciprocal_scale(hash, fq->flows_cnt);
flow = &fq->flows[idx]; flow = &fq->flows[idx];
if (flow->tin && flow->tin != tin) { if (flow->tin && flow->tin != tin) {
flow = get_default_func(fq, tin, idx, skb); flow = get_default_func(fq, tin, idx, skb);
tin->collisions++; tin->collisions++;
...@@ -153,7 +155,7 @@ static void fq_recalc_backlog(struct fq *fq, ...@@ -153,7 +155,7 @@ static void fq_recalc_backlog(struct fq *fq,
} }
static void fq_tin_enqueue(struct fq *fq, static void fq_tin_enqueue(struct fq *fq,
struct fq_tin *tin, struct fq_tin *tin, u32 idx,
struct sk_buff *skb, struct sk_buff *skb,
fq_skb_free_t free_func, fq_skb_free_t free_func,
fq_flow_get_default_t get_default_func) fq_flow_get_default_t get_default_func)
...@@ -163,7 +165,7 @@ static void fq_tin_enqueue(struct fq *fq, ...@@ -163,7 +165,7 @@ static void fq_tin_enqueue(struct fq *fq,
lockdep_assert_held(&fq->lock); lockdep_assert_held(&fq->lock);
flow = fq_flow_classify(fq, tin, skb, get_default_func); flow = fq_flow_classify(fq, tin, idx, skb, get_default_func);
flow->tin = tin; flow->tin = tin;
flow->backlog += skb->len; flow->backlog += skb->len;
......
...@@ -1399,11 +1399,15 @@ static void ieee80211_txq_enqueue(struct ieee80211_local *local, ...@@ -1399,11 +1399,15 @@ static void ieee80211_txq_enqueue(struct ieee80211_local *local,
{ {
struct fq *fq = &local->fq; struct fq *fq = &local->fq;
struct fq_tin *tin = &txqi->tin; struct fq_tin *tin = &txqi->tin;
u32 flow_idx = fq_flow_idx(fq, skb);
ieee80211_set_skb_enqueue_time(skb); ieee80211_set_skb_enqueue_time(skb);
fq_tin_enqueue(fq, tin, skb,
spin_lock_bh(&fq->lock);
fq_tin_enqueue(fq, tin, flow_idx, skb,
fq_skb_free_func, fq_skb_free_func,
fq_flow_get_default_func); fq_flow_get_default_func);
spin_unlock_bh(&fq->lock);
} }
static bool fq_vlan_filter_func(struct fq *fq, struct fq_tin *tin, static bool fq_vlan_filter_func(struct fq *fq, struct fq_tin *tin,
...@@ -1590,7 +1594,6 @@ static bool ieee80211_queue_skb(struct ieee80211_local *local, ...@@ -1590,7 +1594,6 @@ static bool ieee80211_queue_skb(struct ieee80211_local *local,
struct sta_info *sta, struct sta_info *sta,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct fq *fq = &local->fq;
struct ieee80211_vif *vif; struct ieee80211_vif *vif;
struct txq_info *txqi; struct txq_info *txqi;
...@@ -1608,9 +1611,7 @@ static bool ieee80211_queue_skb(struct ieee80211_local *local, ...@@ -1608,9 +1611,7 @@ static bool ieee80211_queue_skb(struct ieee80211_local *local,
if (!txqi) if (!txqi)
return false; return false;
spin_lock_bh(&fq->lock);
ieee80211_txq_enqueue(local, txqi, skb); ieee80211_txq_enqueue(local, txqi, skb);
spin_unlock_bh(&fq->lock);
schedule_and_wake_txq(local, txqi); schedule_and_wake_txq(local, txqi);
...@@ -3221,6 +3222,7 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, ...@@ -3221,6 +3222,7 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
u8 max_subframes = sta->sta.max_amsdu_subframes; u8 max_subframes = sta->sta.max_amsdu_subframes;
int max_frags = local->hw.max_tx_fragments; int max_frags = local->hw.max_tx_fragments;
int max_amsdu_len = sta->sta.max_amsdu_len; int max_amsdu_len = sta->sta.max_amsdu_len;
u32 flow_idx;
__be16 len; __be16 len;
void *data; void *data;
bool ret = false; bool ret = false;
...@@ -3249,6 +3251,8 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, ...@@ -3249,6 +3251,8 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
max_amsdu_len = min_t(int, max_amsdu_len, max_amsdu_len = min_t(int, max_amsdu_len,
sta->sta.max_tid_amsdu_len[tid]); sta->sta.max_tid_amsdu_len[tid]);
flow_idx = fq_flow_idx(fq, skb);
spin_lock_bh(&fq->lock); spin_lock_bh(&fq->lock);
/* TODO: Ideally aggregation should be done on dequeue to remain /* TODO: Ideally aggregation should be done on dequeue to remain
...@@ -3256,7 +3260,8 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, ...@@ -3256,7 +3260,8 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
*/ */
tin = &txqi->tin; tin = &txqi->tin;
flow = fq_flow_classify(fq, tin, skb, fq_flow_get_default_func); flow = fq_flow_classify(fq, tin, flow_idx, skb,
fq_flow_get_default_func);
head = skb_peek_tail(&flow->queue); head = skb_peek_tail(&flow->queue);
if (!head || skb_is_gso(head)) if (!head || skb_is_gso(head))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment