Skip to content

Commit 53f2ba0

Browse files
Hou TaoAlexei Starovoitov
authored andcommitted
bpf: Remove migrate_{disable|enable} in htab_elem_free
htab_elem_free() has two call-sites: delete_all_elements() has already disabled migration, free_htab_elem() is invoked by other 4 functions: __htab_map_lookup_and_delete_elem, __htab_map_lookup_and_delete_batch, htab_map_update_elem and htab_map_delete_elem. BPF syscall has already disabled migration before invoking ->map_update_elem, ->map_delete_elem, and ->map_lookup_and_delete_elem callbacks for hash map. __htab_map_lookup_and_delete_batch() also disables migration before invoking free_htab_elem(). ->map_update_elem() and ->map_delete_elem() of hash map may be invoked by BPF program and the running context of BPF program has already disabled migration. Therefore, it is safe to remove the migration_{disable|enable} pair in htab_elem_free() Signed-off-by: Hou Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent ea5b229 commit 53f2ba0

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

kernel/bpf/hashtab.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,11 +897,9 @@ static void htab_elem_free(struct bpf_htab *htab, struct htab_elem *l)
897897
{
898898
check_and_free_fields(htab, l);
899899

900-
migrate_disable();
901900
if (htab->map.map_type == BPF_MAP_TYPE_PERCPU_HASH)
902901
bpf_mem_cache_free(&htab->pcpu_ma, l->ptr_to_pptr);
903902
bpf_mem_cache_free(&htab->ma, l);
904-
migrate_enable();
905903
}
906904

907905
static void htab_put_fd_value(struct bpf_htab *htab, struct htab_elem *l)

0 commit comments

Comments
 (0)