From eafebcabecd08e7a7e71481bcda6d6f788622495 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Mon, 12 Feb 2018 16:04:35 +0000 Subject: [PATCH] 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: Patrick Bellasi --- kernel/sched/tune.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c index 4ad5a66da181..62f30858e7b9 100644 --- a/kernel/sched/tune.c +++ b/kernel/sched/tune.c @@ -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 @@ out: 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); }