From: Michael Rubin <mrubin@google.com> To: Wu Fengguang <fengguang.wu@intel.com> Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jack@suse.cz, riel@redhat.com, akpm@linux-foundation.org, david@fromorbit.com, hch@lst.de, axboe@kernel.dk Subject: Re: [PATCH 1/3] mm: helper functions for dirty and writeback accounting Date: Fri, 20 Aug 2010 01:19:33 -0700 [thread overview] Message-ID: <AANLkTinzS5J2PsG4Ftmbjvpi=beyD54A=ZrRw3_DA8jv@mail.gmail.com> (raw) In-Reply-To: <20100820023419.GA5502@localhost> On Thu, Aug 19, 2010 at 7:34 PM, Wu Fengguang <fengguang.wu@intel.com> wrote: > On Thu, Aug 19, 2010 at 01:57:25PM -0700, Michael Rubin wrote: >> Exporting account_pages_dirty and adding a symmetric routine >> account_pages_writeback. > > s/account_pages_writeback/account_page_writeback/ Got it. thanks. > I'd recommend to separate the changes into two patches. > It's actually a bug fix to export account_pages_dirty() for ceph, > which should be a good candidate for 2.6.36. Good idea. >> This allows code outside of the mm core to safely manipulate page state >> and not worry about the other accounting. Not using these routines means >> that some code will lose track of the accounting and we get bugs. This >> has happened once already. >> >> Signed-off-by: Michael Rubin <mrubin@google.com> >> --- >> fs/ceph/addr.c | 8 ++------ >> fs/nilfs2/segment.c | 2 +- >> include/linux/mm.h | 1 + >> mm/page-writeback.c | 15 +++++++++++++++ >> 4 files changed, 19 insertions(+), 7 deletions(-) >> >> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c >> index d9c60b8..359aa3a 100644 >> --- a/fs/ceph/addr.c >> +++ b/fs/ceph/addr.c >> @@ -106,12 +106,8 @@ static int ceph_set_page_dirty(struct page *page) >> if (page->mapping) { /* Race with truncate? */ >> WARN_ON_ONCE(!PageUptodate(page)); >> >> - if (mapping_cap_account_dirty(mapping)) { >> - __inc_zone_page_state(page, NR_FILE_DIRTY); >> - __inc_bdi_stat(mapping->backing_dev_info, >> - BDI_RECLAIMABLE); >> - task_io_account_write(PAGE_CACHE_SIZE); >> - } >> + if (mapping_cap_account_dirty(mapping)) > > That 'if' is not necessary. account_page_dirtied() already has one. > The extra 'if' is not an optimization either, because the ceph fs is > not likely to have un-accountable mappings. Sweet. Thanks. > >> + account_page_dirtied(page, page->mapping); >> radix_tree_tag_set(&mapping->page_tree, >> page_index(page), PAGECACHE_TAG_DIRTY); >> >> diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c >> index c920164..967ed7d 100644 >> --- a/fs/nilfs2/segment.c >> +++ b/fs/nilfs2/segment.c >> @@ -1599,7 +1599,7 @@ nilfs_copy_replace_page_buffers(struct page *page, struct list_head *out) >> kunmap_atomic(kaddr, KM_USER0); >> >> if (!TestSetPageWriteback(clone_page)) >> - inc_zone_page_state(clone_page, NR_WRITEBACK); >> + account_page_writeback(clone_page, page_mapping(clone_page)); >> unlock_page(clone_page); >> >> return 0; >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index a2b4804..b138392 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -855,6 +855,7 @@ int __set_page_dirty_no_writeback(struct page *page); >> int redirty_page_for_writepage(struct writeback_control *wbc, >> struct page *page); >> void account_page_dirtied(struct page *page, struct address_space *mapping); >> +void account_page_writeback(struct page *page, struct address_space *mapping); >> int set_page_dirty(struct page *page); >> int set_page_dirty_lock(struct page *page); >> int clear_page_dirty_for_io(struct page *page); >> diff --git a/mm/page-writeback.c b/mm/page-writeback.c >> index 37498ef..b8e7b3b 100644 >> --- a/mm/page-writeback.c >> +++ b/mm/page-writeback.c >> @@ -1096,6 +1096,21 @@ void account_page_dirtied(struct page *page, struct address_space *mapping) >> task_io_account_write(PAGE_CACHE_SIZE); >> } >> } >> +EXPORT_SYMBOL(account_page_dirtied); >> + >> +/* >> + * Helper function for set_page_writeback family. >> + * NOTE: Unlike account_page_dirtied this does not rely on being atomic >> + * wrt interrupts. >> + */ >> + >> +void account_page_writeback(struct page *page, struct address_space *mapping) >> +{ >> + if (mapping_cap_account_dirty(mapping)) > > The 'if' test and *mapping parameter looks unnecessary at least for > now. The only place a mapping has BDI_CAP_NO_ACCT_WB but not > BDI_CAP_NO_WRITEBACK is fuse, which does its own accounting. Cool. Thanks.
WARNING: multiple messages have this Message-ID (diff)
From: Michael Rubin <mrubin@google.com> To: Wu Fengguang <fengguang.wu@intel.com> Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jack@suse.cz, riel@redhat.com, akpm@linux-foundation.org, david@fromorbit.com, hch@lst.de, axboe@kernel.dk Subject: Re: [PATCH 1/3] mm: helper functions for dirty and writeback accounting Date: Fri, 20 Aug 2010 01:19:33 -0700 [thread overview] Message-ID: <AANLkTinzS5J2PsG4Ftmbjvpi=beyD54A=ZrRw3_DA8jv@mail.gmail.com> (raw) In-Reply-To: <20100820023419.GA5502@localhost> On Thu, Aug 19, 2010 at 7:34 PM, Wu Fengguang <fengguang.wu@intel.com> wrote: > On Thu, Aug 19, 2010 at 01:57:25PM -0700, Michael Rubin wrote: >> Exporting account_pages_dirty and adding a symmetric routine >> account_pages_writeback. > > s/account_pages_writeback/account_page_writeback/ Got it. thanks. > I'd recommend to separate the changes into two patches. > It's actually a bug fix to export account_pages_dirty() for ceph, > which should be a good candidate for 2.6.36. Good idea. >> This allows code outside of the mm core to safely manipulate page state >> and not worry about the other accounting. Not using these routines means >> that some code will lose track of the accounting and we get bugs. This >> has happened once already. >> >> Signed-off-by: Michael Rubin <mrubin@google.com> >> --- >> fs/ceph/addr.c | 8 ++------ >> fs/nilfs2/segment.c | 2 +- >> include/linux/mm.h | 1 + >> mm/page-writeback.c | 15 +++++++++++++++ >> 4 files changed, 19 insertions(+), 7 deletions(-) >> >> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c >> index d9c60b8..359aa3a 100644 >> --- a/fs/ceph/addr.c >> +++ b/fs/ceph/addr.c >> @@ -106,12 +106,8 @@ static int ceph_set_page_dirty(struct page *page) >> if (page->mapping) { /* Race with truncate? */ >> WARN_ON_ONCE(!PageUptodate(page)); >> >> - if (mapping_cap_account_dirty(mapping)) { >> - __inc_zone_page_state(page, NR_FILE_DIRTY); >> - __inc_bdi_stat(mapping->backing_dev_info, >> - BDI_RECLAIMABLE); >> - task_io_account_write(PAGE_CACHE_SIZE); >> - } >> + if (mapping_cap_account_dirty(mapping)) > > That 'if' is not necessary. account_page_dirtied() already has one. > The extra 'if' is not an optimization either, because the ceph fs is > not likely to have un-accountable mappings. Sweet. Thanks. > >> + account_page_dirtied(page, page->mapping); >> radix_tree_tag_set(&mapping->page_tree, >> page_index(page), PAGECACHE_TAG_DIRTY); >> >> diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c >> index c920164..967ed7d 100644 >> --- a/fs/nilfs2/segment.c >> +++ b/fs/nilfs2/segment.c >> @@ -1599,7 +1599,7 @@ nilfs_copy_replace_page_buffers(struct page *page, struct list_head *out) >> kunmap_atomic(kaddr, KM_USER0); >> >> if (!TestSetPageWriteback(clone_page)) >> - inc_zone_page_state(clone_page, NR_WRITEBACK); >> + account_page_writeback(clone_page, page_mapping(clone_page)); >> unlock_page(clone_page); >> >> return 0; >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index a2b4804..b138392 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -855,6 +855,7 @@ int __set_page_dirty_no_writeback(struct page *page); >> int redirty_page_for_writepage(struct writeback_control *wbc, >> struct page *page); >> void account_page_dirtied(struct page *page, struct address_space *mapping); >> +void account_page_writeback(struct page *page, struct address_space *mapping); >> int set_page_dirty(struct page *page); >> int set_page_dirty_lock(struct page *page); >> int clear_page_dirty_for_io(struct page *page); >> diff --git a/mm/page-writeback.c b/mm/page-writeback.c >> index 37498ef..b8e7b3b 100644 >> --- a/mm/page-writeback.c >> +++ b/mm/page-writeback.c >> @@ -1096,6 +1096,21 @@ void account_page_dirtied(struct page *page, struct address_space *mapping) >> task_io_account_write(PAGE_CACHE_SIZE); >> } >> } >> +EXPORT_SYMBOL(account_page_dirtied); >> + >> +/* >> + * Helper function for set_page_writeback family. >> + * NOTE: Unlike account_page_dirtied this does not rely on being atomic >> + * wrt interrupts. >> + */ >> + >> +void account_page_writeback(struct page *page, struct address_space *mapping) >> +{ >> + if (mapping_cap_account_dirty(mapping)) > > The 'if' test and *mapping parameter looks unnecessary at least for > now. The only place a mapping has BDI_CAP_NO_ACCT_WB but not > BDI_CAP_NO_WRITEBACK is fuse, which does its own accounting. Cool. Thanks. -- 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:[~2010-08-20 8:19 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-08-19 20:57 [PATCH 0/3] writeback: kernel visibility Michael Rubin 2010-08-19 20:57 ` Michael Rubin 2010-08-19 20:57 ` [PATCH 1/3] mm: helper functions for dirty and writeback accounting Michael Rubin 2010-08-19 20:57 ` Michael Rubin 2010-08-20 2:34 ` Wu Fengguang 2010-08-20 2:34 ` Wu Fengguang 2010-08-20 8:19 ` Michael Rubin [this message] 2010-08-20 8:19 ` Michael Rubin 2010-08-19 20:57 ` [PATCH 2/3] writeback: Adding pages_dirtied and pages_entered_writeback Michael Rubin 2010-08-19 20:57 ` Michael Rubin 2010-08-20 2:51 ` Wu Fengguang 2010-08-20 2:51 ` Wu Fengguang 2010-08-20 6:54 ` Wu Fengguang 2010-08-20 6:54 ` Wu Fengguang 2010-08-20 8:16 ` Michael Rubin 2010-08-20 8:16 ` Michael Rubin 2010-08-20 8:43 ` Wu Fengguang 2010-08-20 8:43 ` Wu Fengguang 2010-08-20 8:43 ` Wu Fengguang 2010-08-19 20:57 ` [PATCH 3/3] writeback: Reporting dirty thresholds in /proc/vmstat Michael Rubin 2010-08-19 20:57 ` Michael Rubin 2010-08-20 3:16 ` Wu Fengguang 2010-08-20 3:16 ` Wu Fengguang 2010-08-20 8:18 ` Michael Rubin 2010-08-20 8:18 ` Michael Rubin 2010-08-19 22:11 ` [PATCH 0/3] writeback: kernel visibility Rik van Riel 2010-08-19 22:11 ` Rik van Riel
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='AANLkTinzS5J2PsG4Ftmbjvpi=beyD54A=ZrRw3_DA8jv@mail.gmail.com' \ --to=mrubin@google.com \ --cc=akpm@linux-foundation.org \ --cc=axboe@kernel.dk \ --cc=david@fromorbit.com \ --cc=fengguang.wu@intel.com \ --cc=hch@lst.de \ --cc=jack@suse.cz \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=riel@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.