Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vcpu hotplug arm 5.15.12 #13

Open
wants to merge 5 commits into
base: ch-5.15.12
Choose a base branch
from

Conversation

jongwu
Copy link

@jongwu jongwu commented Jun 9, 2022

This patch set enable Vcpu hotplug for arm64, including 5 commit, 4 from Salil Mehta and 1 from Jianyong Wu.

quote from Salil's words:

To support virtual cpu hotplug guest kernel must:

  1. Identify disabled/present vcpus and set/unset the present mask of the vcpu
    during initialization and hotplug event. It must also set the possible mask
    (which includes disabled vcpus) during init of guest kernel.
  2. Provide architecture specific ACPI hooks, for example to map/unmap the
    logical cpuid to hwids/MPIDR. Linux kernel already has generic ACPI cpu
    hotplug framework support.

The last commit fix failure when hot-remove cpu

@jongwu
Copy link
Author

jongwu commented Jun 9, 2022

@justin-he

Salil Mehta and others added 5 commits June 30, 2022 10:19
With ACPI enabled, cpus get identified by the presence of the GICC
entry in the MADT Table. Each GICC entry part of MADT presents cpu as
enabled or disabled. As of now, the disabled cpus are skipped as
physical cpu hotplug is not supported. These remain disabled even after
the kernel has booted.

To support virtual cpu hotplug(in which case disabled vcpus could be
hotplugged even after kernel has booted), QEMU will populate MADT Table
with appropriate details of GICC entry for each possible(present+disabled)
vcpu. Now, during the init time vcpus will be identified as present or
disabled. To achieve this, below changes have been made with respect to
the present/possible vcpu handling along with the mentioned reasoning:

1. Identify all possible(present+disabled) vcpus at boot/init time
   and set their present mask and possible mask. In the existing code,
   cpus are being marked present quite late within smp_prepare_cpus()
   function, which gets called in context to the kernel thread. Since
   the cpu hotplug is not supported, present cpus are always equal to
   the possible cpus. But with cpu hotplug enabled, this assumption is
   not true. Hence, present cpus should be marked while MADT GICC entries
   are bring parsed for each vcpu.
2. Set possible cpus to include disabled. This needs to be done now
   while parsing MADT GICC entries corresponding to each vcpu as the
   disabled vcpu info is available only at this point as for hotplug
   case possible vcpus is not equal to present vcpus.
3. We will store the parsed madt/gicc entry even for the disabled vcpus
   during init time. This is needed as some modules like PMU registers
   IRQs for each possible vcpus during init time. Therefore, a valid
   entry of the MADT GICC should be present for all possible vcpus.
4. Refactoring related to DT/OF is also done to align it with the init
   changes to support vcpu hotplug.

Signed-off-by: Salil Mehta <[email protected]>
Signed-off-by: Xiongfeng Wang <[email protected]>
Bound the total number of identified cpus(including disabled cpus) by
maximum allowed limit by the kernel. Max value is either specified as
part of the kernel parameters 'nr_cpus' or specified during compile
time using CONFIG_NR_CPUS.

Signed-off-by: Salil Mehta <[email protected]>
Signed-off-by: Xiongfeng Wang <[email protected]>
Currently, cpu-operations are only initialized for the cpus which
already have logical cpuid to hwid assoication established. And this
only happens for the cpus which are present during boot time.

To support virtual cpu hotplug, we shall initialize the cpu-operations
for all possible(present+disabled) vcpus. This means logical cpuid to
hwid/mpidr association might not exists(i.e. might be INVALID_HWID)
during init. Later, when the vcpu is actually hotplugged logical cpuid
is allocated and associated with the hwid/mpidr.

This patch does some refactoring to support above change.

Signed-off-by: Salil Mehta <[email protected]>
Signed-off-by: Xiongfeng Wang <[email protected]>
To support virtual cpu hotplug, some arch specific hooks must be
facilitated. These hooks are called by the generic ACPI cpu hotplug
framework during a vcpu hot-(un)plug event handling. The changes
required involve:

1. Allocation of the logical cpuid corresponding to the hwid/mpidr
2. Mapping of logical cpuid to hwid/mpidr and marking present
3. Removing vcpu from present mask during hot-unplug
4. For arm64, all possible cpus are registered within topology_init()
   Hence, we need to override the weak ACPI call of arch_register_cpu()
   (which returns -ENODEV) and return success.
5. NUMA node mapping set for this vcpu using SRAT Table info during init
   time will be discarded as the logical cpu-ids used at that time
   might not be correct. This mapping will be set again using the
   proximity/node info obtained by evaluating _PXM ACPI method.

Note, during hot unplug of vcpu, we do not unmap the association between
the logical cpuid and hwid/mpidr. This remains persistent.

Signed-off-by: Salil Mehta <[email protected]>
Signed-off-by: Xiongfeng Wang <[email protected]>
When hot-remove cpu, the map from cpu to numa will set to NUMA_NO_NODE
which will lead to failure as the map is used by others. Thus we need a
specific map to descrip the unpluged cpu.

Here we introduce a new map to descrip the unpluged cpu map.

Signed-off-by: Jianyong Wu <[email protected]>
@jongwu
Copy link
Author

jongwu commented Jun 30, 2022

@rbradford

@rbradford
Copy link
Member

Looking better. Can you create a PR rebased against ch-5.18.8, check that it works and then send upstream?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants