Skip to contentSkip to conversation

lwt_bpf: remove unnecessary rcu_read_lock in run_lwt_bpf

PATCH Applied Taehee Yoo 3 participants 3 messages Jul 30, 2018 – Jul 31, 2018

Subsystems (2)
lore
Share & tools
lore

Taehee Yoo

author
#0 lore raw

PATCH 1/1 lwt_bpf: remove unnecessary rcu_read_lock in run_lwt_bpf

run_lwt_bpf is called by bpf_{input/output/xmit}. These functions are already protected by rcu_read_lock. because lwtunnel_{input/output/xmit} holds rcu_read_lock and then calls bpf_{input/output/xmit}.
So that rcu_read_lock in the run_lwt_bpf is unnecessary.

---
 net/core/lwt_bpf.c | 2 --
 1 file changed, 2 deletions(-)
net/core/lwt_bpf.c +0 -2
index e7e626f..a49c7ba 100644
@@ -50,10 +50,8 @@ static int run_lwt_bpf(struct sk_buff *skb, struct bpf_lwt_prog *lwt,
 	 * mixing with BH RCU lock doesn't work.
 	 */
 	preempt_disable();
-	rcu_read_lock();
 	bpf_compute_data_pointers(skb);
 	ret = bpf_prog_run_save_cb(lwt->prog, skb);
-	rcu_read_unlock();
 
 	switch (ret) {
 	case BPF_OK:
Signature · 1 line
2.9.3
Acked-by Yonghong Song on v1 1/1
#1 lore raw
Quoted 7 lines · Taehee Yoo

run_lwt_bpf is called by bpf_{input/output/xmit}. These functions are already protected by rcu_read_lock. because lwtunnel_{input/output/xmit} holds rcu_read_lock and then calls bpf_{input/output/xmit}.
So that rcu_read_lock in the run_lwt_bpf is unnecessary.

#2 lore raw
In reply to Taehee Yoo
Quoted 7 lines · Taehee Yoo

run_lwt_bpf is called by bpf_{input/output/xmit}. These functions are already protected by rcu_read_lock. because lwtunnel_{input/output/xmit} holds rcu_read_lock and then calls bpf_{input/output/xmit}.
So that rcu_read_lock in the run_lwt_bpf is unnecessary.

Applied to bpf-next, thanks Taehee!