From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 04/16] cgroup: relocate cgroup_enable_task_cg_lists()
Date: Sun, 9 Feb 2014 08:52:32 -0500 [thread overview]
Message-ID: <1391953964-22088-5-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1391953964-22088-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Move it above so that prototype isn't necessary. Let's also move the
definition of use_task_css_set_links next to it.
This is purely cosmetic.
Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
kernel/cgroup.c | 103 ++++++++++++++++++++++++++------------------------------
1 file changed, 48 insertions(+), 55 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index efae7e2..1ebc6e30 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -173,7 +173,6 @@ static int cgroup_destroy_locked(struct cgroup *cgrp);
static int cgroup_addrm_files(struct cgroup *cgrp, struct cftype cfts[],
bool is_add);
static void cgroup_pidlist_destroy_all(struct cgroup *cgrp);
-static void cgroup_enable_task_cg_lists(void);
/**
* cgroup_css - obtain a cgroup's css for the specified subsystem
@@ -370,14 +369,6 @@ static unsigned long css_set_hash(struct cgroup_subsys_state *css[])
return key;
}
-/*
- * We don't maintain the lists running through each css_set to its task
- * until after the first call to css_task_iter_start(). This reduces the
- * fork()/exit() overhead for people who have cgroups compiled into their
- * kernel but not actually in use.
- */
-static bool use_task_css_set_links __read_mostly;
-
static void __put_css_set(struct css_set *cset, int taskexit)
{
struct cgrp_cset_link *link, *tmp_link;
@@ -1305,6 +1296,54 @@ static int cgroup_remount(struct kernfs_root *kf_root, int *flags, char *data)
return ret;
}
+/*
+ * To reduce the fork() overhead for systems that are not actually using
+ * their cgroups capability, we don't maintain the lists running through
+ * each css_set to its tasks until we see the list actually used - in other
+ * words after the first mount.
+ */
+static bool use_task_css_set_links __read_mostly;
+
+static void cgroup_enable_task_cg_lists(void)
+{
+ struct task_struct *p, *g;
+
+ write_lock(&css_set_lock);
+
+ if (use_task_css_set_links)
+ goto out_unlock;
+
+ use_task_css_set_links = true;
+
+ /*
+ * We need tasklist_lock because RCU is not safe against
+ * while_each_thread(). Besides, a forking task that has passed
+ * cgroup_post_fork() without seeing use_task_css_set_links = 1
+ * is not guaranteed to have its child immediately visible in the
+ * tasklist if we walk through it with RCU.
+ */
+ read_lock(&tasklist_lock);
+ do_each_thread(g, p) {
+ task_lock(p);
+
+ WARN_ON_ONCE(!list_empty(&p->cg_list) ||
+ task_css_set(p) != &init_css_set);
+
+ /*
+ * We should check if the process is exiting, otherwise
+ * it will race with cgroup_exit() in that the list
+ * entry won't be deleted though the process has exited.
+ */
+ if (!(p->flags & PF_EXITING))
+ list_add(&p->cg_list, &task_css_set(p)->tasks);
+
+ task_unlock(p);
+ } while_each_thread(g, p);
+ read_unlock(&tasklist_lock);
+out_unlock:
+ write_unlock(&css_set_lock);
+}
+
static void init_cgroup_housekeeping(struct cgroup *cgrp)
{
atomic_set(&cgrp->refcnt, 1);
@@ -2363,52 +2402,6 @@ int cgroup_task_count(const struct cgroup *cgrp)
return count;
}
-/*
- * To reduce the fork() overhead for systems that are not actually using
- * their cgroups capability, we don't maintain the lists running through
- * each css_set to its tasks until we see the list actually used - in other
- * words after the first mount.
- */
-static void cgroup_enable_task_cg_lists(void)
-{
- struct task_struct *p, *g;
-
- write_lock(&css_set_lock);
-
- if (use_task_css_set_links)
- goto out_unlock;
-
- use_task_css_set_links = true;
-
- /*
- * We need tasklist_lock because RCU is not safe against
- * while_each_thread(). Besides, a forking task that has passed
- * cgroup_post_fork() without seeing use_task_css_set_links = 1
- * is not guaranteed to have its child immediately visible in the
- * tasklist if we walk through it with RCU.
- */
- read_lock(&tasklist_lock);
- do_each_thread(g, p) {
- task_lock(p);
-
- WARN_ON_ONCE(!list_empty(&p->cg_list) ||
- task_css_set(p) != &init_css_set);
-
- /*
- * We should check if the process is exiting, otherwise
- * it will race with cgroup_exit() in that the list
- * entry won't be deleted though the process has exited.
- */
- if (!(p->flags & PF_EXITING))
- list_add(&p->cg_list, &task_css_set(p)->tasks);
-
- task_unlock(p);
- } while_each_thread(g, p);
- read_unlock(&tasklist_lock);
-out_unlock:
- write_unlock(&css_set_lock);
-}
-
/**
* css_next_child - find the next child of a given css
* @pos_css: the current position (%NULL to initiate traversal)
--
1.8.5.3
WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: lizefan@huawei.com
Cc: containers@lists.linux-foundation.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 04/16] cgroup: relocate cgroup_enable_task_cg_lists()
Date: Sun, 9 Feb 2014 08:52:32 -0500 [thread overview]
Message-ID: <1391953964-22088-5-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1391953964-22088-1-git-send-email-tj@kernel.org>
Move it above so that prototype isn't necessary. Let's also move the
definition of use_task_css_set_links next to it.
This is purely cosmetic.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/cgroup.c | 103 ++++++++++++++++++++++++++------------------------------
1 file changed, 48 insertions(+), 55 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index efae7e2..1ebc6e30 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -173,7 +173,6 @@ static int cgroup_destroy_locked(struct cgroup *cgrp);
static int cgroup_addrm_files(struct cgroup *cgrp, struct cftype cfts[],
bool is_add);
static void cgroup_pidlist_destroy_all(struct cgroup *cgrp);
-static void cgroup_enable_task_cg_lists(void);
/**
* cgroup_css - obtain a cgroup's css for the specified subsystem
@@ -370,14 +369,6 @@ static unsigned long css_set_hash(struct cgroup_subsys_state *css[])
return key;
}
-/*
- * We don't maintain the lists running through each css_set to its task
- * until after the first call to css_task_iter_start(). This reduces the
- * fork()/exit() overhead for people who have cgroups compiled into their
- * kernel but not actually in use.
- */
-static bool use_task_css_set_links __read_mostly;
-
static void __put_css_set(struct css_set *cset, int taskexit)
{
struct cgrp_cset_link *link, *tmp_link;
@@ -1305,6 +1296,54 @@ static int cgroup_remount(struct kernfs_root *kf_root, int *flags, char *data)
return ret;
}
+/*
+ * To reduce the fork() overhead for systems that are not actually using
+ * their cgroups capability, we don't maintain the lists running through
+ * each css_set to its tasks until we see the list actually used - in other
+ * words after the first mount.
+ */
+static bool use_task_css_set_links __read_mostly;
+
+static void cgroup_enable_task_cg_lists(void)
+{
+ struct task_struct *p, *g;
+
+ write_lock(&css_set_lock);
+
+ if (use_task_css_set_links)
+ goto out_unlock;
+
+ use_task_css_set_links = true;
+
+ /*
+ * We need tasklist_lock because RCU is not safe against
+ * while_each_thread(). Besides, a forking task that has passed
+ * cgroup_post_fork() without seeing use_task_css_set_links = 1
+ * is not guaranteed to have its child immediately visible in the
+ * tasklist if we walk through it with RCU.
+ */
+ read_lock(&tasklist_lock);
+ do_each_thread(g, p) {
+ task_lock(p);
+
+ WARN_ON_ONCE(!list_empty(&p->cg_list) ||
+ task_css_set(p) != &init_css_set);
+
+ /*
+ * We should check if the process is exiting, otherwise
+ * it will race with cgroup_exit() in that the list
+ * entry won't be deleted though the process has exited.
+ */
+ if (!(p->flags & PF_EXITING))
+ list_add(&p->cg_list, &task_css_set(p)->tasks);
+
+ task_unlock(p);
+ } while_each_thread(g, p);
+ read_unlock(&tasklist_lock);
+out_unlock:
+ write_unlock(&css_set_lock);
+}
+
static void init_cgroup_housekeeping(struct cgroup *cgrp)
{
atomic_set(&cgrp->refcnt, 1);
@@ -2363,52 +2402,6 @@ int cgroup_task_count(const struct cgroup *cgrp)
return count;
}
-/*
- * To reduce the fork() overhead for systems that are not actually using
- * their cgroups capability, we don't maintain the lists running through
- * each css_set to its tasks until we see the list actually used - in other
- * words after the first mount.
- */
-static void cgroup_enable_task_cg_lists(void)
-{
- struct task_struct *p, *g;
-
- write_lock(&css_set_lock);
-
- if (use_task_css_set_links)
- goto out_unlock;
-
- use_task_css_set_links = true;
-
- /*
- * We need tasklist_lock because RCU is not safe against
- * while_each_thread(). Besides, a forking task that has passed
- * cgroup_post_fork() without seeing use_task_css_set_links = 1
- * is not guaranteed to have its child immediately visible in the
- * tasklist if we walk through it with RCU.
- */
- read_lock(&tasklist_lock);
- do_each_thread(g, p) {
- task_lock(p);
-
- WARN_ON_ONCE(!list_empty(&p->cg_list) ||
- task_css_set(p) != &init_css_set);
-
- /*
- * We should check if the process is exiting, otherwise
- * it will race with cgroup_exit() in that the list
- * entry won't be deleted though the process has exited.
- */
- if (!(p->flags & PF_EXITING))
- list_add(&p->cg_list, &task_css_set(p)->tasks);
-
- task_unlock(p);
- } while_each_thread(g, p);
- read_unlock(&tasklist_lock);
-out_unlock:
- write_unlock(&css_set_lock);
-}
-
/**
* css_next_child - find the next child of a given css
* @pos_css: the current position (%NULL to initiate traversal)
--
1.8.5.3
next prev parent reply other threads:[~2014-02-09 13:52 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-09 13:52 [PATCHSET cgroup/for-3.15] cgroup: more cleanups Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 05/16] cgroup: implement cgroup_has_tasks() and unexport cgroup_task_count() Tejun Heo
[not found] ` <1391953964-22088-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-02-10 12:36 ` Michal Hocko
2014-02-10 12:36 ` Michal Hocko
2014-02-10 12:36 ` Michal Hocko
2014-02-09 13:52 ` [PATCH 11/16] cgroup: move css_set_rwsem locking outside of cgroup_task_migrate() Tejun Heo
2014-02-09 13:52 ` [PATCH 13/16] cpuset: don't use cgroup_taskset_cur_css() Tejun Heo
2014-02-09 13:52 ` [PATCH 14/16] cgroup: remove cgroup_taskset_cur_css() and cgroup_taskset_size() Tejun Heo
2014-02-09 13:52 ` [PATCH 15/16] cgroup: cosmetic updates to cgroup_attach_task() Tejun Heo
[not found] ` <1391953964-22088-16-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-02-10 23:06 ` [PATCH v2 " Tejun Heo
2014-02-10 23:06 ` Tejun Heo
2014-02-10 23:06 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 16/16] cgroup: unexport functions Tejun Heo
[not found] ` <1391953964-22088-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-02-09 13:52 ` [PATCH 01/16] cgroup: disallow xattr, release_agent and name if sane_behavior Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 02/16] cgroup: drop CGRP_ROOT_SUBSYS_BOUND Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 03/16] cgroup: enable task_cg_lists on the first cgroup mount Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` Tejun Heo [this message]
2014-02-09 13:52 ` [PATCH 04/16] cgroup: relocate cgroup_enable_task_cg_lists() Tejun Heo
2014-02-09 13:52 ` [PATCH 05/16] cgroup: implement cgroup_has_tasks() and unexport cgroup_task_count() Tejun Heo
2014-02-09 13:52 ` [PATCH 06/16] cgroup: reimplement cgroup_transfer_tasks() without using css_scan_tasks() Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 07/16] cgroup: make css_set_lock a rwsem and rename it to css_set_rwsem Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 08/16] cpuset: use css_task_iter_start/next/end() instead of css_scan_tasks() Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 09/16] cgroup: remove css_scan_tasks() Tejun Heo
2014-02-09 13:52 ` Tejun Heo
[not found] ` <1391953964-22088-10-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-02-13 2:01 ` Li Zefan
2014-02-13 2:01 ` Li Zefan
2014-02-09 13:52 ` [PATCH 10/16] cgroup: separate out put_css_set_locked() and remove put_css_set_taskexit() Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 11/16] cgroup: move css_set_rwsem locking outside of cgroup_task_migrate() Tejun Heo
2014-02-09 13:52 ` [PATCH 12/16] cgroup: drop @skip_css from cgroup_taskset_for_each() Tejun Heo
2014-02-09 13:52 ` Tejun Heo
2014-02-09 13:52 ` [PATCH 13/16] cpuset: don't use cgroup_taskset_cur_css() Tejun Heo
2014-02-09 13:52 ` [PATCH 14/16] cgroup: remove cgroup_taskset_cur_css() and cgroup_taskset_size() Tejun Heo
2014-02-09 13:52 ` [PATCH 15/16] cgroup: cosmetic updates to cgroup_attach_task() Tejun Heo
2014-02-09 13:52 ` [PATCH 16/16] cgroup: unexport functions Tejun Heo
2014-02-13 2:01 ` [PATCHSET cgroup/for-3.15] cgroup: more cleanups Li Zefan
2014-02-13 2:01 ` Li Zefan
2014-02-13 11:59 ` Tejun Heo
2014-02-13 11:59 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1391953964-22088-5-git-send-email-tj@kernel.org \
--to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.