Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c9d535b authored by Tejun Heo's avatar Tejun Heo
Browse files

cgroup: remove css_parent()



cgroup in general is moving towards using cgroup_subsys_state as the
fundamental structural component and css_parent() was introduced to
convert from using cgroup->parent to css->parent.  It was quite some
time ago and we're moving forward with making css more prominent.

This patch drops the trivial wrapper css_parent() and let the users
dereference css->parent.  While at it, explicitly mark fields of css
which are public and immutable.

v2: New usage from device_cgroup.c converted.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Acked-by: default avatar"David S. Miller" <davem@davemloft.net>
Acked-by: default avatarLi Zefan <lizefan@huawei.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Johannes Weiner <hannes@cmpxchg.org>
parent 3b514d24
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ static inline struct blkcg *bio_blkcg(struct bio *bio)
 */
static inline struct blkcg *blkcg_parent(struct blkcg *blkcg)
{
	return css_to_blkcg(css_parent(&blkcg->css));
	return css_to_blkcg(blkcg->css.parent);
}

/**
+11 −18
Original line number Diff line number Diff line
@@ -48,22 +48,28 @@ enum cgroup_subsys_id {
};
#undef SUBSYS

/* Per-subsystem/per-cgroup state maintained by the system. */
/*
 * Per-subsystem/per-cgroup state maintained by the system.  This is the
 * fundamental structural building block that controllers deal with.
 *
 * Fields marked with "PI:" are public and immutable and may be accessed
 * directly without synchronization.
 */
struct cgroup_subsys_state {
	/* the cgroup that this css is attached to */
	/* PI: the cgroup that this css is attached to */
	struct cgroup *cgroup;

	/* the cgroup subsystem that this css is attached to */
	/* PI: the cgroup subsystem that this css is attached to */
	struct cgroup_subsys *ss;

	/* reference count - access via css_[try]get() and css_put() */
	struct percpu_ref refcnt;

	/* the parent css */
	/* PI: the parent css */
	struct cgroup_subsys_state *parent;

	/*
	 * Subsys-unique ID.  0 is unused and root is always 1.  The
	 * PI: Subsys-unique ID.  0 is unused and root is always 1.  The
	 * matching css can be looked up using css_from_id().
	 */
	int id;
@@ -669,19 +675,6 @@ struct cgroup_subsys {
#include <linux/cgroup_subsys.h>
#undef SUBSYS

/**
 * css_parent - find the parent css
 * @css: the target cgroup_subsys_state
 *
 * Return the parent css of @css.  This function is guaranteed to return
 * non-NULL parent as long as @css isn't the root.
 */
static inline
struct cgroup_subsys_state *css_parent(struct cgroup_subsys_state *css)
{
	return css->parent;
}

/**
 * task_css_set_check - obtain a task's css_set with extra access conditions
 * @task: the task to obtain css_set for
+4 −4
Original line number Diff line number Diff line
@@ -3176,10 +3176,10 @@ css_next_descendant_pre(struct cgroup_subsys_state *pos,

	/* no child, visit my or the closest ancestor's next sibling */
	while (pos != root) {
		next = css_next_child(pos, css_parent(pos));
		next = css_next_child(pos, pos->parent);
		if (next)
			return next;
		pos = css_parent(pos);
		pos = pos->parent;
	}

	return NULL;
@@ -3261,12 +3261,12 @@ css_next_descendant_post(struct cgroup_subsys_state *pos,
		return NULL;

	/* if there's an unvisited sibling, visit its leftmost descendant */
	next = css_next_child(pos, css_parent(pos));
	next = css_next_child(pos, pos->parent);
	if (next)
		return css_leftmost_descendant(next);

	/* no sibling left, visit parent */
	return css_parent(pos);
	return pos->parent;
}

static bool cgroup_has_live_children(struct cgroup *cgrp)
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ static inline struct freezer *task_freezer(struct task_struct *task)

static struct freezer *parent_freezer(struct freezer *freezer)
{
	return css_freezer(css_parent(&freezer->css));
	return css_freezer(freezer->css.parent);
}

bool cgroup_freezing(struct task_struct *task)
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ static inline struct cpuset *task_cs(struct task_struct *task)

static inline struct cpuset *parent_cs(struct cpuset *cs)
{
	return css_cs(css_parent(&cs->css));
	return css_cs(cs->css.parent);
}

#ifdef CONFIG_NUMA
Loading