I'm running iperf in server mode on a Ubuntu box (14.04 LTS). The hardware is quad core with hyper-threading, so I have cores 0-7 available (0 is paired with 4, 1 with 5 and so on).
I've set the processor affinity of the running iperf process to use only processors 0,1. I can verify this with taskset:
$ taskset -pc 27745 pid 27745's current affinity list: 0,1
If I view the process in top or htop then the process correctly shows as only ever running on one of those cores. However, if I switch to thread view then I see the child threads running on arbitrary cores.
Is top/htop misleading me somehow? Can this genuinely happen? If so, why and how do I prevent it?
I should comment that whilst I see this with iperf I'm not necessarily implying it's iperf specific. It just happens to be the setup I have. If I can't get to the bottom of this then I'll likely play around with other executables and see if the behaviour is reproducible.