diff mbox series

[5/5] blkcg, writeback: dead memcgs shouldn't contribute to writeback ownership arbitration

Message ID 20190613223041.606735-6-tj@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/5] blk-iolatency: clear use_delay when io.latency is set to zero | expand

Commit Message

Tejun Heo June 13, 2019, 10:30 p.m. UTC
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(-)

Comments

Jan Kara June 19, 2019, 11:20 a.m. UTC | #1
On Thu 13-06-19 15:30:41, Tejun Heo wrote:
> 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>

I see Jens has already pulled the changes so this is mostly informative but
the patch looks good to me.

								Honza
> ---
>  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
>
diff mbox series

Patch

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;