From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751667AbbJJDbL (ORCPT ); Fri, 9 Oct 2015 23:31:11 -0400 Received: from mail-ig0-f176.google.com ([209.85.213.176]:37986 "EHLO mail-ig0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751608AbbJJDbG (ORCPT ); Fri, 9 Oct 2015 23:31:06 -0400 From: Tejun Heo To: lizefan@huawei.com, hannes@cmpxchg.org Cc: cgroups@vger.kernel.org, cyphar@cyphar.com, linux-kernel@vger.kernel.org, kernel-team@fb.com, Tejun Heo Subject: [PATCH 06/14] cgroup: make css_sets pin the associated cgroups Date: Fri, 9 Oct 2015 23:29:33 -0400 Message-Id: <1444447781-16182-7-git-send-email-tj@kernel.org> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444447781-16182-1-git-send-email-tj@kernel.org> References: <1444447781-16182-1-git-send-email-tj@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, css_sets don't pin the associated cgroups. This is okay as a cgroup with css_sets associated are not allowed to be removed; however, to help resource tracking for zombie tasks, this is scheduled to change such that a cgroup can be removed even when it has css_sets associated as long as none of them are populated. To ensure that a cgroup doesn't go away while css_sets are still associated with it, make each associated css_set hold a reference on the cgroup. Signed-off-by: Tejun Heo --- kernel/cgroup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index ab5c9a5..ba11496 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -705,6 +705,7 @@ static void put_css_set_locked(struct css_set *cset) list_for_each_entry_safe(link, tmp_link, &cset->cgrp_links, cgrp_link) { list_del(&link->cset_link); list_del(&link->cgrp_link); + cgroup_put(link->cgrp); kfree(link); } @@ -919,6 +920,8 @@ static void link_css_set(struct list_head *tmp_links, struct css_set *cset, * is sorted by order of hierarchy creation */ list_add_tail(&link->cgrp_link, &cset->cgrp_links); + + cgroup_get(cgrp); } /** @@ -4998,10 +5001,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp) lockdep_assert_held(&cgroup_mutex); - /* - * css_set_rwsem synchronizes access to ->cset_links and prevents - * @cgrp from being removed while put_css_set() is in progress. - */ + /* css_set_rwsem synchronizes access to ->cset_links */ down_read(&css_set_rwsem); empty = list_empty(&cgrp->cset_links); up_read(&css_set_rwsem); -- 2.4.3