Skip to content

Conversation

@evanj
Copy link
Contributor

@evanj evanj commented Jan 6, 2026

The Linux sched_getcpu function was changed to use the glibc "restartable sequences" since glibc 2.35 in in 2022. At this point, most recent Linux distributions have picked this up. The preprocessor macro will conditionally enable it based on the version of glibc, so this should make this faster on newer aarch64 builds, without impacting old ones. I have tested with a microbenchmark that the performance with new glibc is the same as x86-64 (a few ns/call).

I added a test to try to check this. It was useful for me in testing this, but it is probably "wrong": without duplicating the check exactly, it is hard to test the support. It is possible we should remove the test.

Correct the macro: it should be testing __GLIBC__ and __GLIBC_MINOR__ for the glibc version, rather than __GNUC__ and __GNUC_MINOR__ for the gcc/clang version.

Linux distribution support for this feature:

RHEL 9 glibc glibc 2.34 released 2022-05-17 (TOO OLD)
RHEL 9.1 glibc 2.35 released 2022-11-15 [1]
RHEL 10 glibc 2.39 released 2025-05-20

Ubuntu LTS 20.04 glibc 2.31 released 2020-04-23 (TOO OLD)
Ubuntu LTS 22.04 glibc 2.35 released 2022-04-21
Ubuntu LTS 24.04 glibc 2.39 released 2024-04-25

Debian 11 glibc 2.31 released 2021-08-14 (TOO OLD)
Debian 12 glibc 2.36 released 2023-06-14
Debian 13 glibc 2.41 released 2025-08-09

[1] https://developers.redhat.com/articles/2022/12/22/restartable-sequences-support-glibc-rhel-9

@meta-cla meta-cla bot added the CLA Signed label Jan 6, 2026
@evanj evanj force-pushed the evan.jones/physicalcore-aarch64 branch from 2ad521d to e875d5d Compare January 12, 2026 20:21
The Linux sched_getcpu function was changed to use the glibc
"restartable sequences" since glibc 2.35 in in 2022. At this point,
most recent Linux distributions have picked this up. The preprocessor
macro will conditionally enable it based on the version of glibc, so
this should make this faster on newer aarch64 builds, without
impacting old ones. I have tested with a microbenchmark that the
performance with new glibc is the same as x86-64 (a few ns/call).

I added a test to try to check this. It was useful for me in testing
this, but it is probably "wrong": without duplicating the check
exactly, it is hard to test the support. It is possible we should
remove the test.

Correct the macro: it should be testing __GLIBC__ and __GLIBC_MINOR__
for the glibc version, rather than __GNUC__ and __GNUC_MINOR__ for
the gcc/clang version.

Linux distribution support for this feature:

RHEL 9 glibc glibc 2.34 released 2022-05-17 (TOO OLD)
RHEL 9.1 glibc 2.35 released 2022-11-15 [1]
RHEL 10 glibc 2.39 released 2025-05-20

Ubuntu LTS 20.04 glibc 2.31 released 2020-04-23 (TOO OLD)
Ubuntu LTS 22.04 glibc 2.35 released 2022-04-21
Ubuntu LTS 24.04 glibc 2.39 released 2024-04-25

Debian 11 glibc 2.31 released 2021-08-14 (TOO OLD)
Debian 12 glibc 2.36 released 2023-06-14
Debian 13 glibc 2.41 released 2025-08-09

[1] https://developers.redhat.com/articles/2022/12/22/restartable-sequences-support-glibc-rhel-9
@evanj evanj force-pushed the evan.jones/physicalcore-aarch64 branch from e875d5d to 97ca3b1 Compare January 12, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant