diff options
author | Roman Gushchin <guro@fb.com> | 2019-11-15 17:34:46 -0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-12-19 15:59:01 +0000 |
commit | bd0469d848a5722d7676d1c88c8a3fd57cf0b44a (patch) | |
tree | 17a0866ad059c91d5457879756721790cb0bb551 /mm | |
parent | 920c7230b861076a1478571445f006c180dc91bf (diff) | |
download | linux-stable-bd0469d848a5722d7676d1c88c8a3fd57cf0b44a.tar.gz linux-stable-bd0469d848a5722d7676d1c88c8a3fd57cf0b44a.tar.bz2 linux-stable-bd0469d848a5722d7676d1c88c8a3fd57cf0b44a.zip |
mm: hugetlb: switch to css_tryget() in hugetlb_cgroup_charge_cgroup()
commit 0362f326d86c645b5e96b7dbc3ee515986ed019d upstream.
An exiting task might belong to an offline cgroup. In this case an
attempt to grab a cgroup reference from the task can end up with an
infinite loop in hugetlb_cgroup_charge_cgroup(), because neither the
cgroup will become online, neither the task will be migrated to a live
cgroup.
Fix this by switching over to css_tryget(). As css_tryget_online()
can't guarantee that the cgroup won't go offline, in most cases the
check doesn't make sense. In this particular case users of
hugetlb_cgroup_charge_cgroup() are not affected by this change.
A similar problem is described by commit 18fa84a2db0e ("cgroup: Use
css_tryget() instead of css_tryget_online() in task_get_css()").
Link: http://lkml.kernel.org/r/20191106225131.3543616-2-guro@fb.com
Signed-off-by: Roman Gushchin <guro@fb.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/hugetlb_cgroup.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 493f758445e7..08b225f26eb2 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -181,7 +181,7 @@ int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages, again: rcu_read_lock(); h_cg = hugetlb_cgroup_from_task(current); - if (!css_tryget_online(&h_cg->css)) { + if (!css_tryget(&h_cg->css)) { rcu_read_unlock(); goto again; } |