Skip to content

Commit bc915e6

Browse files
htejunaxboe
authored andcommitted
blkcg: remove unnecessary blkcg_root handling from css_alloc/free paths
blkcg_css_alloc() bypasses policy data allocation and blkcg_css_free() bypasses policy data and blkcg freeing for blkcg_root. There's no reason to to treat policy data any differently for blkcg_root. If the root css gets allocated after policies are registered, policy registration path will add policy data; otherwise, the alloc path will. The free path isn't never invoked for root csses. This patch removes the unnecessary special handling of blkcg_root from css_alloc/free paths. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 994b783 commit bc915e6

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

block/blk-cgroup.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -823,18 +823,15 @@ static void blkcg_css_offline(struct cgroup_subsys_state *css)
823823
static void blkcg_css_free(struct cgroup_subsys_state *css)
824824
{
825825
struct blkcg *blkcg = css_to_blkcg(css);
826+
int i;
826827

827828
mutex_lock(&blkcg_pol_mutex);
828829
list_del(&blkcg->all_blkcgs_node);
829830
mutex_unlock(&blkcg_pol_mutex);
830831

831-
if (blkcg != &blkcg_root) {
832-
int i;
833-
834-
for (i = 0; i < BLKCG_MAX_POLS; i++)
835-
kfree(blkcg->pd[i]);
836-
kfree(blkcg);
837-
}
832+
for (i = 0; i < BLKCG_MAX_POLS; i++)
833+
kfree(blkcg->pd[i]);
834+
kfree(blkcg);
838835
}
839836

840837
static struct cgroup_subsys_state *
@@ -848,13 +845,12 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
848845

849846
if (!parent_css) {
850847
blkcg = &blkcg_root;
851-
goto done;
852-
}
853-
854-
blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
855-
if (!blkcg) {
856-
ret = ERR_PTR(-ENOMEM);
857-
goto free_blkcg;
848+
} else {
849+
blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
850+
if (!blkcg) {
851+
ret = ERR_PTR(-ENOMEM);
852+
goto free_blkcg;
853+
}
858854
}
859855

860856
for (i = 0; i < BLKCG_MAX_POLS ; i++) {
@@ -881,7 +877,6 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
881877
pol->cpd_init_fn(blkcg);
882878
}
883879

884-
done:
885880
spin_lock_init(&blkcg->lock);
886881
INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_NOWAIT);
887882
INIT_HLIST_HEAD(&blkcg->blkg_list);

0 commit comments

Comments
 (0)