On Sun, Aug 8, 2021 at 3:12 PM Yadunandan Pillai <ytpillai@xxxxxxxxxxxx> wrote: > > Hello, > > Conceptually, what would be the process behind updating a percpu map > from userspace? Looking up elements is fairly simple to digest. (For > example). It's symmetrical to lookup. You have to prepare an array of values, one for each possible CPU, and just pass that to bpf_map_update_elem() call. You cannot update individual CPU value, it's all of CPU values (for a given key, of course). > > ------- > > int map_fd = bpf_create_map_name( > BPF_MAP_TYPE_PERCPU_ARRAY, > "map_name", > sizeof(__u32), > sizeof(__u32), > 10, > 0 > ); > > int key = 4; > int values[nr_cpus]; > > bpf_map_lookup_elem(map_fd, &key, values); > > ------- > > This gets the fifth element for each percpu array. > > But how do you update the values in each percpu array from the > "values" array? If you can directly run bpf_map_update_elem() on the > file descriptor, does that mean that the updated value is automatically > replicated across all percpu arrays? What if you wanted to update a > specific percpu array? > Why don't you just try and see how it works? In this case, if you specify the same key (4), you'll update values (across all CPUs) corresponding to key=4.