Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

wifi: mac80211: Remove redundant rcu_read_lock/unlock() in spin_lock

Since commit a8bb74acd8efe ("rcu: Consolidate RCU-sched update-side function definitions")
there is no difference between rcu_read_lock(), rcu_read_lock_bh() and
rcu_read_lock_sched() in terms of RCU read section and the relevant grace
period. That means that spin_lock(), which implies rcu_read_lock_sched(),
also implies rcu_read_lock().

There is no need no explicitly start a RCU read section if one has already
been started implicitly by spin_lock().

Simplify the code and remove the inner rcu_read_lock() invocation.

Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
Signed-off-by: pengdonglin <dolinux.peng@gmail.com>
Link: https://patch.msgid.link/20250916044735.2316171-11-dolinux.peng@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

pengdonglin and committed by
Johannes Berg
872e397d a37a6f54

-10
-2
net/mac80211/cfg.c
··· 4935 4935 int ret = 0; 4936 4936 4937 4937 spin_lock_bh(&local->fq.lock); 4938 - rcu_read_lock(); 4939 4938 4940 4939 if (wdev) { 4941 4940 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); ··· 4960 4961 } 4961 4962 4962 4963 out: 4963 - rcu_read_unlock(); 4964 4964 spin_unlock_bh(&local->fq.lock); 4965 4965 4966 4966 return ret;
-2
net/mac80211/debugfs.c
··· 82 82 int len = 0; 83 83 84 84 spin_lock_bh(&local->fq.lock); 85 - rcu_read_lock(); 86 85 87 86 len = scnprintf(buf, sizeof(buf), 88 87 "access name value\n" ··· 104 105 fq->limit, 105 106 fq->quantum); 106 107 107 - rcu_read_unlock(); 108 108 spin_unlock_bh(&local->fq.lock); 109 109 110 110 return simple_read_from_buffer(user_buf, count, ppos,
-2
net/mac80211/debugfs_netdev.c
··· 625 625 txqi = to_txq_info(sdata->vif.txq); 626 626 627 627 spin_lock_bh(&local->fq.lock); 628 - rcu_read_lock(); 629 628 630 629 len = scnprintf(buf, 631 630 buflen, ··· 641 642 txqi->tin.tx_bytes, 642 643 txqi->tin.tx_packets); 643 644 644 - rcu_read_unlock(); 645 645 spin_unlock_bh(&local->fq.lock); 646 646 647 647 return len;
-2
net/mac80211/debugfs_sta.c
··· 148 148 return -ENOMEM; 149 149 150 150 spin_lock_bh(&local->fq.lock); 151 - rcu_read_lock(); 152 151 153 152 p += scnprintf(p, 154 153 bufsz + buf - p, ··· 177 178 test_bit(IEEE80211_TXQ_DIRTY, &txqi->flags) ? " DIRTY" : ""); 178 179 } 179 180 180 - rcu_read_unlock(); 181 181 spin_unlock_bh(&local->fq.lock); 182 182 183 183 rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
-2
net/mac80211/sta_info.c
··· 2637 2637 2638 2638 if (link_id < 0 && tid < IEEE80211_NUM_TIDS) { 2639 2639 spin_lock_bh(&local->fq.lock); 2640 - rcu_read_lock(); 2641 2640 2642 2641 tidstats->filled |= BIT(NL80211_TID_STATS_TXQ_STATS); 2643 2642 ieee80211_fill_txq_stats(&tidstats->txq_stats, 2644 2643 to_txq_info(sta->sta.txq[tid])); 2645 2644 2646 - rcu_read_unlock(); 2647 2645 spin_unlock_bh(&local->fq.lock); 2648 2646 } 2649 2647 }