Skip to content

Commit

Permalink
watchdog/core: Rework CPU hotplug locking
Browse files Browse the repository at this point in the history
The watchdog proc interface causes extensive recursive locking of the CPU
hotplug percpu rwsem, which is deadlock prone.

Replace the get/put_online_cpus() pairs with cpu_hotplug_disable()/enable()
calls for now. Later patches will remove that requirement completely.

Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Don Zickus <dzickus@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Link: http://lkml.kernel.org/r/20170912194146.568079057@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Thomas Gleixner authored and Ingo Molnar committed Sep 14, 2017
1 parent 5490125 commit b7a3498
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kernel/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write,
int err, old, new;
int *watchdog_param = (int *)table->data;

get_online_cpus();
cpu_hotplug_disable();
mutex_lock(&watchdog_proc_mutex);

/*
Expand Down Expand Up @@ -752,7 +752,7 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write,
}
out:
mutex_unlock(&watchdog_proc_mutex);
put_online_cpus();
cpu_hotplug_enable();
return err;
}

Expand Down Expand Up @@ -794,7 +794,7 @@ int proc_watchdog_thresh(struct ctl_table *table, int write,
{
int err, old, new;

get_online_cpus();
cpu_hotplug_disable();
mutex_lock(&watchdog_proc_mutex);

old = ACCESS_ONCE(watchdog_thresh);
Expand All @@ -818,7 +818,7 @@ int proc_watchdog_thresh(struct ctl_table *table, int write,
}
out:
mutex_unlock(&watchdog_proc_mutex);
put_online_cpus();
cpu_hotplug_enable();
return err;
}

Expand All @@ -833,7 +833,7 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write,
{
int err;

get_online_cpus();
cpu_hotplug_disable();
mutex_lock(&watchdog_proc_mutex);

err = proc_do_large_bitmap(table, write, buffer, lenp, ppos);
Expand All @@ -856,7 +856,7 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write,
}

mutex_unlock(&watchdog_proc_mutex);
put_online_cpus();
cpu_hotplug_enable();
return err;
}

Expand Down

0 comments on commit b7a3498

Please sign in to comment.