From patchwork Mon Mar 19 15:48:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 132041 Delivered-To: patch@linaro.org Received: by 10.80.152.129 with SMTP id j1csp2968964edb; Mon, 19 Mar 2018 08:50:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELsDQNSuOAjJl1lncWjiBKFXIMyXJlWw0bjOdgi9kx5eJnBNGKwwuHt+iXkNdDDwjp/j4rgV X-Received: by 10.101.93.5 with SMTP id e5mr9241986pgr.82.1521474600099; Mon, 19 Mar 2018 08:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521474600; cv=none; d=google.com; s=arc-20160816; b=QzgDr/8z7hLvRD8kJIxMRoQXQqqHa2AV2ELf7xrzsHE0K1u13Ym3OIEMqmpsEfEjCg Ds7bTwiBrlKe6wTgAhHtLDYCcWRFi9GzQ3n1PhiW4Kb/v4WcLuYOUWCH+NpnJ+abj2PD 5MgJWLQcRnCt6p+tZRmN507lgSBxOozkhgzOxBB2qOqAvXc5oeNo1hYXR7hcEqO2w4hr 1WYZ6TU3J56kwnA72qskM1Ka4K6PZja/yKMUBMPWptG4cDz7XEuC8v/o+aejctC2r3lO vpIqpd7KFdYnmZxetQKFUFDIT4qRupSsQCCtIU7ODz4RpD1wLoiSMnqzsEWDKzE2rALY TxEg== 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=A0TcJZyUXzZRiljV1xE1wuQIGTnvPnKiYvOVhQUJxLo=; b=hkPT2VouY831MXa7FaeqAAUOs7CkpdGjUYR4KCXLiFjWuPW5E/5NZsi/XntqdlC/AY oo1DtgUwifbfWrTGSiv7kuH752E72Ur3qn6DbKcU4nD36mFmkCnxG464idwzqu44BH5T lkql15kaY/T/ywYY4tTR5K4nW7efrlAZaJ3H84EZPS1jnA108SqBsfQUewYHNNEU+UdM FbFHAX4n00ikTBEh2GwtkLYUIDuh50JPz9LfIs41I1JVQd4u+EYUNYbmRfgYW6aVDRau 0BW0RO8Tlinu25mCKluszUG4ZsmWGWpziL6gg8GBKUwojGGYnfBsGnr3gUExGNt9Qna8 Y2qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=B/EuLGZC; 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 bg3-v6si211143plb.118.2018.03.19.08.49.59; Mon, 19 Mar 2018 08:50:00 -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=B/EuLGZC; 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 S934028AbeCSPty (ORCPT + 28 others); Mon, 19 Mar 2018 11:49:54 -0400 Received: from mail-sn1nam01on0129.outbound.protection.outlook.com ([104.47.32.129]:20557 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933855AbeCSPtk (ORCPT ); Mon, 19 Mar 2018 11:49:40 -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=A0TcJZyUXzZRiljV1xE1wuQIGTnvPnKiYvOVhQUJxLo=; b=B/EuLGZCYJAH7/eEvsbZRCcsyEOtgcB3vXu1N35JYn4hw4ftKn2HypXjPjOoY9LaYMZYycrhHd+xrtpWpR0tMSp9ZNkaDgzrZldUqvkdJEkwiKteFq392Qz1flrgjEBqO2Wm87xv7EuHsk7JTzH31YukU2mGzbEpHk4BISsynnM= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0981.namprd21.prod.outlook.com (52.132.133.27) 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:49:37 +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:49:37 +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.15 093/124] block, bfq: put async queues for root bfq groups too Thread-Topic: [PATCH AUTOSEL for 4.15 093/124] block, bfq: put async queues for root bfq groups too Thread-Index: AQHTv5nCLkWSTRGPYUOHds/U6G1Fgw== Date: Mon, 19 Mar 2018 15:48:44 +0000 Message-ID: <20180319154645.11350-93-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-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; DM5PR2101MB0981; 7:DU/S8+y2gvvZHUAsK9GhDcwR7p6elC1/71bsUu/+RqMXt7NQyYxSBH5mNj3jAdjY5VcTwgN0KfqbOKwwv/zCYbLpMgzDkvm6swaTdH4h4i8BA/BMl8y+hUUJzWcjd+bXUb+r+0ZErN8av9yAbExEMnlvhRTZBQ9ZBZP/caigTg7NFv20jgB6oe0rh6GdyG68oEmj39XU0BswnNadQUG2nKwK64ULOpMBBVr7X9PJzekMhKSbmFKUjg2FAiRHYW4V; 20:8909PVRT5S7yMZSeMWlGiGuTM2y6zJdRGyFsBj28N3IkfVeyzdTNs/mOaZrFeLTtXU9PUBNRdMqFDbm5JX0UrGyCC8tutL/kODYKuNt94tUphLgyMExdCY4ggnZPHeeKECfNmuRbTA7sEBUMnZdoPm8BHfh1lEsHdT16vuS/uAo= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: db45fdb3-1bf2-4007-4540-08d58db10532 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0981; x-ms-traffictypediagnostic: DM5PR2101MB0981: 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)(5005006)(8121501046)(3231221)(944501300)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:DM5PR2101MB0981; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0981; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(396003)(376002)(366004)(39860400002)(39380400002)(189003)(199004)(66066001)(6486002)(26005)(110136005)(5660300001)(54906003)(3280700002)(6512007)(68736007)(102836004)(6436002)(107886003)(10290500003)(53936002)(186003)(59450400001)(72206003)(14454004)(36756003)(6666003)(2950100002)(316002)(6506007)(22452003)(478600001)(10090500001)(106356001)(105586002)(99286004)(7736002)(3660700001)(86362001)(76176011)(305945005)(86612001)(2501003)(97736004)(5250100002)(39060400002)(4326008)(3846002)(6116002)(1076002)(8936002)(25786009)(81156014)(81166006)(8676002)(2900100001)(2906002)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0981; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: nBwPtQtGcmwwebESax6zQHsA6n4t8Jbi6isIg8hFsexPRO3GrbnMZVInScZDVg8GAS03Wp3twFO0NWOZoKDPuhDw73Wcz+ipNedvmRlz197TXe1LEnIvekH3sk/UuH14ndK+zD9KfLPUO59c9ljyJXPVGLHYwRLTmnB1VewaTorehk5XgkXNOtADxj1y6azaRwdsbBEhPDUQjgcIe2yIZXVCIbJTkJ2usAc5ByjN5cA/pXOSV7kITDFh6rNH0N8MV2H4ZalOG+g3kdR2ExMHIk3FD7jgZp7vkYrd4tf3xsJ7E1FhavOw9gDBthixPmpzZIJbhNyNiCSHdbBliUqCHA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <70CA0F2D4A74EB4CAED18D1B31C8472B@namprd21.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: db45fdb3-1bf2-4007-4540-08d58db10532 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:48:44.0915 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0981 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 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);