RFR: 8283199: Linux os::cpu_microcode_revision() stalls cold startup [v2]

Aleksey Shipilev shade at openjdk.java.net
Mon Mar 21 09:31:14 UTC 2022


On Thu, 17 Mar 2022 07:24:23 GMT, David Holmes <dholmes at openjdk.org> wrote:

> What versions of Linux have `/sys/devices/system/cpu/cpu0/microcode/version`? 

I looked through Linux kernel sources, and I believe it was added by https://github.com/torvalds/linux/commit/9a4b9efa1d39d7d31bed08fbe5a9b2a03b2759d4 back in 2006, and landed in 2.6.19. So even a relatively ancient RHEL 6 already has it.

> And is it present in virtualized environments? 

One of my x86_64 QEMU nodes does not have it, apparently. There is still `/proc/cpuinfo` with `microcode:` field there. I think another trouble in virtualized environment would be not having the CPU0, but rather some other CPU id.

> What cost is there for systems that always have to take the second path?

So, emulating the missing sysfs file...

Cold start:


# Baseline
real	0m0.043s
real	0m0.042s
real	0m0.042s
real	0m0.043s
real	0m0.042s

# Real CPU id in sysfs (this patch)
real	0m0.024s
real	0m0.022s
real	0m0.023s
real	0m0.023s
real	0m0.023s

# Non-existent CPU id in sysfs
real	0m0.045s
real	0m0.043s
real	0m0.043s
real	0m0.043s
real	0m0.043s


Hot start:


# Baseline
real	0m0.046s
real	0m0.024s
real	0m0.024s
real	0m0.024s
real	0m0.026s

# Real CPU id in sysfs (this patch)
real	0m0.025s
real	0m0.023s
real	0m0.023s
real	0m0.023s
real	0m0.025s

# Non-existent CPU id in sysfs
real	0m0.045s
real	0m0.025s
real	0m0.026s
real	0m0.025s
real	0m0.025s


So I'd say we pay about 1 ms penalty if sysfs file does not exist. I would chalk it up as "pretend this is the actual performance cost for [JDK-8249672](https://bugs.openjdk.java.net/browse/JDK-8249672) work", push this follow-up, and actually look at moving all this mess out of the startup sequence with [JDK-8283200](https://bugs.openjdk.java.net/browse/JDK-8283200).

> src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp line 475:
> 
>> 473:         sscanf(data, "%x", &result);
>> 474:       }
>> 475:       fclose(fp);
> 
> The diff would be much simpler if you added a return here and so avoided the need for the if statement below.

See new commit.

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

PR: https://git.openjdk.java.net/jdk/pull/7825


More information about the hotspot-runtime-dev mailing list