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: 123823 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3797407qgn; Tue, 9 Jan 2018 01:29:25 -0800 (PST) X-Google-Smtp-Source: ACJfBosv4agkinXBplh+ZtcjDR2hDmZ3xckDYOMGoZ4tMeG/GA58ZHds/wxMojM8s0UUXgozDAHY X-Received: by 10.159.198.9 with SMTP id f9mr15392044plo.322.1515490165358; Tue, 09 Jan 2018 01:29:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515490165; cv=none; d=google.com; s=arc-20160816; b=gpv07ERf6YbrmYUA+/s/0jXL5Q2ZRkQQoSZlVPN9yoOmjDKph4qyn+KbMtoQAMr+5w NNQ4q0fRpbq5sUFNLbuAtnbbeT8zE2yUP3t0eHAtjqGh5KRJdf4aOKqhInKPvqe7xAeU hLpbh6gVYsAe7OJ84oXRuByLPe/6gzoXWrC5doritFBMs3dSJbEg11xlRC3bsioxEFzS RLgFuo1egM9ZBIlFOJQLegBhiQbYb2PJQhG+kRshGVB0aNHxnwGikmYcQvsRr7QbbfwZ LFrPa3jJZFn+LdhNAQU5H/uV3aYBVltzon74d52PmEAwDhiaSkFYU7ii1ewZ8EmA26CB +5Ng== 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=vawbe2B617uwgCLknFa4dUewRKYhEx78Ff1NK6hGGezG9EnE/kDfCi/jQFktePjyTF hI2uus/6HIRyRZfPpYQWS7dyapXsx53cAx7qX9pv/6omwZMI+5VMsUynEevdHbE6JaR4 zck2zqSMuUKB0MNN5uIVcYZxpInKUytYH0nRwzfw/TDU3cQNqWYF43PsbhVTfzoJdf/+ rCyFRGZz74kMT3grNgXGeOcuEEDR+JIYY6nI6oJ6ndFhwHsl7TCjLcS2nlX1qellqxb8 vmrPbHmMxbMCVgFIcVQxgLNJvP6f8vK0p1fLpVYrpSo6P3xvB4ZM3t3NugImudryXhEF YPLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LOFkzXwT; 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 ay1si3467052plb.2.2018.01.09.01.29.25; Tue, 09 Jan 2018 01:29: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=LOFkzXwT; 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 S1752624AbeAIJ3W (ORCPT + 28 others); Tue, 9 Jan 2018 04:29:22 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:40946 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752320AbeAIJ2Q (ORCPT ); Tue, 9 Jan 2018 04:28:16 -0500 Received: by mail-wr0-f196.google.com with SMTP id p17so13447573wre.7 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=bS/QYRBYcyQo0Z4XJFiDisUyX8Qk2D/E3Qx0dqNwAW4yuKoqKGft6gSdZlUhqxKOdd M28WElgBlR5sWrAxG584SXuWCacbsmvld5b5Vyx6ZlkP4zU0pR6xe3a8t7MCDU6l+0xj dHRU2tf5eUuOs1UpTgZLTmMVRcSn1owk82UmZtCEluIyGhnmlYVd6HXU593XO6fry/xr dCAG2+Zxd8OGTWfMi0DCjxt/rzqZQicm4OxxZFdvrUZssO5+wdqoD741O8eCwNFd9YzM PervbRV+8jfkxKjtiO8iCZI7YSyjyf9vvjo9m8buf52UttBUwG4FBOZhHZTdIPjjQf9i v/VQ== X-Gm-Message-State: AKGB3mLKkJAcckaL0v/ObrCB1Vc6/k/e/dSyJ9/Z6Q/FKdVgM34AX6Dd htR5c2+AHxKEjmEcbFAN2fg99g== 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-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 Acked-by: Guoqing Jiang 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);