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

cpu/hotplug: handle unbalanced hotplug enable/disable #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ void cpu_hotplug_done(void)
cpuhp_lock_release();
}

static void _cpu_hotplug_disable(void)
{
cpu_hotplug_disabled++;
}

static void _cpu_hotplug_enable(void)
{
if (WARN(!cpu_hotplug_disabled, "Unbalanced cpu hotplug enable\n"))
return;

cpu_hotplug_disabled--;
}

/*
* Wait for currently running CPU hotplug operations to complete (if any) and
* disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects
Expand All @@ -255,15 +268,15 @@ void cpu_hotplug_done(void)
void cpu_hotplug_disable(void)
{
cpu_maps_update_begin();
cpu_hotplug_disabled++;
_cpu_hotplug_disable();
cpu_maps_update_done();
}
EXPORT_SYMBOL_GPL(cpu_hotplug_disable);

void cpu_hotplug_enable(void)
{
cpu_maps_update_begin();
WARN_ON(--cpu_hotplug_disabled < 0);
_cpu_hotplug_enable();
cpu_maps_update_done();
}
EXPORT_SYMBOL_GPL(cpu_hotplug_enable);
Expand Down Expand Up @@ -1054,7 +1067,7 @@ int disable_nonboot_cpus(void)
* this even in case of failure as all disable_nonboot_cpus() users are
* supposed to do enable_nonboot_cpus() on the failure path.
*/
cpu_hotplug_disabled++;
_cpu_hotplug_disable();

cpu_maps_update_done();
return error;
Expand All @@ -1074,7 +1087,7 @@ void enable_nonboot_cpus(void)

/* Allow everyone to use the CPU hotplug again */
cpu_maps_update_begin();
WARN_ON(--cpu_hotplug_disabled < 0);
_cpu_hotplug_enable();
if (cpumask_empty(frozen_cpus))
goto out;

Expand Down