Serial console polling burns CPU on VMware
After doing some debugging with a serial console recently (in a VM) I noticed that when the guest stops in the loader prompt or in kmdb the fan on the laptop (VM host) turns on blowing out hot air. A quick look at the hypervisor stats show that, indeed, the guest is burning CPU.
I thought that odd, given that the serial configuration for the guest includes the special "yieldOnMsrRead" setting.
Here's the section of the guest's vmx file for the serial console:
serial0.fileType = "network" serial0.fileName = "telnet://10.1.2.3:5432" serial0.present = "TRUE" serial0.startConnected = "TRUE" serial0.yieldOnMsrRead = "TRUE"
BTW, see helpful notes on this setup here:
Investigation reveals that the "yieldOnMsrRead" feature depends upon the VM guest actually doing a read of the Modem Status Register (MSR) in polling loops where it waits for input. In short, our polling loops only read the Line Status Register (LSR) to find out if we can receive another character.
I found that simply inserting a read (actually, "inb()") of the MSR in those loops allows the VM guest to stop in these read loops without spinning up the fan in my laptop.