RFR: 8357086: os::xxx functions returning memory size should return size_t [v4]
Anton Artemov
duke at openjdk.org
Wed Jun 11 12:30:30 UTC 2025
On Wed, 11 Jun 2025 08:35:30 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8357086: Fixed spaces in formatting in gc-related code.
>
> Are you up for making an experiment that changes `total_swap_space` and `free_swap_space` to return two values: one the actual value in `size_t` and the other an error code that gets set whenever we hit an error?
>
> The two proposed alternatives for this would be:
> 1) returning something containing the two values (struct, Pair, Tuple, array, ...)
> 2) Return the size_t and using an an out put parameter to signal an error (or vice versa)
>
> I think the fan-out of that will not be too bad and the likely outcome is that it is clearer that the code is propagating errors.
@stefank I inspected the container-related code once again, and came to conclusion that it is safe to use ssize_t, as you suggested above initially. The `OSCONTAINER_ERROR` return value will not be returned by `free_swap_space()` in os_linux.cpp as well as in anywhere in that file, because in all places there is a check for non-negativity. If negative, then the flow falls back to the host method, which can return value >= -1, i.e. fitting `ssize_t`. I will push these changes soon once tested.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25450#issuecomment-2962496029
More information about the hotspot-dev
mailing list