Commit a9791555 authored by JP Kobryn's avatar JP Kobryn Committed by Tejun Heo
Browse files

cgroup: change rstat function signatures from cgroup-based to css-based



This non-functional change serves as preparation for moving to
subsystem-based rstat trees. To simplify future commits, change the
signatures of existing cgroup-based rstat functions to become css-based and
rename them to reflect that.

Though the signatures have changed, the implementations have not. Within
these functions use the css->cgroup pointer to obtain the associated cgroup
and allow code to function the same just as it did before this patch. At
applicable call sites, pass the subsystem-specific css pointer as an
argument or pass a pointer to cgroup::self if not in subsystem context.

Note that cgroup_rstat_updated_list() and cgroup_rstat_push_children()
are not altered yet since there would be a larger amount of css to
cgroup conversions which may overcomplicate the code at this
intermediate phase.

Signed-off-by: default avatarJP Kobryn <inwardvessel@gmail.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 845a7245
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1144,7 +1144,7 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu)
/*
 * We source root cgroup stats from the system-wide stats to avoid
 * tracking the same information twice and incurring overhead when no
 * cgroups are defined. For that reason, cgroup_rstat_flush in
 * cgroups are defined. For that reason, css_rstat_flush in
 * blkcg_print_stat does not actually fill out the iostat in the root
 * cgroup's blkcg_gq.
 *
@@ -1253,7 +1253,7 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)
	if (!seq_css(sf)->parent)
		blkcg_fill_root_iostats();
	else
		cgroup_rstat_flush(blkcg->css.cgroup);
		css_rstat_flush(&blkcg->css);

	rcu_read_lock();
	hlist_for_each_entry_rcu(blkg, &blkcg->blkg_list, blkcg_node) {
@@ -2243,7 +2243,7 @@ void blk_cgroup_bio_start(struct bio *bio)
	}

	u64_stats_update_end_irqrestore(&bis->sync, flags);
	cgroup_rstat_updated(blkcg->css.cgroup, cpu);
	css_rstat_updated(&blkcg->css, cpu);
	put_cpu();
}

+1 −1
Original line number Diff line number Diff line
@@ -536,7 +536,7 @@ struct cgroup {
	/*
	 * A singly-linked list of cgroup structures to be rstat flushed.
	 * This is a scratch field to be used exclusively by
	 * cgroup_rstat_flush_locked() and protected by cgroup_rstat_lock.
	 * css_rstat_flush_locked() and protected by cgroup_rstat_lock.
	 */
	struct cgroup	*rstat_flush_next;

+2 −2
Original line number Diff line number Diff line
@@ -693,8 +693,8 @@ static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen)
/*
 * cgroup scalable recursive statistics.
 */
void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);
void cgroup_rstat_flush(struct cgroup *cgrp);
void css_rstat_updated(struct cgroup_subsys_state *css, int cpu);
void css_rstat_flush(struct cgroup_subsys_state *css);

/*
 * Basic resource stats.
+2 −2
Original line number Diff line number Diff line
@@ -270,8 +270,8 @@ int cgroup_task_count(const struct cgroup *cgrp);
/*
 * rstat.c
 */
int cgroup_rstat_init(struct cgroup *cgrp);
void cgroup_rstat_exit(struct cgroup *cgrp);
int css_rstat_init(struct cgroup_subsys_state *css);
void css_rstat_exit(struct cgroup_subsys_state *css);
void cgroup_rstat_boot(void);
void cgroup_base_stat_cputime_show(struct seq_file *seq);

+17 −13
Original line number Diff line number Diff line
@@ -1362,7 +1362,7 @@ static void cgroup_destroy_root(struct cgroup_root *root)

	cgroup_unlock();

	cgroup_rstat_exit(cgrp);
	css_rstat_exit(&cgrp->self);
	kernfs_destroy_root(root->kf_root);
	cgroup_free_root(root);
}
@@ -2136,7 +2136,7 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask)
	if (ret)
		goto destroy_root;

	ret = cgroup_rstat_init(root_cgrp);
	ret = css_rstat_init(&root_cgrp->self);
	if (ret)
		goto destroy_root;

@@ -2178,7 +2178,7 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask)
	goto out;

exit_stats:
	cgroup_rstat_exit(root_cgrp);
	css_rstat_exit(&root_cgrp->self);
destroy_root:
	kernfs_destroy_root(root->kf_root);
	root->kf_root = NULL;
@@ -5435,7 +5435,7 @@ static void css_free_rwork_fn(struct work_struct *work)
			cgroup_put(cgroup_parent(cgrp));
			kernfs_put(cgrp->kn);
			psi_cgroup_free(cgrp);
			cgroup_rstat_exit(cgrp);
			css_rstat_exit(css);
			kfree(cgrp);
		} else {
			/*
@@ -5465,7 +5465,7 @@ static void css_release_work_fn(struct work_struct *work)

		/* css release path */
		if (!list_empty(&css->rstat_css_node)) {
			cgroup_rstat_flush(cgrp);
			css_rstat_flush(css);
			list_del_rcu(&css->rstat_css_node);
		}

@@ -5493,7 +5493,7 @@ static void css_release_work_fn(struct work_struct *work)
		/* cgroup release path */
		TRACE_CGROUP_PATH(release, cgrp);

		cgroup_rstat_flush(cgrp);
		css_rstat_flush(css);

		spin_lock_irq(&css_set_lock);
		for (tcgrp = cgroup_parent(cgrp); tcgrp;
@@ -5686,17 +5686,13 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name,
	if (ret)
		goto out_free_cgrp;

	ret = cgroup_rstat_init(cgrp);
	if (ret)
		goto out_cancel_ref;

	/* create the directory */
	kn = kernfs_create_dir_ns(parent->kn, name, mode,
				  current_fsuid(), current_fsgid(),
				  cgrp, NULL);
	if (IS_ERR(kn)) {
		ret = PTR_ERR(kn);
		goto out_stat_exit;
		goto out_cancel_ref;
	}
	cgrp->kn = kn;

@@ -5706,6 +5702,14 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name,
	cgrp->root = root;
	cgrp->level = level;

	/*
	 * Now that init_cgroup_housekeeping() has been called and cgrp->self
	 * is setup, it is safe to perform rstat initialization on it.
	 */
	ret = css_rstat_init(&cgrp->self);
	if (ret)
		goto out_stat_exit;

	ret = psi_cgroup_alloc(cgrp);
	if (ret)
		goto out_kernfs_remove;
@@ -5776,10 +5780,10 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name,

out_psi_free:
	psi_cgroup_free(cgrp);
out_stat_exit:
	css_rstat_exit(&cgrp->self);
out_kernfs_remove:
	kernfs_remove(cgrp->kn);
out_stat_exit:
	cgroup_rstat_exit(cgrp);
out_cancel_ref:
	percpu_ref_exit(&cgrp->self.refcnt);
out_free_cgrp:
Loading