Skip to content

Commit be2c6b1

Browse files
rhvgoyalJens Axboe
authored andcommitted
blkio-throttle: Avoid calling blkiocg_lookup_group() for root group
o Jeff Moyer was doing some testing on a RAM backed disk and blkiocg_lookup_group() showed up high overhead after memcpy(). Similarly somebody else reported that blkiocg_lookup_group() is eating 6% extra cpu. Though looking at the code I can't think why the overhead of this function is so high. One thing is that it is called with very high frequency (once for every IO). o For lot of folks blkio controller will be compiled in but they might not have actually created cgroups. Hence optimize the case of root cgroup where we can avoid calling blkiocg_lookup_group() if IO is happening in root group (common case). Reported-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent ba5bd52 commit be2c6b1

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎block/blk-throttle.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,15 @@ static struct throtl_grp * throtl_find_alloc_tg(struct throtl_data *td,
168168
* tree of blkg (instead of traversing through hash list all
169169
* the time.
170170
*/
171-
tg = tg_of_blkg(blkiocg_lookup_group(blkcg, key));
171+
172+
/*
173+
* This is the common case when there are no blkio cgroups.
174+
* Avoid lookup in this case
175+
*/
176+
if (blkcg == &blkio_root_cgroup)
177+
tg = &td->root_tg;
178+
else
179+
tg = tg_of_blkg(blkiocg_lookup_group(blkcg, key));
172180

173181
/* Fill in device details for root group */
174182
if (tg && !tg->blkg.dev && bdi->dev && dev_name(bdi->dev)) {

0 commit comments

Comments
 (0)