RFR: 8283199: Linux os::cpu_microcode_revision() stalls cold startup [v3]
Aleksey Shipilev
shade at openjdk.java.net
Tue Mar 22 14:35:14 UTC 2022
On Tue, 22 Mar 2022 02:46:52 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> 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.
Right, like in the new version?
-------------
PR: https://git.openjdk.java.net/jdk/pull/7825
More information about the hotspot-runtime-dev
mailing list