<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58283>58283</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            pthread_getaffinity_np tests fail on a system using Docker with fixed container cores
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            compiler-rt
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DavidSpickett
      </td>
    </tr>
</table>

<pre>
    `compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_getaffinity_np.cpp` checks that `pthread_getaffinity_np` returns the same number of cores as `get_nprocs` does. Presumably to check that interception of the former has been done correctly.

I have a bot that uses Docker with a fixed set of cores. This test fails on that bot: https://lab.llvm.org/staging/#/builders/158/builds/368

This is because `get_nprocs` doesn't account for cgroups. On the machine `nproc` gives:
```
/# nproc --all
160
/# nproc
10
```
(I have assigned it 10 fixed cores)

Adding some printfs to the test I get:
```
# /tmp/test.o
sizeof cpu_set_t: 128
CPU_COUNT_S is 10
nprocs is 160
test.o: /tmp/test.c:16: main: Assertion `CPU_COUNT_S(sizeof(set_x), set_x) == get_nprocs()' failed.
```

I dug into `nproc` and found that it in fact calls `pthread_getaffinity_np` so it can work when cgroups are used.

https://github.com/coreutils/gnulib/blob/48a6c46b0b7e993aecf5c09386afd554165506ff/lib/nproc.c#L68

Seems a shame to disable this for all AArch64 (and Arm, I intend to move more bots to fixed core counts) to this test.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9VduOmzAQ_RryYi3iHnjgId2o0kpVW2m3z5ExA7gLNrLN7qZf3xlD2kRKKxFsPJ7bmTmTRrfnOigioadZjmAejAuSzw4sLZYr6eQvMCcUT1rh0QtKHrkFi_svUi0fuM5uMMDbUw-Od51EnfNJzaGYZzTMxADi1TI3cMfw-_5lumjALUbRTWCWT8DUMjVgmO6Y0AYs45YMoCIqGC0sKbUabMi-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