VirtualBox

Ticket #19903 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

VBoxService CPU hotplug brings always cpu1 online regardless of plugged CPU => fixed in SVN/next maintenance

Reported by: musteresel Owned by:
Component: guest additions Version: VirtualBox 6.1.6
Keywords: hotplug Cc:
Guest type: Linux Host type: Linux

Description

The code to bring a newly plugged CPU online is seriously wrong, textual description of what is done there:

  • Lists all files under /sys/devices/system/cpu
  • Iterates over these, one after the other
  • If current file name starts with "cpu" but is not "cpu0" nor "cpuidle", then
  • Tries to open /sys/devices/system/cpu/FILENAME/online and write 1 to it
  • If that succeeds (for ONE single file), calls it a day and returns.

Actual code is here: https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Additions/common/VBoxService/VBoxServiceCpuHotPlug.cpp#L449

Assuming (?) that the directory listing is sorted by name, this will always put cpu1 (and only that!) online.

---

Stumbled over this while trying to find out why my CPU (cpu2 ... cpu1 comes before that in the directory listing) isn't online prior to getting it back offline (https://www.virtualbox.org/ticket/19902)

Change History

comment:1 Changed 3 years ago by musteresel

Suggestion for a better approach:

  • Parse /sys/devices/system/cpu/offline to get currently offline CPUs
  • One after the other:
    • Turn that cpu on
    • Look into /sys/devices/system/cpu/cpuX/topology/{core_id,physical_package_id} for the core and package id of that CPU
    • If that matches the CPU which was plugged, fine, return.
    • Else, turn the CPU off again and continue with the next initially offline CPU.

If necessary one could also look through the currently online CPUs to see if the hotplugged CPU is there already.

If there's interest I can make a patch. I'm not sure about the support of the various files across Linux kernel versions, however. Also perhaps there is a way to get the topology of an offline CPU without turning it on?

comment:2 Changed 3 years ago by aeichner

Thanks for the report, should be fixed in the next maintenance release. There is a new testbuild available on Testbuilds, >= r140448. You only need to update the guest additions if you want to try it out. I decided against turning potentially all CPUs on to find the one with the matching topology as it could induce quite some load for VMs with many CPUs, instead the first offline CPU found is being enabled. I couldn't find a way to get the CPU topology from an offline CPU so far, not even when running in the kernel.

comment:3 Changed 3 years ago by aeichner

  • Summary changed from VBoxService CPU hotplug brings always cpu1 online regardless of plugged CPU to VBoxService CPU hotplug brings always cpu1 online regardless of plugged CPU => fixed in SVN/next maintenance

comment:4 Changed 3 years ago by musteresel

Yes, test build fixes this. I'm looking whether I can find a way to get the topology of an offline cpu and let you know if I find something!

comment:5 Changed 3 years ago by arudnev

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in 6.1.16

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use