can add a new bpf helper function bpf_map_compare_and_update_elem?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Suppose we have a map, MAP_A, and the user program does the following:

1. bpf_map_lookup_elem(MAP_A, key, value)
2. change the value
3. bpf_map_update_elem(MAP_A, key, value, FLAG)

At the same time, the kernel's BPF program may also be modifying the value.

Then we have concurrency problems.

Therefore, can we add a helper function like compare and swap?

Let's call it bpf_map_compare_and_update_elem.

So, the map operations will be modified as follows:

for true {
    1. bpf_map_lookup_elem(MAP_A, key, old_value)
    2. change value
    3. ret = bpf_map_compare_and_update_elem(MAP_A, key, old_value,
new_value, FLAG)
    4. if ret == 0 { break }
}


thank you



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux