i'd suggest a different approach that is simpler:
- step0: set flag that "all newly created tasks need the array
allocated from now on".
- step1: allocate N arrays outside tasklist_lock
- step2: take tasklist_lock, loop over all tasks that exist and pass
in the N arrays to all tasks that still need it.
If tasks were 'refilled', drop tasklist_lock and go back to step 1.
- step3: free N (superfluously allocated) arrays
Make N something like 32 to not get into a bad quadratic nr_tasks
double loop in practice. (Possibly allocate arrays[32] dynamically as
well at step0 and not have it on the kernel stack - so 32 can be
changed to 128 or so.)
Ingo
--