From patchwork Tue Jan 9 09:17:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10151227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD86D60223 for ; Tue, 9 Jan 2018 09:18:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0DFE28982 for ; Tue, 9 Jan 2018 09:18:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D48952898C; Tue, 9 Jan 2018 09:18:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2892F28686 for ; Tue, 9 Jan 2018 09:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751101AbeAIJSW (ORCPT ); Tue, 9 Jan 2018 04:18:22 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:45298 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbeAIJRo (ORCPT ); Tue, 9 Jan 2018 04:17:44 -0500 Received: by mail-wr0-f196.google.com with SMTP id 16so921108wry.12 for ; Tue, 09 Jan 2018 01:17:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/NNn3CRLueUP+337g5SPtWL764Ent/s5vgAZcbv/0/8=; b=Dggkl5NVUkt7i+NxOIcUR7TsWu2V54QH3xSdTqLTkZJefLVuJv6O/ntkqbxkxCEQ5U gepuB4AVdWjTDcTGqSf7QANTFhK1UO3qjz0cZPPwaFW2qsXjfoRGUzZN70aaSElJ3ZVP qubEqBsQ+bLG5FcbgA6N3dWlxB2pG/7gh1LKM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/NNn3CRLueUP+337g5SPtWL764Ent/s5vgAZcbv/0/8=; b=ES0uLOVwuXIbqKqRxU9q7GweE7IK4mK76KqOp2EBHsRJFUc5CqSGsehj28feCVYfnx ypXRgj6GwMoRcRyPH2/Ja5ELmgaEW4VVvJQzxHEfpmOIIVjDST6XIswySKlqIiQooJAU 5MQ6ujjuA1lhUeCpngdRFk8Xkd/CVfIPObJcF2E/28712mUDp6yTJnFJW4zkTJYQTqyv C+1WyXhCN4aTYgkAABKrZ1BpFEZD3Ns4RQw9DdPZdcf4qJxAIpMK9da12JuZQhRk3+9i Jt5dgItcYs3WS8eepT3Q+lMvO9sbPbZpXmoqCSG0CmVzNkvxbnmdsfjsnbXFJ7a8rdBS EYqQ== X-Gm-Message-State: AKGB3mJpP4RiWBN9eJu4NCx+wQi0s8XKFFQSrtEPgPA3aky0nkVFc+nR +nP4OLP0vnApQXRwqeqnm98qLQ== X-Google-Smtp-Source: ACJfBou5Yk5aeujKB5TQ8/3jY0YAczAUI99D5MgSBlg4q/E9CG/LaYHHznJZhagoXHxTpV+cYiEDCA== X-Received: by 10.223.132.135 with SMTP id 7mr12984318wrg.250.1515489462730; Tue, 09 Jan 2018 01:17:42 -0800 (PST) Received: from localhost.localdomain (146-241-48-150.dyn.eolo.it. [146.241.48.150]) by smtp.gmail.com with ESMTPSA id y124sm14662722wmb.42.2018.01.09.01.17.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 01:17:42 -0800 (PST) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, 162996@studenti.unimore.it, Paolo Valente , Davide Ferrari Subject: [PATCH BUGFIX 1/2] block, bfq: put async queues for root bfq groups too Date: Tue, 9 Jan 2018 10:17:26 +0100 Message-Id: <20180109091727.5262-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180109091727.5262-1-paolo.valente@linaro.org> References: <20180109091727.5262-1-paolo.valente@linaro.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reported-by: Guoqing Jiang Signed-off-by: Davide Ferrari Signed-off-by: Paolo Valente --- block/bfq-cgroup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index da1525ec4c87..d819dc77fe65 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -775,10 +775,11 @@ static void bfq_pd_offline(struct blkg_policy_data *pd) unsigned long flags; int i; + spin_lock_irqsave(&bfqd->lock, flags); + if (!entity) /* root group */ - return; + goto put_async_queues; - spin_lock_irqsave(&bfqd->lock, flags); /* * Empty all service_trees belonging to this group before * deactivating the group itself. @@ -809,6 +810,8 @@ static void bfq_pd_offline(struct blkg_policy_data *pd) } __bfq_deactivate_entity(entity, false); + +put_async_queues: bfq_put_async_queues(bfqd, bfqg); spin_unlock_irqrestore(&bfqd->lock, flags);