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: 123820 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3788694qgn; Tue, 9 Jan 2018 01:18:25 -0800 (PST) X-Google-Smtp-Source: ACJfBostFKaiEV02nUXo7Qn0U3fMwx1de2oP9Co9XgfvvzUuioeMRl224CszVOVGbNm87EZt7QnX X-Received: by 10.99.171.67 with SMTP id k3mr11447434pgp.51.1515489505581; Tue, 09 Jan 2018 01:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515489505; cv=none; d=google.com; s=arc-20160816; b=Qtq9oiyxZRRSy+I90cFlGkR/EaFcBkJ895tNNCku+cvPkMD3LD6Hw9QpIddviiXd5a 7owIBv2NGSWZb/T9YxIyL6t9YjnjN4mIz6Fc+dSjeH++FPOyzBub0qIBvKcEqw9BP/Ba SBvoH7AxmLfd8D2/MOzB0XN4wz0lojQABV+rX2+65ezaTVQfsLHT2A41gJMHTEDd8CUE tYhHFnLFWhQYH8jYUYcVUJhaYZnPhOHRhpSi/VuqCsXv6FeVDdnxh4TLmvhp0nxEJPpo NQmmJEw0NScrtfqWZRNHPfQqpTu2EE01lDk4GPeZQK3gbAyt4CY7f2+0bVY3CDiZy3kr LyzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/NNn3CRLueUP+337g5SPtWL764Ent/s5vgAZcbv/0/8=; b=NeLAtFJXbdBQR/Jy3lWT40VfpPa6U77gg8cXKsHzwxS3OqYilJxB7ripf+3Y58OwRd f/RY+Ag9xnSUDb+ddliongt0GrTCnnGsthNOnviS5t92uQLHsN/To63/1JCdcd2/naCU 1brO2McpoRCH7Ozken+VTvPWh8luItyXvv1UjQKJpy6X52De2QCPKqCxBnQxNKB6TEMh FJ/JiWsXWHjQTQdPJXP9jrZjpH8pVfg2OVprY1dsGwwuEKF4TtrUGcpZlzYDHsKPgxbP DX/9WGrFUP1hC6p1SmogKshF33Olu9l/tmdfNpQGDr3eyeidUaTAcvvFa7wyJIMwCKLR gPLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dggkl5NV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si8794136pgf.664.2018.01.09.01.18.25; Tue, 09 Jan 2018 01:18:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dggkl5NV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751987AbeAIJSW (ORCPT + 28 others); Tue, 9 Jan 2018 04:18:22 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:42495 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751101AbeAIJRo (ORCPT ); Tue, 9 Jan 2018 04:17:44 -0500 Received: by mail-wr0-f193.google.com with SMTP id w107so13414971wrb.9 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=qM+gnMSRL3mTDsA809a/yhxO+VhfjM5xTwicP831tmHURjlrPHCExYlSzOK3nIyr7t 8Fu6H0QFJNvsf3kbz+d7uP2lLUJxBikHNcQVgKyigEWF+hXfg0qN13WCqmxKgxzyPj9x eoy6zjOt95Avcw8I0un91Cf1YxVnANTcPqFnQO5H2SI0pkB2Pichf/4BR5A5r1JhvR54 aneaEmWravWrCMfhpIvTGo/9M3EGHKeB3feFJfViFvcAuRfLAE5S3m994GfSO+cVPvc0 gsQUqMDfL1KwvF+tV6JCJu9TtBAPHDgq8aFY+sGaPg+k5Xw38zHKjYaQf/DwIrUzdnTI GzeA== X-Gm-Message-State: AKGB3mLf1iIwQZtmvz/UZRe+gRMGVbpNxyNJSY8QctNfnE6yweqGxECl uH4iiRAgOeUHwiHrAZan62WH6w== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.15.1 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);