RFR: 8360515: PROPERFMTARGS should always use size_t template specialization for unit [v2]

David Holmes dholmes at openjdk.org
Thu Jun 26 23:50:38 UTC 2025


On Thu, 26 Jun 2025 08:17:03 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

>> src/hotspot/os/bsd/memMapPrinter_macosx.cpp line 239:
>> 
>>> 237:       st->print_cr("               rss: %llu (%llu%s)", vm_info.resident_size, byte_size_in_proper_unit(vm_info.resident_size), proper_unit_for_byte_size(vm_info.resident_size));
>>> 238:       st->print_cr("          peak rss: %llu (%llu%s)", vm_info.resident_size_peak, byte_size_in_proper_unit(vm_info.resident_size_peak), proper_unit_for_byte_size(vm_info.resident_size_peak));
>>> 239:       st->print_cr("         page size: %d (" PROPERFMT ")", vm_info.page_size, PROPERFMTARGS((size_t)vm_info.page_size));
>> 
>> Just to clarify something for the reader here, as it tripped me up, the `vm_info` fields are declared as `mach_vm_size_t`, which one might expect is some kind of `size_t` but alas no [1]:
>> 
>> typedef uint64_t mach_vm_size_t;
>> 
>> But given you cast `page_size` to size_t (it is `int32_t`) why not cast the others too and use `PROPERFMT`?
>> 
>> [1] https://developer.apple.com/documentation/kernel/mach_vm_size_t
>
> I originally wanted this patch to be minimally invasive and just fix the mismatch between PROPERFMT and PROPERFMTARGS. The cast to size_t wasn't added by me, I just changed the format specifier to match the type in PROPERFMTARGS. I agree that it looks a bit weird to have both the expanded macro and PROPERFMTARGS next to each other, and I'm not 100% sure why vm_info.page_size is casted to size_t.
> 
> I'm fine with making the usage consistent in this patch, making all the prints use PROPERFMT+PROPERFMTARGS with casts to size_t, or the other way around using the expanded macro.

Sorry for mis-attributing the cast to your change. This could go either way with no way clearly better than the other. Lets see if another reviewer has a strong opinion.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25975#discussion_r2170301537


More information about the hotspot-dev mailing list