
A request for comments (RFC) was sent out last night on the Linux kernel mailing list in seeking to clean-up the AMD Zen microarchitecture detection within the kernel. This is for enhancing the kernel where there are code paths specific to a certain generation of AMD Zen processors or select generations such as Zen 3 through Zen 5 CPUs. AI was leveraged in helping to clean-up this AMD Zen code in the Linux kernel.
AMD Linux engineer Borislav Petkov sent out of the RFC as an initial attempt at cleaning up the Zen microarchitecture deection. Boris explained in the LKML message:
"I have been wondering how to improve that Zen uarch detection and handling and be able to do range checks of uarches, i.e., "this code needs to run on Zen microarchitectures 3 to 5". And I asked AI.It gave me a lot of blurb but the basic idea is good so I went and did it. See below.
It boots in a VM, I'm not even trying to cause the cat to catch fire by booting on a real machine but that will happen soon too.
The thing can easily be extended to pre-Zen but that is not really needed, I'd say.
X86_FEATURE_ZEN to mark all Zens remains, that will be a future patch. Perhaps something as simple as:
if (boot_cpu_data.x86_uarch)
but I have to move Hygon off of that usage. We'll see. Small steps."
Some of the initial code changes do help in making it more immediately clear what Zen generations are relevant for a given code path, e.g.
We'll see where this AMD Zen code clean-up leads for the Linux kernel.