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); From patchwork Tue Jan 9 09:27:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 123822 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3796769qgn; Tue, 9 Jan 2018 01:28:31 -0800 (PST) X-Google-Smtp-Source: ACJfBoudZDeCyRpFsY8+stoPJaO9RwY8w5mY02WSagf4VoZFqdrBK5cwEfZimdRasckaAeMCuTIS X-Received: by 10.84.133.226 with SMTP id f89mr14773164plf.407.1515490111671; Tue, 09 Jan 2018 01:28:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515490111; cv=none; d=google.com; s=arc-20160816; b=Op17buOQgj8hQGqhiOSciz815TPktyHpOLNrW1xX6tUsdYLrTL/M6IebNI1SOkSuPF QT0mWPdpTrdBuCYRMBkVUofUFYkM19Yr4Y79iW3DzaPwLhCD1DXVa9buA5gR912cX5/C b++y4HQs8V30N5kiKCs9OHkN8mSl3FSmuanN6HUlG2/HA6JTXwRS0EnvmQ4p2C4ZcA3k A8QDLuRMfbAYiKdJq0LnLJ9qRn4p0xT5j7LDUm/IxY+lkLAuAPMjp/s/5csoP/SJhROi l2GEjLIjhlf2V7d/4Dt7jZGY6IIiK1JluIZqyWC0gtXgv0q7YQIz4vbVXvD3xnxqALR5 mxNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=HXbiwH/hQd6lJB2g00vxKJ1zfWW+jO65rSjxIZdwMfg=; b=P1NpdmD1gHX4HEPPYQ7YNyT5bIdKq3aypbllxKQEY/acVW0k8OabWQg4I695An2lXo xYublMzpTc4m4QEJJL9EqXnfrk7nSNZ91OF2DJN/FxWbjvVJzqwy/jzvm+nFzTUvyBra 4qPd9kWUc8LVTuf0bcv9hLovB+KhUoeZGBJIaax9c50ZydvYmg73nTYxTHDntfzDbhmh ddsB+IB1VROPin8yexFvRNAnEVbgfTe+LNImuiRX6stI23Q30pjkI+YmsYvbtsGokA0h He855SGQ1BcwRiwUJzP45osVoyPQpOfPykklHiXwRQkFFuEHbnKV8nerK14RbIRnkZ7N 2xJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E5iacIn1; 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 bc7si10145681plb.428.2018.01.09.01.28.31; Tue, 09 Jan 2018 01:28:31 -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=E5iacIn1; 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 S1752588AbeAIJ23 (ORCPT + 28 others); Tue, 9 Jan 2018 04:28:29 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:37316 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752561AbeAIJ2R (ORCPT ); Tue, 9 Jan 2018 04:28:17 -0500 Received: by mail-wm0-f66.google.com with SMTP id f140so19159297wmd.2 for ; Tue, 09 Jan 2018 01:28:16 -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; bh=HXbiwH/hQd6lJB2g00vxKJ1zfWW+jO65rSjxIZdwMfg=; b=E5iacIn1nDzIMMS1NsBT9e0Bf9JglcvtrLSGqweMeLwq9pXncRf6akOOyBG1wynlxB zfQPHE7feW6ccnnzDnVAsSSx5bkJLGsbLcH9WCRiTygATG/1AypL8U0H8LT9po73+bQw P1W4hFX1CpPsLR9qK3dshZUtRlti7/16AmBGI= 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; bh=HXbiwH/hQd6lJB2g00vxKJ1zfWW+jO65rSjxIZdwMfg=; b=OfagpGMf5oN/9NV2/q6qoWSwzuMmtBQ6I3AyQmKoKXqpJebkQYlXOjXZefMvOAxn2P RzbPFLRyc4ETJZ9O2lIndWKu372Z70ZT7zGw6pvk/TDukf1kELUlcJqJ1yPyb5weeaeF 65WM7A/+X5jQ8E1RvwIP9ku7ciDMy8VsxTsCNDsuseP0Fho+T176wmwQdyxhiaEAKbo8 9BHWOhuoXxVDylBL3CTTBeNq6RPHqf8vsWigvgmRb365RZvYJCiC51cQ0dPczDPlcGWL xiDm+URREfriL/Uu+r2dEt5J7aMnjHGy5JGWyBmpYMeaAvFk+u0695wfMqCUjfE/H0fh Zh0g== X-Gm-Message-State: AKGB3mLMhs9xOAcip50Drzavho4DAOnwEVLDlyWxqjrB/KMfmM8s71o9 lzjrzsEZmh1GjGyVM83aCHCbog== X-Received: by 10.28.132.203 with SMTP id g194mr12044144wmd.69.1515490096254; Tue, 09 Jan 2018 01:28:16 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 01:28:15 -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 Subject: [PATCH BUGFIX V2 2/2] block, bfq: release oom-queue ref to root group on exit Date: Tue, 9 Jan 2018 10:27:59 +0100 Message-Id: <20180109092759.5454-3-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On scheduler init, a reference to the root group, and a reference to its corresponding blkg are taken for the oom queue. Yet these references are not released on scheduler exit, which prevents these objects from be freed. This commit adds the missing reference releases. Reported-by: Davide Ferrari Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.15.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index ea48b5c8f088..c56a495af2e8 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5015,6 +5015,9 @@ static void bfq_exit_queue(struct elevator_queue *e) hrtimer_cancel(&bfqd->idle_slice_timer); + /* release oom-queue reference to root group */ + bfqg_and_blkg_put(bfqd->root_group); + #ifdef CONFIG_BFQ_GROUP_IOSCHED blkcg_deactivate_policy(bfqd->queue, &blkcg_policy_bfq); #else