From patchwork Mon Mar 19 15:56:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 132092 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp93791ljb; Mon, 19 Mar 2018 14:57:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELs3fCNe/Gkq7xoC3l5gwK1VlQFtqOLX474FeI3hIHFcgPQCsqviauVkrDM1RxgRoggbMb3C X-Received: by 10.101.67.198 with SMTP id n6mr10304724pgp.150.1521496637196; Mon, 19 Mar 2018 14:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521496637; cv=none; d=google.com; s=arc-20160816; b=KEy/LA23MRnoXcsHeNxBtM8dXCj1ipi7yhIeL0A1/TWBzAKly9ZTQiA2mEf+6yoo49 BqBKLPG8y4d2KGZ8Z3OKex4TcOewrbN/Vp6uPj7/0mQJ4q/6u9zC9jUHYgvD0++hdfH/ 1cHl35yRs5HDaQrtJ5f37mNWKy6y4u2z+G+3NH3NHcrGEwaG8APeJmosrnR3GDWbUyUu NVqJcAgvZMme4WGmmAdAD8vx442AJFnVEqd2nIm+cdkUEF4mKRBQ0tmjNRZA+SXIW/r/ w+yLRssjE0ZaabW7fg0lwtEjdKA/R4nlTIi3qVtNHJ6p3J0Gzx9cEq2qRfaBJrW15Tn3 +vow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:spamdiagnosticmetadata:spamdiagnosticoutput :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=lP2+1JTv3hRcacjAquh492UERePxfateFV/k+apieqc=; b=CI0H2An3Hw9Mn6tlU37WJk89+WEguvt7l5Jzv1CHr9458iSaIQcRisAlJdVk/NcSkm 2deuQAnyvxmX8yr2d2mHRqOfkOPqVGOx0P9AR+KMRcP3QjcsDMw5vJmFN2VjRY3SUhE9 f/KcJipn1KtGs0DEe2PqPwffkISOPEZmWyvGWN8tOAzgxBgq2wSQgVKkzF766/ZlN6Ch Gt4O8+cmQ4iqT312AwuvjrwkM3dZRINDFqcM3OqH2NMr6zVf+FezLH0XDbJO9tsfrEwR +hBdB5y3zNgtHhIiRhwSxh6KjRhcSyEFOUvoBI0td1nQ8YLaVuUJ3c8kuHYCuzE+/GL1 4maA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=LWyY7EK6; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si178066pls.108.2018.03.19.14.57.16; Mon, 19 Mar 2018 14:57:17 -0700 (PDT) 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=@microsoft.com header.s=selector1 header.b=LWyY7EK6; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S972092AbeCSV4k (ORCPT + 28 others); Mon, 19 Mar 2018 17:56:40 -0400 Received: from mail-by2nam01on0117.outbound.protection.outlook.com ([104.47.34.117]:58464 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934578AbeCSP4m (ORCPT ); Mon, 19 Mar 2018 11:56:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=lP2+1JTv3hRcacjAquh492UERePxfateFV/k+apieqc=; b=LWyY7EK6J1xdT3FGq7zb9bffIJA6y5Sqtgl1pDFQLCF9QUij/RuJIKr1UeoAdbhdqokZRvr++vBYKYxCxuTOm38njTESbtWftyjBYd8FN9uo04vNm2v1v1oXdOsto1A3LKwELVuj424cWU7FgxMY4OeeflMzv4c1UI0gnWbsWiQ= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1031.namprd21.prod.outlook.com (52.132.128.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.0; Mon, 19 Mar 2018 15:56:36 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:56:36 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Paolo Valente , Davide Ferrari , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 73/97] block, bfq: put async queues for root bfq groups too Thread-Topic: [PATCH AUTOSEL for 4.14 73/97] block, bfq: put async queues for root bfq groups too Thread-Index: AQHTv5rK/0MSJyfMokSyZfQj+ha28A== Date: Mon, 19 Mar 2018 15:56:07 +0000 Message-ID: <20180319155411.12348-73-alexander.levin@microsoft.com> References: <20180319155411.12348-1-alexander.levin@microsoft.com> In-Reply-To: <20180319155411.12348-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB1031; 7:ResibTq1zWSMaKeJJxb2mX9aDgi6NU5rgZgPaFYHrwdqmbRikjJdMwtwD7xiitnyWkWpuXRd/nhjInfkuIDsZuXOLMNBS+RCxn03qVkhHtEuEc1eXQiBpsd0Tj1BsdXPFFn4DlTNKyIN0Sz6bEUT8zzq/PMhyDraFpcI3TMVwSYPeYKKcSOIl626mHW3TLnd97bAWVorzMJKxHcERvFMyApNEqXCmi1b5bU+xlVAVEX21+3ZvcAhMz6Bw0bqxRoj; 20:ILYIjLPyJlTvLbB6SytCWwtLQ0FmHjL0LZ4jpWSxyp8kcy1GbZ2nrNYb1rVDnWA6VKMmz8bDBY5v84wVecH+MxzSx0xlgpSie9ZMXwwSvC4VLZRrjBVZvvCWIUmzqa7oq879NeN/w/8GP3BwwUuag2b/hvTdK5PC6mTUKmLuII4= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 3db20565-1bbf-4b55-af22-08d58db1feec x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB1031; x-ms-traffictypediagnostic: DM5PR2101MB1031: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR2101MB1031; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB1031; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(346002)(396003)(39860400002)(39380400002)(199004)(189003)(25786009)(6506007)(59450400001)(66066001)(99286004)(76176011)(10290500003)(54906003)(68736007)(3660700001)(97736004)(22452003)(107886003)(53936002)(86362001)(110136005)(2501003)(5250100002)(86612001)(14454004)(478600001)(72206003)(316002)(102836004)(26005)(186003)(6116002)(3846002)(7736002)(39060400002)(2950100002)(10090500001)(6436002)(3280700002)(6512007)(6666003)(2900100001)(8676002)(8936002)(36756003)(106356001)(105586002)(4326008)(5660300001)(305945005)(1076002)(81156014)(6486002)(81166006)(2906002)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB1031; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: JenArAywIeZBV9cNkpoJZoKjWt5L1BsL6JTkda1qkiXuO/jC0zYyP4De/3H3wFhrU7ORtG47MfppHO6uEntEFCF19wJ4TvfAvODdkJNbGCAh+3Cenc9bMzymkFyglMsvHCJ0SvPsJ/yruZMgMoKT9rkkZOs5bHHjppqHmgHeoxU75wSZgEdLV2oGQD0dRrUXVx7S40iBG4OgaLD8EoF4XDhFsjtwL8o2SiBqX4fpGyyOPIhJtBiABbjqPLSOr8Syhog27JLXqtPEBre6q9/huEZKVZOcPnNMK81r6FfdMExzoi1lL4FtZZTwW4s2/oz4Pq94TbBZHgaBNtOskpL9yQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3db20565-1bbf-4b55-af22-08d58db1feec X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:56:07.0495 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1031 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Valente [ Upstream commit 52257ffbfcaf58d247b13fb148e27ed17c33e526 ] 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 Tested-by: Holger Hoffstätte Signed-off-by: Davide Ferrari Signed-off-by: Paolo Valente Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-cgroup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.14.1 diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index ceefb9a706d6..5d53e504acae 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -749,10 +749,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. @@ -783,6 +784,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);