RFR: 8283199: Linux os::cpu_microcode_revision() stalls cold startup [v3]
David Holmes
dholmes at openjdk.java.net
Tue Mar 22 02:50:28 UTC 2022
On Mon, 21 Mar 2022 13:24:47 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp line 467:
>>
>>> 465:
>>> 466: // Attempt 1 (faster): Read the microcode version off the sysfs.
>>> 467: {
>>
>> Why the new block?
>
> Because I don't want to extend the lifetime of `fp`, `data`, etc.
I really don't see an issue, only fp needs to change
// Attempt 1 (faster): Read the microcode version off the sysfs.
// No block
FILE *fp = os::fopen("/sys/devices/system/cpu/cpu0/microcode/version", "r");
if (fp) {
char data[128] = {0}; // looking for short line
if (fgets(data, sizeof(data), fp)) {
sscanf(data, "%x", &result);
}
fclose(fp);
if (result != 0) { // moved inside if block
return result;
}
}
// Attempt 2 (slower): Read the microcode version off the procfs.
// No block - reuse fp
fp = os::fopen("/proc/cpuinfo", "r");
if (fp) {
char data[2048] = {0}; // lines should fit in 2K buf
size_t len = sizeof(data);
...
}
That way the diff would have been the addition of a chunk of new code and a couple of modified lines at the start of the existing block.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7825
More information about the hotspot-runtime-dev
mailing list