Commit f5e50cd0757cc97cd1caded0d3f07ff09b5319e4
Committed by
John W. Linville
1 parent
ece1a2e7e8
Exists in
master
and in
6 other branches
mac80211: Improve mpath state locking
No need to take the mpath state lock when an mpath is removed. Also, no need checking the lock when reading mpath flags. Signed-off-by: Javier Cardona <javier@cozybit.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Showing 2 changed files with 7 additions and 11 deletions Side-by-side Diff
net/mac80211/mesh.h
... | ... | @@ -80,7 +80,9 @@ |
80 | 80 | * retry |
81 | 81 | * @discovery_retries: number of discovery retries |
82 | 82 | * @flags: mesh path flags, as specified on &enum mesh_path_flags |
83 | - * @state_lock: mesh path state lock | |
83 | + * @state_lock: mesh path state lock used to protect changes to the | |
84 | + * mpath itself. No need to take this lock when adding or removing | |
85 | + * an mpath to a hash bucket on a path table. | |
84 | 86 | * @is_gate: the destination station of this path is a mesh gate |
85 | 87 | * |
86 | 88 | * |
net/mac80211/mesh_pathtbl.c
... | ... | @@ -776,18 +776,17 @@ |
776 | 776 | tbl = rcu_dereference(mesh_paths); |
777 | 777 | for_each_mesh_entry(tbl, p, node, i) { |
778 | 778 | mpath = node->mpath; |
779 | - spin_lock_bh(&mpath->state_lock); | |
780 | 779 | if (rcu_dereference(mpath->next_hop) == sta && |
781 | 780 | mpath->flags & MESH_PATH_ACTIVE && |
782 | 781 | !(mpath->flags & MESH_PATH_FIXED)) { |
782 | + spin_lock_bh(&mpath->state_lock); | |
783 | 783 | mpath->flags &= ~MESH_PATH_ACTIVE; |
784 | 784 | ++mpath->sn; |
785 | 785 | spin_unlock_bh(&mpath->state_lock); |
786 | 786 | mesh_path_error_tx(sdata->u.mesh.mshcfg.element_ttl, |
787 | 787 | mpath->dst, cpu_to_le32(mpath->sn), |
788 | 788 | reason, bcast, sdata); |
789 | - } else | |
790 | - spin_unlock_bh(&mpath->state_lock); | |
789 | + } | |
791 | 790 | } |
792 | 791 | rcu_read_unlock(); |
793 | 792 | } |
... | ... | @@ -866,7 +865,7 @@ |
866 | 865 | if (mpath->sdata != sdata) |
867 | 866 | continue; |
868 | 867 | spin_lock_bh(&tbl->hashwlock[i]); |
869 | - spin_lock_bh(&mpath->state_lock); | |
868 | + hlist_del_rcu(&node->list); | |
870 | 869 | call_rcu(&node->rcu, mesh_path_node_reclaim); |
871 | 870 | atomic_dec(&tbl->entries); |
872 | 871 | spin_unlock_bh(&tbl->hashwlock[i]); |
873 | 872 | |
874 | 873 | |
... | ... | @@ -1160,15 +1159,10 @@ |
1160 | 1159 | if (node->mpath->sdata != sdata) |
1161 | 1160 | continue; |
1162 | 1161 | mpath = node->mpath; |
1163 | - spin_lock_bh(&mpath->state_lock); | |
1164 | 1162 | if ((!(mpath->flags & MESH_PATH_RESOLVING)) && |
1165 | 1163 | (!(mpath->flags & MESH_PATH_FIXED)) && |
1166 | - time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE)) { | |
1167 | - spin_unlock_bh(&mpath->state_lock); | |
1164 | + time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE)) | |
1168 | 1165 | mesh_path_del(mpath->dst, mpath->sdata); |
1169 | - } else | |
1170 | - spin_unlock_bh(&mpath->state_lock); | |
1171 | - } | |
1172 | 1166 | rcu_read_unlock(); |
1173 | 1167 | } |
1174 | 1168 |