From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vivek Goyal Subject: Re: [PATCH 7/8] blkcg: implement per-queue policy activation Date: Fri, 13 Apr 2012 11:21:23 -0400 Message-ID: <20120413152122.GC26383@redhat.com> References: <1334273380-30233-1-git-send-email-tj@kernel.org> <1334273380-30233-8-git-send-email-tj@kernel.org> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <1334273380-30233-8-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Tejun Heo Cc: axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org, ctalbott-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, rni-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org On Thu, Apr 12, 2012 at 04:29:39PM -0700, Tejun Heo wrote: [..] > @@ -111,12 +122,11 @@ static struct blkio_group *blkg_alloc(struct blkio_cgroup *blkcg, > struct blkio_policy_type *pol = blkio_policy[i]; > struct blkg_policy_data *pd; > > - if (!pol) > + if (!blkcg_policy_enabled(q, pol)) > continue; > > /* alloc per-policy data and attach it to blkg */ > - pd = kzalloc_node(sizeof(*pd) + pol->pdata_size, GFP_ATOMIC, > - q->node); > + pd = kzalloc_node(blkg_pd_size(pol), GFP_ATOMIC, q->node); > if (!pd) { > blkg_free(blkg); > return NULL; > @@ -130,7 +140,7 @@ static struct blkio_group *blkg_alloc(struct blkio_cgroup *blkcg, > for (i = 0; i < BLKCG_MAX_POLS; i++) { > struct blkio_policy_type *pol = blkio_policy[i]; > > - if (pol) > + if (blkcg_policy_enabled(blkg->q, pol)) > pol->ops.blkio_init_group_fn(blkg); > } May be pol->ops.blkio_init_group_fn() can be called in the loop above where you are allocating the group. So you don't end up looping through policies twice and don't have to call blkcg_policy_enabled() twice. Thanks Vivek