From: Andrew Morton put this back - hotplug-cpu-migrate-a-task-within-its-cpuset.patch uses it. Cc: Andrea Arcangeli Cc: Christoph Lameter Cc: David Rientjes Signed-off-by: Andrew Morton --- include/linux/cpuset.h | 6 ++++++ kernel/cpuset.c | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff -puN include/linux/cpuset.h~oom-do-not-take-callback_mutex-fix include/linux/cpuset.h --- a/include/linux/cpuset.h~oom-do-not-take-callback_mutex-fix +++ a/include/linux/cpuset.h @@ -59,6 +59,9 @@ extern void __cpuset_memory_pressure_bum extern const struct file_operations proc_cpuset_operations; extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer); +extern void cpuset_lock(void); +extern void cpuset_unlock(void); + extern int cpuset_mem_spread_node(void); static inline int cpuset_do_page_mem_spread(void) @@ -125,6 +128,9 @@ static inline char *cpuset_task_status_a return buffer; } +static inline void cpuset_lock(void) {} +static inline void cpuset_unlock(void) {} + static inline int cpuset_mem_spread_node(void) { return 0; diff -puN kernel/cpuset.c~oom-do-not-take-callback_mutex-fix kernel/cpuset.c --- a/kernel/cpuset.c~oom-do-not-take-callback_mutex-fix +++ a/kernel/cpuset.c @@ -2521,6 +2521,33 @@ int __cpuset_zone_allowed_hardwall(struc } /** + * cpuset_lock - lock out any changes to cpuset structures + * + * The out of memory (oom) code needs to mutex_lock cpusets + * from being changed while it scans the tasklist looking for a + * task in an overlapping cpuset. Expose callback_mutex via this + * cpuset_lock() routine, so the oom code can lock it, before + * locking the task list. The tasklist_lock is a spinlock, so + * must be taken inside callback_mutex. + */ + +void cpuset_lock(void) +{ + mutex_lock(&callback_mutex); +} + +/** + * cpuset_unlock - release lock on cpuset changes + * + * Undo the lock taken in a previous cpuset_lock() call. + */ + +void cpuset_unlock(void) +{ + mutex_unlock(&callback_mutex); +} + +/** * cpuset_mem_spread_node() - On which node to begin search for a page * * If a task is marked PF_SPREAD_PAGE or PF_SPREAD_SLAB (as for _