Messages in this thread |  | | Date | Fri, 22 Oct 2021 13:00:13 -1000 | From | Tejun Heo <> | Subject | Re: [PATCH 3/3] bpf: Implement prealloc for task_local_storage |
| |
Hello,
On Fri, Oct 22, 2021 at 03:47:33PM -0700, Martin KaFai Lau wrote: ... > > + for_each_process_thread(g, p) { > I am thinking if this loop can be done in bpf iter. > > If the bpf_local_storage_map is sleepable safe (not yet done but there is > an earlier attempt [0]), bpf_local_storage_update() should be able to > alloc without GFP_ATOMIC by sleepable bpf prog and this potentially > will be useful in general for other sleepable use cases. > > For example, if a sleepable bpf iter prog can run in this loop (or the existing > bpf task iter loop is as good?), the iter bpf prog can call > bpf_task_storage_get(BPF_SK_STORAGE_GET_F_CREATE) on a sleepable > bpf_local_storage_map.
Yeah, whatever that can walk all the existing tasks should do, and I think the locked section can be shrunk too.
percpu_down_write(&threadgroup_rwsem); list_add_tail(&smap->prealloc_node, &prealloc_smaps); percpu_up_write(&threadgroup_rwsem);
// Here, it's guaranteed that all new tasks are guaranteed to // prealloc on fork.
Iterate all tasks in whatever way and allocate if necessary;
Thanks.
-- tejun
|  |