Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1175638

[PATCH 2/2 block/for-linus] writeback: don't drain bdi_writeback_congested on bdi destruction

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Tejun Heo <tj@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 2/2 block/for-linus] writeback: don't drain bdi_writeback_congested on bdi destruction
Date Thu, 02 Jul 2015 03:00:02 +0200
Message-ID <pHB18-41K-1@gated-at.bofh.it> (permalink)
References <pHB18-41K-3@gated-at.bofh.it>
X-Original-To Jens Axboe <axboe@kernel.dk>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=Wb1uPTFVcwrVVAcZ36RP6/aRzBvL0LNB3oRlm7zG9hc=; b=mdCkzeMrv6xQwzIyUkvZUx+G/ig8c1hj/ry1bRcI1BUBU8lPdtRWhkeOWdP1TSfHei eTIRfdl8zkydO4Ej4N63lNX/VwA2EYM1S+B+HH1uPswXOlO7ldlm48L7dmxkHjRUepHI 3Ob2AUh6a+y5AIFY7PwbLhzcBJLE7OozcY+mjHZPK9vIAk10Y0IHok3u0VlGVPqcSc24 m++c7z1xMpjlji+FlIOlxVq3RcZWH3EkyoUTZDMWgIZ4Cf5ZNL2a6p+IYRFB38EwW59/ PBw/Q1r/XGyQI0DDh1rPpT7L1rdlDppMtzNpTl9nF4LUUeJZW3KDz6d85N86kYNze+Fa lFag==
X-Received by 10.140.96.202 with SMTP id k68mr37748599qge.102.1435798419517; Wed, 01 Jul 2015 17:53:39 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.23 (2014-03-12)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 92
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, Jon Christopherson <jon@jons.org>
X-Original-Date Wed, 1 Jul 2015 20:53:37 -0400
X-Original-Message-ID <20150702005337.GB26440@mtj.duckdns.org>
X-Original-References <20150702005253.GA26440@mtj.duckdns.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1175638

Show key headers only | View raw


52ebea749aae ("writeback: make backing_dev_info host cgroup-specific
bdi_writebacks") made bdi (backing_dev_info) host per-cgroup wb's
(bdi_writeback's).  As the congested state needs to be per-wb and
referenced from blkcg side and multiple wbs, the patch made all
non-root cong's (bdi_writeback_congested's) reference counted and
indexed on bdi.

When a bdi is destroyed, cgwb_bdi_destroy() tries to drain all
non-root cong's; however, this can hang indefinitely because wb's can
also be referenced from blkcg_gq's which are destroyed after bdi
destruction is complete.

This patch fixes the bug by updating bdi destruction to not wait for
cong's to drain.  A cong is unlinked from bdi->cgwb_congested_tree on
bdi destuction regardless of its reference count as the bdi may go
away any point after destruction.  wb_congested_put() checks whether
the cong is already unlinked on release.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Jon Christopherson <jon@jons.org>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=100681
Fixes: 52ebea749aae ("writeback: make backing_dev_info host cgroup-specific bdi_writebacks")
---
 mm/backing-dev.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -425,7 +425,6 @@ retry:
 		new_congested = NULL;
 		rb_link_node(&congested->rb_node, parent, node);
 		rb_insert_color(&congested->rb_node, &bdi->cgwb_congested_tree);
-		atomic_inc(&bdi->usage_cnt);
 		goto found;
 	}
 
@@ -456,7 +455,6 @@ found:
  */
 void wb_congested_put(struct bdi_writeback_congested *congested)
 {
-	struct backing_dev_info *bdi = congested->bdi;
 	unsigned long flags;
 
 	local_irq_save(flags);
@@ -465,12 +463,15 @@ void wb_congested_put(struct bdi_writeba
 		return;
 	}
 
-	rb_erase(&congested->rb_node, &congested->bdi->cgwb_congested_tree);
+	/* bdi might already have been destroyed leaving @congested unlinked */
+	if (congested->bdi) {
+		rb_erase(&congested->rb_node,
+			 &congested->bdi->cgwb_congested_tree);
+		congested->bdi = NULL;
+	}
+
 	spin_unlock_irqrestore(&cgwb_lock, flags);
 	kfree(congested);
-
-	if (atomic_dec_and_test(&bdi->usage_cnt))
-		wake_up_all(&cgwb_release_wait);
 }
 
 static void cgwb_release_workfn(struct work_struct *work)
@@ -675,13 +676,22 @@ static int cgwb_bdi_init(struct backing_
 static void cgwb_bdi_destroy(struct backing_dev_info *bdi)
 {
 	struct radix_tree_iter iter;
+	struct bdi_writeback_congested *congested, *congested_n;
 	void **slot;
 
 	WARN_ON(test_bit(WB_registered, &bdi->wb.state));
 
 	spin_lock_irq(&cgwb_lock);
+
 	radix_tree_for_each_slot(slot, &bdi->cgwb_tree, &iter, 0)
 		cgwb_kill(*slot);
+
+	rbtree_postorder_for_each_entry_safe(congested, congested_n,
+					&bdi->cgwb_congested_tree, rb_node) {
+		rb_erase(&congested->rb_node, &bdi->cgwb_congested_tree);
+		congested->bdi = NULL;	/* mark @congested unlinked */
+	}
+
 	spin_unlock_irq(&cgwb_lock);
 
 	/*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/2 block/for-linus] writeback: don't drain  bdi_writeback_congested on bdi destruction Tejun Heo <tj@kernel.org> - 2015-07-02 03:00 +0200
  Re: [PATCH] tools/perf, rbtree: Add RCU wrappers to make rbtree.h  usable in user-space Tejun Heo <tj@kernel.org> - 2015-07-02 15:30 +0200
    Re: [PATCH] tools/perf, rbtree: Add RCU wrappers to make rbtree.h usable in user-space Rusty Russell <rusty@rustcorp.com.au> - 2015-07-03 02:40 +0200
      Re: [PATCH] tools/perf, rbtree: Add RCU wrappers to make rbtree.h  usable in user-space Jon Christopherson <jon@jons.org> - 2015-07-03 12:10 +0200
      Re: [PATCH] tools/perf, rbtree: Add RCU wrappers to make rbtree.h  usable in user-space Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-05 10:50 +0200
  Re: [PATCH 2/2 block/for-linus] writeback: don't drain bdi_writeback_congested  on bdi destruction Jens Axboe <axboe@kernel.dk> - 2015-07-02 16:10 +0200

csiph-web