Commit 73cc4a5
Currently, we use bucket_lock when traversing bpf_sk_storage_map
elements. Since bpf_iter programs cannot use bpf_sk_storage_get() and bpf_sk_storage_delete() helpers which may also grab bucket lock, we do not have a deadlock issue which exists for hashmap when using bucket_lock ([1]). If a bucket contains a lot of sockets, during bpf_iter traversing a bucket, concurrent bpf_sk_storage_{get,delete}() may experience some undesirable delays. Using rcu_read_lock() is a reasonable compromise here. Although it may lose some precision, e.g., access stale sockets, but it will not hurt performance of other bpf programs. [1] https://lore.kernel.org/bpf/20200902235341.2001534-1-yhs@fb.com Cc: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Yonghong Song <yhs@fb.com> --- net/core/bpf_sk_storage.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)1 parent a1ee995 commit 73cc4a5
1 file changed
+6
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
701 | 701 | | |
702 | 702 | | |
703 | 703 | | |
704 | | - | |
| 704 | + | |
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
| |||
715 | 715 | | |
716 | 716 | | |
717 | 717 | | |
718 | | - | |
| 718 | + | |
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
| |||
726 | 726 | | |
727 | 727 | | |
728 | 728 | | |
729 | | - | |
| 729 | + | |
730 | 730 | | |
731 | 731 | | |
732 | 732 | | |
| |||
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
809 | | - | |
| 809 | + | |
810 | 810 | | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
| 811 | + | |
| 812 | + | |
816 | 813 | | |
817 | 814 | | |
818 | 815 | | |
| |||
0 commit comments