RFR: 8339148: Add os::active_physical_processor_count() API
David Holmes
dholmes at openjdk.org
Thu Aug 29 23:23:18 UTC 2024
On Thu, 29 Aug 2024 12:38:40 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:
> Please review this rather trivial patch for adding `os::active_physical_processor_count()` function. It is useful to have that info on Linux for the container code which bounds the CPU limit above by that value. Also, the old `os::Linux::active_processor_count()` was protected and had a bit of a misleading name. As a bonus, we can get rid of some `friend class` smells.
>
> **Testing**:
> - [x] GHA
> - [x] Container tests and cgroup gtests on linux x86_64
>
> Thoughts?
I'm not clear exactly what you need here but "physical" is not what you are looking up.
src/hotspot/os/linux/os_linux.cpp line 4833:
> 4831:
> 4832: // Return the active CPUs irrespective of the system being containerized
> 4833: // or not. Thus, this returns the host active cpus in a container.
No it doesn't! The comment for the function you call states clearly:
// Get the current number of available processors for this process.
This is not related to "physical count" at all!
-------------
Changes requested by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/20768#pullrequestreview-2270580489
PR Review Comment: https://git.openjdk.org/jdk/pull/20768#discussion_r1737466694
More information about the hotspot-runtime-dev
mailing list