RFR: 8339148: Add os::active_physical_processor_count() API

Severin Gehwolf sgehwolf at openjdk.org
Fri Aug 30 08:19:19 UTC 2024


On Thu, 29 Aug 2024 23:19:15 GMT, David Holmes <dholmes 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?
>
> 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!

OK. Happy to change the name to something more suitable. The idea is to have a function that returns the "available" cpus of the node/host whether in container or not. How about `available_host_processor_count()`?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20768#discussion_r1738179548


More information about the hotspot-runtime-dev mailing list