Re: [PATCH] kvm: x86: Print "disabled by bios" only once per host

From: Erwan Velu
Date: Tue Feb 18 2020 - 11:30:22 EST


On 14/02/2020 18:05, Sean Christopherson wrote:
This has come up before[*]. Using _once() doesn't fully solve the issue
when KVM is built as a module. The spam is more than likely a userspace
bug, i.e. userspace is probing KVM on every CPU.

I made some progress on this.


That's "/usr/bin/udevadm trigger --type=devices --action=add" the culprit.

It does echo "add" in /sys/devices/system/cpu/cpu<x>/uevent

For the each cpu, it does the 'add' which trigger the "disabled by bios" message from kvm_arch_init.

Note that doing a "add" on the same processor will trigger the same message at every "add" event.


So I tried the patch of using pr_err_once() instead of printk() and the behavior is fine : despite the number of "add" generated, there is a single line being printed out.

Without the patch, every "add" generates the "disabled by bios" message.


So the question is : do we want to handle the case where a possible bios missed the configuration of some cores ?

If no, then the patch is fine and could be submitted. I don't see the need of printing this message at every call as it pollute the kernel log.

If yes, then we need to keep a trace of the number of enabled/disabled cores so we can report a mismatch. As this message seems printed per cpu, that would kind of mean a global variable right ?


What are your recommendations on this ?


Erwan,