Skip to content

Commit 64fd06d

Browse files
Fushuai Wangtheihor
authored andcommitted
bpf: Use rcu_read_lock_dont_migrate() and and rcu_read_unlock_migrate()
Replace the combination of migrate_disable()/migrate_enable() and rcu_read_lock()/rcu_read_unlock() with rcu_read_lock_dont_migrate()/rcu_read_unlock_migrate() in bpf_sk_storage.c. Signed-off-by: Fushuai Wang <[email protected]>
1 parent 2a180ed commit 64fd06d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

net/core/bpf_sk_storage.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@ void bpf_sk_storage_free(struct sock *sk)
5050
{
5151
struct bpf_local_storage *sk_storage;
5252

53-
migrate_disable();
54-
rcu_read_lock();
53+
rcu_read_lock_dont_migrate();
5554
sk_storage = rcu_dereference(sk->sk_bpf_storage);
5655
if (!sk_storage)
5756
goto out;
5857

5958
bpf_local_storage_destroy(sk_storage);
6059
out:
61-
rcu_read_unlock();
62-
migrate_enable();
60+
rcu_read_unlock_migrate();
6361
}
6462

6563
static void bpf_sk_storage_map_free(struct bpf_map *map)
@@ -161,8 +159,7 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk)
161159

162160
RCU_INIT_POINTER(newsk->sk_bpf_storage, NULL);
163161

164-
migrate_disable();
165-
rcu_read_lock();
162+
rcu_read_lock_dont_migrate();
166163
sk_storage = rcu_dereference(sk->sk_bpf_storage);
167164

168165
if (!sk_storage || hlist_empty(&sk_storage->list))
@@ -213,9 +210,8 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk)
213210
}
214211

215212
out:
216-
rcu_read_unlock();
217-
migrate_enable();
218213

214+
rcu_read_unlock_migrate();
219215
/* In case of an error, don't free anything explicitly here, the
220216
* caller is responsible to call bpf_sk_storage_free.
221217
*/

0 commit comments

Comments
 (0)