linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk, jbacik@fb.com
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	kernel-team@fb.com, dennis@kernel.org, jack@suse.cz,
	Tejun Heo <tj@kernel.org>
Subject: [PATCH 5/5] blkcg, writeback: dead memcgs shouldn't contribute to writeback ownership arbitration
Date: Thu, 13 Jun 2019 15:30:41 -0700	[thread overview]
Message-ID: <20190613223041.606735-6-tj@kernel.org> (raw)
In-Reply-To: <20190613223041.606735-1-tj@kernel.org>

wbc_account_io() collects information on cgroup ownership of writeback
pages to determine which cgroup should own the inode.  Pages can stay
associated with dead memcgs but we want to avoid attributing IOs to
dead blkcgs as much as possible as the association is likely to be
stale.  However, currently, pages associated with dead memcgs
contribute to the accounting delaying and/or confusing the
arbitration.

Fix it by ignoring pages associated with dead memcgs.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jan Kara <jack@suse.cz>
---
 fs/fs-writeback.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index e41cbe8e81b9..9ebfb1b28430 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -715,6 +715,7 @@ void wbc_detach_inode(struct writeback_control *wbc)
 void wbc_account_io(struct writeback_control *wbc, struct page *page,
 		    size_t bytes)
 {
+	struct cgroup_subsys_state *css;
 	int id;
 
 	/*
@@ -726,7 +727,12 @@ void wbc_account_io(struct writeback_control *wbc, struct page *page,
 	if (!wbc->wb)
 		return;
 
-	id = mem_cgroup_css_from_page(page)->id;
+	css = mem_cgroup_css_from_page(page);
+	/* dead cgroups shouldn't contribute to inode ownership arbitration */
+	if (!(css->flags & CSS_ONLINE))
+		return;
+
+	id = css->id;
 
 	if (id == wbc->wb_id) {
 		wbc->wb_bytes += bytes;
-- 
2.17.1


  parent reply	other threads:[~2019-06-13 22:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 22:30 [PATCHSET block/for-linus] Assorted blkcg fixes Tejun Heo
2019-06-13 22:30 ` [PATCH 1/5] blk-iolatency: clear use_delay when io.latency is set to zero Tejun Heo
2019-06-13 22:30 ` [PATCH 2/5] blkcg: update blkcg_print_stat() to handle larger outputs Tejun Heo
2019-06-13 22:30 ` [PATCH 3/5] blkcg: perpcu_ref init/exit should be done from blkg_alloc/free() Tejun Heo
2019-06-13 22:30 ` [PATCH 4/5] blkcg: blkcg_activate_policy() should initialize ancestors first Tejun Heo
2019-06-13 22:30 ` Tejun Heo [this message]
2019-06-19 11:20   ` [PATCH 5/5] blkcg, writeback: dead memcgs shouldn't contribute to writeback ownership arbitration Jan Kara
2019-06-15  7:40 ` [PATCHSET block/for-linus] Assorted blkcg fixes Jens Axboe
2019-06-15 15:50   ` Tejun Heo
2019-06-15 16:40     ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190613223041.606735-6-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=dennis@kernel.org \
    --cc=jack@suse.cz \
    --cc=jbacik@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).