You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following confusion regarding percpu_array - the bcc documentation here mentions that updates are not synchronized across the copies of CPUs. However, skimming through the kernel code I see that in the update_elem for percpu_array there is a loop over all possible CPUs to update the value - here.
Am I missing something or does the documentation need to be updated?
Thanks!
The text was updated successfully, but these errors were encountered:
Your second link is pointing to a loop in bpf_percpu_array_copy, but there's a similar loop in bpf_percpu_array_update which seems more relevant to the question you're asking. Guessing you meant to ask about the latter function.
Anyways, the API for updating percpu array from userspace differs a bit from the API BPF programs use, but still preserves the "updates are not synchronized" expectation.
for_each_possible_cpu(cpu) {
bpf_long_memcpy(per_cpu_ptr(pptr, cpu), value + off, size);
off += size;
}
The passed in value buffer contains a separate value for each cpu, see tools/testing/selftests/bpf/test_maps.c in kernel source for an example use. The helper called from BPF, array_map_update_elem, updates a single cpu's value.
The semantics probably differ to keep the BPF_MAP_UPDATE_ELEM interface simple, since most bpf map types aren't percpu. Most BPF programs use percpu arrays to gather data from the program itself, or as a temporary 'heap' buffer space, and rarely need userspace to populate the percpu array except perhaps with some initial values. If you have a different usecase, though, we'd love to hear about it!
I have the following confusion regarding percpu_array - the bcc documentation here mentions that updates are not synchronized across the copies of CPUs. However, skimming through the kernel code I see that in the
update_elem
forpercpu_array
there is a loop over all possible CPUs to update the value - here.Am I missing something or does the documentation need to be updated?
Thanks!
The text was updated successfully, but these errors were encountered: