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

Commit eafebcab authored by Patrick Bellasi's avatar Patrick Bellasi
Browse files

ANDROID: sched/tune: cleanup schedtune_boostgroup_{init,release}



This update the definition of these two methods to make more clear their
role.

In this refactored version, the slow path entry functions:
   schedtune_css_alloc()
   schedtune_css_free()
are in charge just to allocate and release the memory used to track
schedtune boost groups.

These two functions rely respectively on:
   schedtune_boostgroup_init()
   schedtune_boostgroup_release()
for everything related to setting up data structures and properly
initializing them.

Change-Id: I9336102b5c6a6b5726fd466e99b7d6b28d38f455
Signed-off-by: default avatarPatrick Bellasi <patrick.bellasi@arm.com>
parent ca17b83d
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -632,23 +632,22 @@ static struct cftype files[] = {
	{ }	/* terminate */
};

static int
schedtune_boostgroup_init(struct schedtune *st)
static void
schedtune_boostgroup_init(struct schedtune *st, int idx)
{
	struct boost_groups *bg;
	int cpu;

	/* Keep track of allocated boost groups */
	allocated_group[st->idx] = st;

	/* Initialize the per CPU boost groups */
	/* Initialize per CPUs boost group support */
	for_each_possible_cpu(cpu) {
		bg = &per_cpu(cpu_boost_groups, cpu);
		bg->group[st->idx].boost = 0;
		bg->group[st->idx].tasks = 0;
		bg->group[idx].boost = 0;
		bg->group[idx].tasks = 0;
	}

	return 0;
	/* Keep track of allocated boost groups */
	allocated_group[idx] = st;
	st->idx = idx;
}

static struct cgroup_subsys_state *
@@ -681,14 +680,10 @@ schedtune_css_alloc(struct cgroup_subsys_state *parent_css)
		goto out;

	/* Initialize per CPUs boost group support */
	st->idx = idx;
	if (schedtune_boostgroup_init(st))
		goto release;
	schedtune_boostgroup_init(st, idx);

	return &st->css;

release:
	kfree(st);
out:
	return ERR_PTR(-ENOMEM);
}
@@ -696,8 +691,14 @@ schedtune_css_alloc(struct cgroup_subsys_state *parent_css)
static void
schedtune_boostgroup_release(struct schedtune *st)
{
	/* Reset this boost group */
	schedtune_boostgroup_update(st->idx, 0);
	struct boost_groups *bg;
	int cpu;

	/* Reset per CPUs boost group support */
	for_each_possible_cpu(cpu) {
		bg = &per_cpu(cpu_boost_groups, cpu);
		bg->group[st->idx].boost = 0;
	}

	/* Keep track of allocated boost groups */
	allocated_group[st->idx] = NULL;
@@ -708,6 +709,7 @@ schedtune_css_free(struct cgroup_subsys_state *css)
{
	struct schedtune *st = css_st(css);

	/* Release per CPUs boost group support */
	schedtune_boostgroup_release(st);
	kfree(st);
}