RFR: 8367319: Add os interfaces to get machine and container values separately [v5]

Severin Gehwolf sgehwolf at openjdk.org
Thu Dec 4 08:40:02 UTC 2025


On Thu, 4 Dec 2025 06:50:05 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/hotspot/os/linux/os_linux.cpp line 222:
>> 
>>> 220:     return true;
>>> 221:   }
>>> 222:   return false;
>> 
>> Assume this usage:
>> 
>> physical_memory_size mem_limit = 0;
>> if (!os::Container::memory_limit(mem_limit)) {
>>   // assume mem_limit == 0;
>> }
>> 
>> 
>> The general contract for cases where a function returned `false` (i.e. error) is that the passed in reference remains untouched. This seems to violate that contract. `value` could change from whatever the initial value was to `value_unlimited` and return `false`.
>
> I don't see a specification for any of these bool-returning functions with out-parameters (whether already existing or new here) so I'm not quite sure how to read a lot of them. Does returning true mean asking about a limit was successful, or that it was successful and there is a limit? Do the low-level functions have the same behaviour as the higher-level ones?

This started with:
https://bugs.openjdk.org/browse/JDK-8357086

They should have the same meaning throughout. Returning `true` means the passed in reference has been set to a value. In the container case it might be `value_unlimited` (for example an interface file has value `max`). So if the desire is to return `false` for unlimited, then this needs to be handled on top.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27646#discussion_r2588068482


More information about the hotspot-dev mailing list