RFR: 8348554: Enhance Linux kernel version checks

Robbin Ehn rehn at openjdk.org
Fri Jan 24 10:53:46 UTC 2025


On Fri, 24 Jan 2025 09:54:56 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> I also fixed a typo in bug synopsis, you need to adjust the PR title a bit too :)

Thanks for having a look!

> src/hotspot/os/linux/os_linux.cpp line 381:
> 
>> 379: }
>> 380: 
>> 381: void os::Linux::kernel_version(long* major, long* patch, long* sub) {
> 
> I think semver calls these "major", "minor", "patch".

Yes, it seems like it's only the actual define for these numbers which have those names.
I'll change as the kselftest also use the names you suggest.

> src/hotspot/os/linux/os_linux.cpp line 392:
> 
>> 390:     return;
>> 391:   }
>> 392:   int nr_matched = sscanf(buffer.release, "%ld.%ld.%ld", major, patch, sub);
> 
> Are we sure the kernel version always have 3 components? It would be safer to handle 2-component version as well, and set the third component to `0` in that case.

I took another look; technically, only one is guaranteed by the source.
However, in practice, there are always three (checked in Linux v3).

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

PR Comment: https://git.openjdk.org/jdk/pull/23291#issuecomment-2612231291
PR Review Comment: https://git.openjdk.org/jdk/pull/23291#discussion_r1928496535
PR Review Comment: https://git.openjdk.org/jdk/pull/23291#discussion_r1928494640


More information about the hotspot-runtime-dev mailing list