Skip to content

Commit

Permalink
xen/acpi: ACPI cpu hotplug
Browse files Browse the repository at this point in the history
This patch implement real Xen ACPI cpu hotplug driver as module.
When loaded, it replaces Xen stub driver.

For booting existed cpus, the driver enumerates them.
For hotadded cpus, which added at runtime and notify OS via
device or container event, the driver is invoked to add them,
parsing cpu information, hypercalling to Xen hypervisor to add
them, and finally setting up new /sys interface for them.

Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Liu Jinsong authored and Konrad Rzeszutek Wilk committed Feb 20, 2013
1 parent 40a5863 commit 39adc48
Show file tree
Hide file tree
Showing 6 changed files with 530 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/xen/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ config XEN_ACPI_HOTPLUG_MEMORY
to hot-add memory at runtime (the hot-added memory cannot be
removed until machine stop), select Y/M here, otherwise select N.

config XEN_ACPI_HOTPLUG_CPU
tristate "Xen ACPI cpu hotplug"
depends on XEN_DOM0 && XEN_STUB && ACPI
select ACPI_CONTAINER
default n
help
Xen ACPI cpu enumerating and hotplugging

For hotplugging, currently Xen only support ACPI cpu hotadd.
If you want to hotadd cpu at runtime (the hotadded cpu cannot
be removed until machine stop), select Y/M here.

config XEN_ACPI_PROCESSOR
tristate "Xen ACPI processor"
depends on XEN && X86 && ACPI_PROCESSOR && CPU_FREQ
Expand Down
1 change: 1 addition & 0 deletions drivers/xen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/
obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o
obj-$(CONFIG_XEN_STUB) += xen-stub.o
obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o
obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o
obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o
xen-evtchn-y := evtchn.o
xen-gntdev-y := gntdev.o
Expand Down
35 changes: 35 additions & 0 deletions drivers/xen/pcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,41 @@ static irqreturn_t xen_pcpu_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}

/* Sync with Xen hypervisor after cpu hotadded */
void xen_pcpu_hotplug_sync(void)
{
schedule_work(&xen_pcpu_work);
}
EXPORT_SYMBOL_GPL(xen_pcpu_hotplug_sync);

/*
* For hypervisor presented cpu, return logic cpu id;
* For hypervisor non-presented cpu, return -ENODEV.
*/
int xen_pcpu_id(uint32_t acpi_id)
{
int cpu_id = 0, max_id = 0;
struct xen_platform_op op;

op.cmd = XENPF_get_cpuinfo;
while (cpu_id <= max_id) {
op.u.pcpu_info.xen_cpuid = cpu_id;
if (HYPERVISOR_dom0_op(&op)) {
cpu_id++;
continue;
}

if (acpi_id == op.u.pcpu_info.acpi_id)
return cpu_id;
if (op.u.pcpu_info.max_present > max_id)
max_id = op.u.pcpu_info.max_present;
cpu_id++;
}

return -ENODEV;
}
EXPORT_SYMBOL_GPL(xen_pcpu_id);

static int __init xen_pcpu_init(void)
{
int irq, ret;
Expand Down
Loading

0 comments on commit 39adc48

Please sign in to comment.