bpf: Remove migrate_{disable|enable} from bpf_local_storage_free()

bpf_local_storage_free() has three callers:

1) bpf_local_storage_alloc()
Its caller must have disabled migration.

2) bpf_local_storage_destroy()
Its four callers (bpf_{cgrp|inode|task|sk}_storage_free()) have already
invoked migrate_disable() before invoking bpf_local_storage_destroy().

3) bpf_selem_unlink()
Its callers include: cgrp/inode/task/sk storage ->map_delete_elem
callbacks, bpf_{cgrp|inode|task|sk}_storage_delete() helpers and
bpf_local_storage_map_free(). All of these callers have already disabled
migration before invoking bpf_selem_unlink().

Therefore, it is OK to remove migrate_{disable|enable} pair from
bpf_local_storage_free().

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20250108010728.207536-16-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Hou Tao 2025-01-08 09:07:27 +08:00 committed by Alexei Starovoitov
parent 4855a75ebf
commit 7b984359e0

View File

@ -172,17 +172,14 @@ static void bpf_local_storage_free(struct bpf_local_storage *local_storage,
return; return;
} }
if (smap) { if (smap)
migrate_disable();
bpf_mem_cache_free(&smap->storage_ma, local_storage); bpf_mem_cache_free(&smap->storage_ma, local_storage);
migrate_enable(); else
} else {
/* smap could be NULL if the selem that triggered /* smap could be NULL if the selem that triggered
* this 'local_storage' creation had been long gone. * this 'local_storage' creation had been long gone.
* In this case, directly do call_rcu(). * In this case, directly do call_rcu().
*/ */
call_rcu(&local_storage->rcu, bpf_local_storage_free_rcu); call_rcu(&local_storage->rcu, bpf_local_storage_free_rcu);
}
} }
/* rcu tasks trace callback for bpf_ma == false */ /* rcu tasks trace callback for bpf_ma == false */