From patchwork Tue Jan 9 09:27:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10151293 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 24FF060223 for ; Tue, 9 Jan 2018 09:30:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 213B128997 for ; Tue, 9 Jan 2018 09:30:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15AC72899A; Tue, 9 Jan 2018 09:30:03 +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=unavailable 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 0E43228992 for ; Tue, 9 Jan 2018 09:30:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752402AbeAIJ3U (ORCPT ); Tue, 9 Jan 2018 04:29:20 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:41489 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752435AbeAIJ2Q (ORCPT ); Tue, 9 Jan 2018 04:28:16 -0500 Received: by mail-wr0-f193.google.com with SMTP id o7so10661213wro.8 for ; Tue, 09 Jan 2018 01:28:15 -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=LOFkzXwTIVlWiM0yc8/YtoUkAWa53dan+IF44eh+rIoOG2UZKfB6PRJVDea6II1Rsr H9ILw8lraA10lcXTRJFz8YrpjK43osdtsAzvzX2I0rL2S/93BDM5OSB+XqvxsbEGpmHc AMDHnqQ8bAztbDlA/BAZnJ3y2oeZO2fQknJKw= 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=pWr2T/+Lwt9A/7Mz/pIiBLAF5GQy2aFIIfRiKDhuOI1QoC+JtzUexkfkl17D+VT6DS Ki6JyFBPMfzoCM/A5yYvKDKJTx1Rk3O9wolnkx9ucir2iFmmYKoJvIlhxqYbE9eLwFAA afadTn20DPomKV47WlgwX7XCIBoFUPzVVQr8FODEjNAz/3xzvpENG0fhKQOwHRBwo/OE oulcp2DUmuJlJ/v5B++l3hAoK4wMeoWSn3hZ39DjboFOQKQBXMRWqTSbX/xfSz+FMeyr yCnM0L6DFlSno72r2WbhTF0nLRgRqhaeQrIZTzXFc4WzsW5IWjOK5Dddi0pKquWSVrTO cDyA== X-Gm-Message-State: AKGB3mLh2qX28Tw525KxMIOWbqbSuoKxg6BL/j+dg1F2E/0j1rHnMxdC tYWq4G3uD0U6lqrvKhwL2lo+IIXodOY= X-Google-Smtp-Source: ACJfBoulOq5ix6c9Bwhn4cDSFiLHhkYkjjFmLHG3loG+nPp/4ci5nFP918L09Hm0vSGTs6OFXQsSuw== X-Received: by 10.223.160.25 with SMTP id k25mr13764145wrk.31.1515490094868; Tue, 09 Jan 2018 01:28:14 -0800 (PST) Received: from localhost.localdomain (146-241-48-150.dyn.eolo.it. [146.241.48.150]) by smtp.gmail.com with ESMTPSA id y134sm19179828wme.12.2018.01.09.01.28.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 01:28:14 -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 V2 1/2] block, bfq: put async queues for root bfq groups too Date: Tue, 9 Jan 2018 10:27:58 +0100 Message-Id: <20180109092759.5454-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180109092759.5454-1-paolo.valente@linaro.org> References: <20180109092759.5454-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 Acked-by: Guoqing Jiang --- 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);