From: Greg Kroah-Hartman Date: Thu, 11 Oct 2018 09:32:00 +0000 (+0200) Subject: 3.18-stable patches X-Git-Tag: v3.18.124~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da5f0cec0547f4b8ef44864506967b312f135608;p=thirdparty%2Fkernel%2Fstable-queue.git 3.18-stable patches added patches: cgroup-fix-deadlock-in-cpu-hotplug-path.patch --- diff --git a/queue-3.18/cgroup-fix-deadlock-in-cpu-hotplug-path.patch b/queue-3.18/cgroup-fix-deadlock-in-cpu-hotplug-path.patch new file mode 100644 index 00000000000..65fb593f988 --- /dev/null +++ b/queue-3.18/cgroup-fix-deadlock-in-cpu-hotplug-path.patch @@ -0,0 +1,81 @@ +From 116d2f7496c51b2e02e8e4ecdd2bdf5fb9d5a641 Mon Sep 17 00:00:00 2001 +From: Prateek Sood +Date: Tue, 19 Dec 2017 12:56:57 +0530 +Subject: cgroup: Fix deadlock in cpu hotplug path + +From: Prateek Sood + +commit 116d2f7496c51b2e02e8e4ecdd2bdf5fb9d5a641 upstream. + +Deadlock during cgroup migration from cpu hotplug path when a task T is +being moved from source to destination cgroup. + +kworker/0:0 +cpuset_hotplug_workfn() + cpuset_hotplug_update_tasks() + hotplug_update_tasks_legacy() + remove_tasks_in_empty_cpuset() + cgroup_transfer_tasks() // stuck in iterator loop + cgroup_migrate() + cgroup_migrate_add_task() + +In cgroup_migrate_add_task() it checks for PF_EXITING flag of task T. +Task T will not migrate to destination cgroup. css_task_iter_start() +will keep pointing to task T in loop waiting for task T cg_list node +to be removed. + +Task T +do_exit() + exit_signals() // sets PF_EXITING + exit_task_namespaces() + switch_task_namespaces() + free_nsproxy() + put_mnt_ns() + drop_collected_mounts() + namespace_unlock() + synchronize_rcu() + _synchronize_rcu_expedited() + schedule_work() // on cpu0 low priority worker pool + wait_event() // waiting for work item to execute + +Task T inserted a work item in the worklist of cpu0 low priority +worker pool. It is waiting for expedited grace period work item +to execute. This work item will only be executed once kworker/0:0 +complete execution of cpuset_hotplug_workfn(). + +kworker/0:0 ==> Task T ==>kworker/0:0 + +In case of PF_EXITING task being migrated from source to destination +cgroup, migrate next available task in source cgroup. + +Signed-off-by: Prateek Sood +Signed-off-by: Tejun Heo +[AmitP: Upstream commit cherry-pick failed, so I picked the + backported changes from CAF/msm-4.9 tree instead: + https://source.codeaurora.org/quic/la/kernel/msm-4.9/commit/?id=49b74f1696417b270c89cd893ca9f37088928078] +Signed-off-by: Amit Pundir +Signed-off-by: Greg Kroah-Hartman +--- +This patch can be cleanly applied and build tested on 4.4.y and 3.18.y +as well but I couldn't find it in msm-4.4 and msm-3.18 trees. So this +patch is really untested on those stable trees. +Build tested on 4.9.131, 4.4.159 and 3.18.123 for ARCH=arm/arm64 allmodconfig. + + kernel/cgroup.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/kernel/cgroup.c ++++ b/kernel/cgroup.c +@@ -3669,7 +3669,11 @@ int cgroup_transfer_tasks(struct cgroup + */ + do { + css_task_iter_start(&from->self, &it); +- task = css_task_iter_next(&it); ++ ++ do { ++ task = css_task_iter_next(&it); ++ } while (task && (task->flags & PF_EXITING)); ++ + if (task) + get_task_struct(task); + css_task_iter_end(&it); diff --git a/queue-3.18/series b/queue-3.18/series index 9cefb4c0db6..2f8b42e5030 100644 --- a/queue-3.18/series +++ b/queue-3.18/series @@ -115,3 +115,4 @@ ext4-never-move-the-system.data-xattr-out-of-the-inode-body.patch ext4-add-more-inode-number-paranoia-checks.patch jbd2-don-t-mark-block-as-modified-if-the-handle-is-out-of-credits.patch ext4-avoid-running-out-of-journal-credits-when-appending-to-an-inline-file.patch +cgroup-fix-deadlock-in-cpu-hotplug-path.patch