From: Konstantin Khlebnikov <khlebnikov@openvz.org>
To: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>,
linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 2/4] shmem: tag swap entries in radix tree
Date: Fri, 10 Feb 2012 23:42:26 +0400 [thread overview]
Message-ID: <20120210194225.6492.26880.stgit@zurg> (raw)
In-Reply-To: <20120210193249.6492.18768.stgit@zurg>
Shmem not uses any radix tree tags. Let's use one of them to mark
swap-entries stored in radix-tree as exceptional entries.
This allows to simplify and speedup truncate and swapoff operations.
Plus put tag manipulation, shmem_unuse(), shmem_unuse_inode() and
shmem_writepage() under CONFIG_SWAP. They are useless without swap.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
mm/shmem.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 4af8e85..b8e5f90 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -76,6 +76,9 @@ static struct vfsmount *shm_mnt;
/* Symlink up to this size is kmalloc'ed instead of using a swappable page */
#define SHORT_SYMLINK_LEN 128
+/* Radix-tree tag for swap-entries */
+#define SHMEM_TAG_SWAP 0
+
struct shmem_xattr {
struct list_head list; /* anchored by shmem_inode_info->xattr_list */
char *name; /* xattr name */
@@ -239,9 +242,17 @@ static int shmem_radix_tree_replace(struct address_space *mapping,
&mapping->tree_lock);
if (item != expected)
return -ENOENT;
- if (replacement)
+ if (replacement) {
+#ifdef CONFIG_SWAP
+ if (radix_tree_exceptional_entry(replacement))
+ radix_tree_tag_set(&mapping->page_tree,
+ index, SHMEM_TAG_SWAP);
+ else if (radix_tree_exceptional_entry(expected))
+ radix_tree_tag_clear(&mapping->page_tree,
+ index, SHMEM_TAG_SWAP);
+#endif
radix_tree_replace_slot(pslot, replacement);
- else
+ } else
radix_tree_delete(&mapping->page_tree, index);
return 0;
}
@@ -592,6 +603,8 @@ static void shmem_evict_inode(struct inode *inode)
end_writeback(inode);
}
+#ifdef CONFIG_SWAP
+
/*
* If swap found in inode, free it and move page from swapcache to filecache.
*/
@@ -760,6 +773,8 @@ redirty:
return 0;
}
+#endif /* CONFIG_SWAP */
+
#ifdef CONFIG_NUMA
#ifdef CONFIG_TMPFS
static void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
@@ -2281,7 +2296,9 @@ static void shmem_destroy_inodecache(void)
}
static const struct address_space_operations shmem_aops = {
+#ifdef CONFIG_SWAP
.writepage = shmem_writepage,
+#endif
.set_page_dirty = __set_page_dirty_no_writeback,
#ifdef CONFIG_TMPFS
.write_begin = shmem_write_begin,
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-02-10 19:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 19:42 [PATCH 0/4] shmem: radix-tree cleanups and swapoff optimizations Konstantin Khlebnikov
2012-02-10 19:42 ` [PATCH 1/4] shmem: simlify shmem_unlock_mapping Konstantin Khlebnikov
2012-02-10 19:42 ` Konstantin Khlebnikov [this message]
2012-02-10 19:42 ` [PATCH 3/4] shmem: use radix-tree iterator in shmem_unuse_inode() Konstantin Khlebnikov
2012-02-10 19:42 ` [PATCH 4/4] mm: use swap readahead at swapoff Konstantin Khlebnikov
2012-02-11 7:43 ` [PATCH 5/4] shmem: put shmem_delete_from_page_cache under CONFIG_SWAP Konstantin Khlebnikov
2012-02-11 7:44 ` [PATCH 6/4] shmem: simplify shmem_truncate_range Konstantin Khlebnikov
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=20120210194225.6492.26880.stgit@zurg \
--to=khlebnikov@openvz.org \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=torvalds@linux-foundation.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).