mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
cgroup: remove cgroup->name
cgroup->name handling became quite complicated over time involving
dedicated struct cgroup_name for RCU protection. Now that cgroup is
on kernfs, we can drop all of it and simply use kernfs_name/path() and
friends. Replace cgroup->name and all related code with kernfs
name/path constructs.
* Reimplement cgroup_name() and cgroup_path() as thin wrappers on top
of kernfs counterparts, which involves semantic changes.
pr_cont_cgroup_name() and pr_cont_cgroup_path() added.
* cgroup->name handling dropped from cgroup_rename().
* All users of cgroup_name/path() updated to the new semantics. Users
which were formatting the string just to printk them are converted
to use pr_cont_cgroup_name/path() instead, which simplifies things
quite a bit. As cgroup_name() no longer requires RCU read lock
around it, RCU lockings which were protecting only cgroup_name() are
removed.
v2: Comment above oom_info_lock updated as suggested by Michal.
v3: dummy_top doesn't have a kn associated and
pr_cont_cgroup_name/path() ended up calling the matching kernfs
functions with NULL kn leading to oops. Test for NULL kn and
print "/" if so. This issue was reported by Fengguang Wu.
v4: Rebased on top of 0ab02ca8f8
("cgroup: protect modifications to
cgroup_idr with cgroup_mutex").
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
This commit is contained in:
parent
6f30558f37
commit
e61734c55c
7 changed files with 110 additions and 210 deletions
|
@ -138,11 +138,6 @@ enum {
|
|||
CGRP_SANE_BEHAVIOR,
|
||||
};
|
||||
|
||||
struct cgroup_name {
|
||||
struct rcu_head rcu_head;
|
||||
char name[];
|
||||
};
|
||||
|
||||
struct cgroup {
|
||||
unsigned long flags; /* "unsigned long" so bitops work */
|
||||
|
||||
|
@ -179,19 +174,6 @@ struct cgroup {
|
|||
*/
|
||||
u64 serial_nr;
|
||||
|
||||
/*
|
||||
* This is a copy of dentry->d_name, and it's needed because
|
||||
* we can't use dentry->d_name in cgroup_path().
|
||||
*
|
||||
* You must acquire rcu_read_lock() to access cgrp->name, and
|
||||
* the only place that can change it is rename(), which is
|
||||
* protected by parent dir's i_mutex.
|
||||
*
|
||||
* Normally you should use cgroup_name() wrapper rather than
|
||||
* access it directly.
|
||||
*/
|
||||
struct cgroup_name __rcu *name;
|
||||
|
||||
/* Private pointers for each registered subsystem */
|
||||
struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT];
|
||||
|
||||
|
@ -479,12 +461,6 @@ static inline bool cgroup_sane_behavior(const struct cgroup *cgrp)
|
|||
return cgrp->root->flags & CGRP_ROOT_SANE_BEHAVIOR;
|
||||
}
|
||||
|
||||
/* Caller should hold rcu_read_lock() */
|
||||
static inline const char *cgroup_name(const struct cgroup *cgrp)
|
||||
{
|
||||
return rcu_dereference(cgrp->name)->name;
|
||||
}
|
||||
|
||||
/* returns ino associated with a cgroup, 0 indicates unmounted root */
|
||||
static inline ino_t cgroup_ino(struct cgroup *cgrp)
|
||||
{
|
||||
|
@ -503,14 +479,47 @@ static inline struct cftype *seq_cft(struct seq_file *seq)
|
|||
|
||||
struct cgroup_subsys_state *seq_css(struct seq_file *seq);
|
||||
|
||||
/*
|
||||
* Name / path handling functions. All are thin wrappers around the kernfs
|
||||
* counterparts and can be called under any context.
|
||||
*/
|
||||
|
||||
static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen)
|
||||
{
|
||||
return kernfs_name(cgrp->kn, buf, buflen);
|
||||
}
|
||||
|
||||
static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf,
|
||||
size_t buflen)
|
||||
{
|
||||
return kernfs_path(cgrp->kn, buf, buflen);
|
||||
}
|
||||
|
||||
static inline void pr_cont_cgroup_name(struct cgroup *cgrp)
|
||||
{
|
||||
/* dummy_top doesn't have a kn associated */
|
||||
if (cgrp->kn)
|
||||
pr_cont_kernfs_name(cgrp->kn);
|
||||
else
|
||||
pr_cont("/");
|
||||
}
|
||||
|
||||
static inline void pr_cont_cgroup_path(struct cgroup *cgrp)
|
||||
{
|
||||
/* dummy_top doesn't have a kn associated */
|
||||
if (cgrp->kn)
|
||||
pr_cont_kernfs_path(cgrp->kn);
|
||||
else
|
||||
pr_cont("/");
|
||||
}
|
||||
|
||||
char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
|
||||
|
||||
int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
|
||||
int cgroup_rm_cftypes(struct cftype *cfts);
|
||||
|
||||
bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor);
|
||||
|
||||
int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
|
||||
int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
|
||||
|
||||
int cgroup_task_count(const struct cgroup *cgrp);
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue