Commit 026085ef5ae07c3197f2baacc091ce067b86ed11
Committed by
Tejun Heo
1 parent
c84cdf75cc
Exists in
master
and in
6 other branches
cgroup: remove redundant get/put of old css_set from migrate
We can now assume that the css_set reference held by the task will not go away for an exiting task. PF_EXITING state can be trusted throughout migration by checking it after locking threadgroup. Changes in V4: * https://lkml.org/lkml/2011/12/20/368 (Tejun Heo) * Fix typo in commit message * Undid the rename of css_set_check_fetched * https://lkml.org/lkml/2011/12/20/427 (Li Zefan) * Fix comment in cgroup_task_migrate() Changes in V3: * https://lkml.org/lkml/2011/12/20/255 (Frederic Weisbecker) * Fixed to put error in retval Changes in V2: * https://lkml.org/lkml/2011/12/19/289 (Tejun Heo) * Updated commit message -tj: removed stale patch description about dropped function rename. Signed-off-by: Mandeep Singh Baines <msb@chromium.org> Acked-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Tejun Heo <tj@kernel.org> Cc: containers@lists.linux-foundation.org Cc: cgroups@vger.kernel.org Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Paul Menage <paul@paulmenage.org>
Showing 1 changed file with 8 additions and 20 deletions Side-by-side Diff
kernel/cgroup.c
... | ... | @@ -1850,14 +1850,12 @@ |
1850 | 1850 | struct css_set *newcg; |
1851 | 1851 | |
1852 | 1852 | /* |
1853 | - * get old css_set. We are synchronized through threadgroup_lock() | |
1854 | - * against PF_EXITING setting such that we can't race against | |
1855 | - * cgroup_exit() changing the css_set to init_css_set and dropping the | |
1856 | - * old one. | |
1853 | + * We are synchronized through threadgroup_lock() against PF_EXITING | |
1854 | + * setting such that we can't race against cgroup_exit() changing the | |
1855 | + * css_set to init_css_set and dropping the old one. | |
1857 | 1856 | */ |
1858 | 1857 | WARN_ON_ONCE(tsk->flags & PF_EXITING); |
1859 | 1858 | oldcg = tsk->cgroups; |
1860 | - get_css_set(oldcg); | |
1861 | 1859 | |
1862 | 1860 | /* locate or allocate a new css_set for this task. */ |
1863 | 1861 | if (guarantee) { |
1864 | 1862 | |
1865 | 1863 | |
... | ... | @@ -1872,12 +1870,9 @@ |
1872 | 1870 | might_sleep(); |
1873 | 1871 | /* find_css_set will give us newcg already referenced. */ |
1874 | 1872 | newcg = find_css_set(oldcg, cgrp); |
1875 | - if (!newcg) { | |
1876 | - put_css_set(oldcg); | |
1873 | + if (!newcg) | |
1877 | 1874 | return -ENOMEM; |
1878 | - } | |
1879 | 1875 | } |
1880 | - put_css_set(oldcg); | |
1881 | 1876 | |
1882 | 1877 | task_lock(tsk); |
1883 | 1878 | rcu_assign_pointer(tsk->cgroups, newcg); |
1884 | 1879 | |
... | ... | @@ -2186,18 +2181,11 @@ |
2186 | 2181 | * init_css_set. |
2187 | 2182 | */ |
2188 | 2183 | oldcg = tc->task->cgroups; |
2189 | - get_css_set(oldcg); | |
2190 | - /* see if the new one for us is already in the list? */ | |
2191 | - if (css_set_check_fetched(cgrp, tc->task, oldcg, &newcg_list)) { | |
2192 | - /* was already there, nothing to do. */ | |
2193 | - put_css_set(oldcg); | |
2194 | - } else { | |
2195 | - /* we don't already have it. get new one. */ | |
2196 | - retval = css_set_prefetch(cgrp, oldcg, &newcg_list); | |
2197 | - put_css_set(oldcg); | |
2198 | - if (retval) | |
2184 | + | |
2185 | + /* if we don't already have it in the list get a new one */ | |
2186 | + if (!css_set_check_fetched(cgrp, tc->task, oldcg, &newcg_list)) | |
2187 | + if (retval = css_set_prefetch(cgrp, oldcg, &newcg_list)) | |
2199 | 2188 | goto out_list_teardown; |
2200 | - } | |
2201 | 2189 | } |
2202 | 2190 | |
2203 | 2191 | /* |