I have a problem with this retry algorithm of
hwloc_linux_foreach_proc_tid(). For example with the
hwloc_linux_get_pid_cpubind() function. hwloc_linux_get_pid_cpubind()
should collect all affinity mask from the threads. But if the retry is
triggered and the new tid list does not have a tid anymore which had
an affinity mask which is not a subset of the collected one in the
first run. The end result is inaccurate.

A small example:

tid A has affinity 0x1
tid B has affinity 0x2

After the first round the affinity mask is 0x3. Now tid A exits and
the retry check will be trigged. The end affinity mask will still be
0x3. Because the mask will not be reset to 0.

Here is a proposal to fix this. It passes a new argument to the
callback function, which is only true for the first tid. So this can
be used to zero the cpuset.