From: Tejun Heo <tj@kernel.org> To: axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, jack@suse.cz, hch@infradead.org, hannes@cmpxchg.org, linux-fsdevel@vger.kernel.org, vgoyal@redhat.com, lizefan@huawei.com, cgroups@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.cz, clm@fb.com, fengguang.wu@intel.com, david@fromorbit.com, gthelen@google.com, Tejun Heo <tj@kernel.org> Subject: [PATCH 4/8] truncate: swap the order of conditionals in cancel_dirty_page() Date: Mon, 23 Mar 2015 01:25:40 -0400 [thread overview] Message-ID: <1427088344-17542-5-git-send-email-tj@kernel.org> (raw) In-Reply-To: <1427088344-17542-1-git-send-email-tj@kernel.org> cancel_dirty_page() currently performs TestClearPageDirty() and then tests whether the mapping exists and has cap_account_dirty. This patch swaps the order so that it performs the mapping tests first. If the mapping tests fail, the dirty is cleared with ClearPageDirty(). The order or the conditionals is swapped but the end result is the same. This will help inode foreign cgroup wb switching. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jan Kara <jack@suse.cz> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Greg Thelen <gthelen@google.com> --- mm/truncate.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index fe2d769..9d40cd4 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -108,13 +108,13 @@ void do_invalidatepage(struct page *page, unsigned int offset, */ void cancel_dirty_page(struct page *page, unsigned int account_size) { - struct mem_cgroup *memcg; + struct address_space *mapping = page->mapping; - memcg = mem_cgroup_begin_page_stat(page); - if (TestClearPageDirty(page)) { - struct address_space *mapping = page->mapping; + if (mapping && mapping_cap_account_dirty(mapping)) { + struct mem_cgroup *memcg; - if (mapping && mapping_cap_account_dirty(mapping)) { + memcg = mem_cgroup_begin_page_stat(page); + if (TestClearPageDirty(page)) { struct bdi_writeback *wb = inode_to_wb(mapping->host); mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY); @@ -123,8 +123,10 @@ void cancel_dirty_page(struct page *page, unsigned int account_size) if (account_size) task_io_account_cancelled_write(account_size); } + mem_cgroup_end_page_stat(memcg); + } else { + ClearPageDirty(page); } - mem_cgroup_end_page_stat(memcg); } EXPORT_SYMBOL(cancel_dirty_page); -- 2.1.0
WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org> To: axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, jack@suse.cz, hch@infradead.org, hannes@cmpxchg.org, linux-fsdevel@vger.kernel.org, vgoyal@redhat.com, lizefan@huawei.com, cgroups@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.cz, clm@fb.com, fengguang.wu@intel.com, david@fromorbit.com, gthelen@google.com, Tejun Heo <tj@kernel.org> Subject: [PATCH 4/8] truncate: swap the order of conditionals in cancel_dirty_page() Date: Mon, 23 Mar 2015 01:25:40 -0400 [thread overview] Message-ID: <1427088344-17542-5-git-send-email-tj@kernel.org> (raw) In-Reply-To: <1427088344-17542-1-git-send-email-tj@kernel.org> cancel_dirty_page() currently performs TestClearPageDirty() and then tests whether the mapping exists and has cap_account_dirty. This patch swaps the order so that it performs the mapping tests first. If the mapping tests fail, the dirty is cleared with ClearPageDirty(). The order or the conditionals is swapped but the end result is the same. This will help inode foreign cgroup wb switching. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jan Kara <jack@suse.cz> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Greg Thelen <gthelen@google.com> --- mm/truncate.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index fe2d769..9d40cd4 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -108,13 +108,13 @@ void do_invalidatepage(struct page *page, unsigned int offset, */ void cancel_dirty_page(struct page *page, unsigned int account_size) { - struct mem_cgroup *memcg; + struct address_space *mapping = page->mapping; - memcg = mem_cgroup_begin_page_stat(page); - if (TestClearPageDirty(page)) { - struct address_space *mapping = page->mapping; + if (mapping && mapping_cap_account_dirty(mapping)) { + struct mem_cgroup *memcg; - if (mapping && mapping_cap_account_dirty(mapping)) { + memcg = mem_cgroup_begin_page_stat(page); + if (TestClearPageDirty(page)) { struct bdi_writeback *wb = inode_to_wb(mapping->host); mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY); @@ -123,8 +123,10 @@ void cancel_dirty_page(struct page *page, unsigned int account_size) if (account_size) task_io_account_cancelled_write(account_size); } + mem_cgroup_end_page_stat(memcg); + } else { + ClearPageDirty(page); } - mem_cgroup_end_page_stat(memcg); } EXPORT_SYMBOL(cancel_dirty_page); -- 2.1.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-03-23 5:28 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-03-23 5:25 [PATCHSET 3/3 block/for-4.1/core] writeback: implement foreign cgroup inode bdi_writeback switching Tejun Heo 2015-03-23 5:25 ` Tejun Heo 2015-03-23 5:25 ` [PATCH 1/8] writeback: relocate wb[_try]_get(), wb_put(), inode_{attach|detach}_wb() Tejun Heo 2015-03-23 5:25 ` Tejun Heo 2015-03-23 5:25 ` [PATCH 2/8] writeback: make writeback_control track the inode being written back Tejun Heo 2015-03-23 5:25 ` Tejun Heo 2015-03-23 5:25 ` [PATCH 3/8] writeback: implement foreign cgroup inode detection Tejun Heo 2015-03-23 5:25 ` Tejun Heo 2015-03-23 5:25 ` Tejun Heo [this message] 2015-03-23 5:25 ` [PATCH 4/8] truncate: swap the order of conditionals in cancel_dirty_page() Tejun Heo 2015-03-23 5:25 ` [PATCH 5/8] writeback: implement [locked_]inode_to_wb_and_lock_list() Tejun Heo 2015-03-23 5:25 ` Tejun Heo 2015-03-23 5:25 ` [PATCH 6/8] writeback: implement I_WB_SWITCH and bdi_writeback stat update transaction Tejun Heo 2015-03-23 5:25 ` Tejun Heo 2015-03-23 5:25 ` [PATCH 7/8] writeback: add lockdep annotation to inode_to_wb() Tejun Heo 2015-03-23 5:25 ` Tejun Heo 2015-03-23 5:25 ` [PATCH 8/8] writeback: implement foreign cgroup inode bdi_writeback switching Tejun Heo 2015-03-23 5:25 ` Tejun Heo 2015-03-25 22:44 ` [PATCH 9/8] writeback: disassociate inodes from dying bdi_writebacks Tejun Heo 2015-03-25 22:44 ` Tejun Heo 2015-03-25 22:44 ` Tejun Heo 2015-03-25 22:44 ` Tejun Heo
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=1427088344-17542-5-git-send-email-tj@kernel.org \ --to=tj@kernel.org \ --cc=axboe@kernel.dk \ --cc=cgroups@vger.kernel.org \ --cc=clm@fb.com \ --cc=david@fromorbit.com \ --cc=fengguang.wu@intel.com \ --cc=gthelen@google.com \ --cc=hannes@cmpxchg.org \ --cc=hch@infradead.org \ --cc=jack@suse.cz \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=lizefan@huawei.com \ --cc=mhocko@suse.cz \ --cc=vgoyal@redhat.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.