Skip to content

Commit 52257ff

Browse files
Algodev-githubaxboe
authored andcommitted
block, bfq: put async queues for root bfq groups too
For each pair [device for which bfq is selected as I/O scheduler, group in blkio/io], bfq maintains a corresponding bfq group. Each such bfq group contains a set of async queues, with each async queue created on demand, i.e., when some I/O request arrives for it. On creation, an async queue gets an extra reference, to make sure that the queue is not freed as long as its bfq group exists. Accordingly, to allow the queue to be freed after the group exited, this extra reference must released on group exit. The above holds also for a bfq root group, i.e., for the bfq group corresponding to the root blkio/io root for a given device. Yet, by mistake, the references to the existing async queues of a root group are not released when the latter exits. This causes a memory leak when the instance of bfq for a given device exits. In a similar vein, bfqg_stats_xfer_dead is not executed for a root group. This commit fixes bfq_pd_offline so that the latter executes the above missing operations for a root group too. Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com> Reported-by: Guoqing Jiang <gqjiang@suse.com> Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com> Signed-off-by: Davide Ferrari <davideferrari8@gmail.com> Signed-off-by: Paolo Valente <paolo.valente@linaro.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8ab0b7d commit 52257ff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

block/bfq-cgroup.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,11 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
775775
unsigned long flags;
776776
int i;
777777

778+
spin_lock_irqsave(&bfqd->lock, flags);
779+
778780
if (!entity) /* root group */
779-
return;
781+
goto put_async_queues;
780782

781-
spin_lock_irqsave(&bfqd->lock, flags);
782783
/*
783784
* Empty all service_trees belonging to this group before
784785
* deactivating the group itself.
@@ -809,6 +810,8 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
809810
}
810811

811812
__bfq_deactivate_entity(entity, false);
813+
814+
put_async_queues:
812815
bfq_put_async_queues(bfqd, bfqg);
813816

814817
spin_unlock_irqrestore(&bfqd->lock, flags);

0 commit comments

Comments
 (0)