From: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
To: linux-mm <linux-mm@kvack.org>
Subject: [RFC] Don't set/test/wait-for radix tree tags if no capability
Date: Wed, 13 Sep 2006 15:35:14 -0400 [thread overview]
Message-ID: <1158176114.5328.52.camel@localhost> (raw)
While debugging a problem [in the out-of-tree migration cache], I
noticed a lot of radix-tree tag activity for address spaces that have
the BDI_CAP_NO_{ACCT_DIRTY|WRITEBACK} capability flags set--effectively
disabling these capabilities--in their backing device. Altho'
functionally benign, I believe that this unnecessary overhead. Seeking
contrary opinions.
Would this patch, if correct, be worthwhile? Seems not to cause any
problem, and does eliminate the tag handling for swap space and similar
address spaces.
---
page-writeback functions are setting/testing radix-tree tags for
mappings whose backing device has the corresponding "capabilities"
turned off via the BDI_CAP_NO_{ACCT_DIRTY|WRITEBACK} flags.
This patch makes all setting/getting/waiting-on the radix-tree
tags conditional on the corresponding mapping capability,
eliminating a lot of unnecessary radix tree traversal--e.g.,
for swap cache.
Note: perhaps all of the tags should be conditional on the
'_WRITEBACK capability alone, because if the mapping doesn't
support writeback, there is no need to track dirty pages in the
cache, whether or not dirty page accounting is enabled. However,
currently, all mappings that have one of the capability flags set
also have the other flag set. Might not always be the case, tho.
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
mm/filemap.c | 2 +-
mm/page-writeback.c | 21 ++++++++++++---------
2 files changed, 13 insertions(+), 10 deletions(-)
Index: linux-2.6.18-rc6-mm2/mm/page-writeback.c
===================================================================
--- linux-2.6.18-rc6-mm2.orig/mm/page-writeback.c 2006-09-13 11:46:50.000000000 -0400
+++ linux-2.6.18-rc6-mm2/mm/page-writeback.c 2006-09-13 14:44:57.000000000 -0400
@@ -766,11 +766,13 @@ int __set_page_dirty_nobuffers(struct pa
mapping2 = page_mapping(page);
if (mapping2) { /* Race with truncate? */
BUG_ON(mapping2 != mapping);
- if (mapping_cap_account_dirty(mapping))
+ if (mapping_cap_account_dirty(mapping)) {
__inc_zone_page_state(page,
NR_FILE_DIRTY);
- radix_tree_tag_set(&mapping->page_tree,
- page_index(page), PAGECACHE_TAG_DIRTY);
+ radix_tree_tag_set(&mapping->page_tree,
+ page_index(page),
+ PAGECACHE_TAG_DIRTY);
+ }
}
write_unlock_irq(&mapping->tree_lock);
if (mapping->host) {
@@ -855,9 +857,10 @@ int test_clear_page_dirty(struct page *p
if (mapping) {
write_lock_irqsave(&mapping->tree_lock, flags);
if (TestClearPageDirty(page)) {
- radix_tree_tag_clear(&mapping->page_tree,
- page_index(page),
- PAGECACHE_TAG_DIRTY);
+ if (mapping_cap_account_dirty(mapping))
+ radix_tree_tag_clear(&mapping->page_tree,
+ page_index(page),
+ PAGECACHE_TAG_DIRTY);
write_unlock_irqrestore(&mapping->tree_lock, flags);
/*
* We can continue to use `mapping' here because the
@@ -919,7 +922,7 @@ int test_clear_page_writeback(struct pag
write_lock_irqsave(&mapping->tree_lock, flags);
ret = TestClearPageWriteback(page);
- if (ret)
+ if (ret && mapping_cap_writeback_dirty(mapping))
radix_tree_tag_clear(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_WRITEBACK);
@@ -940,11 +943,11 @@ int test_set_page_writeback(struct page
write_lock_irqsave(&mapping->tree_lock, flags);
ret = TestSetPageWriteback(page);
- if (!ret)
+ if (!ret && mapping_cap_writeback_dirty(mapping))
radix_tree_tag_set(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_WRITEBACK);
- if (!PageDirty(page))
+ if (!PageDirty(page) && mapping_cap_account_dirty(mapping))
radix_tree_tag_clear(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_DIRTY);
Index: linux-2.6.18-rc6-mm2/mm/filemap.c
===================================================================
--- linux-2.6.18-rc6-mm2.orig/mm/filemap.c 2006-09-13 14:44:44.000000000 -0400
+++ linux-2.6.18-rc6-mm2/mm/filemap.c 2006-09-13 14:44:57.000000000 -0400
@@ -258,7 +258,7 @@ int wait_on_page_writeback_range(struct
int ret = 0;
pgoff_t index;
- if (end < start)
+ if (end < start || !mapping_cap_writeback_dirty(mapping))
return 0;
pagevec_init(&pvec, 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 reply other threads:[~2006-09-13 19:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-13 19:35 Lee Schermerhorn [this message]
2006-09-13 20:51 ` Christoph Lameter
2006-09-13 22:12 ` Lee Schermerhorn
2006-09-14 15:23 ` Hugh Dickins
2006-09-14 15:52 ` Lee Schermerhorn
2006-09-14 16:20 ` Hugh Dickins
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=1158176114.5328.52.camel@localhost \
--to=lee.schermerhorn@hp.com \
--cc=linux-mm@kvack.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