summaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2010-05-04 17:27:05 +0200
committerJ. Bruce Fields <bfields@citi.umich.edu>2010-05-04 17:29:05 +0200
commit5306293c9cd2caf41849cc909281bda628bb989e (patch)
tree3be4e8231e2772c8a43ddbef5c6a72c20b3054bb /mm/swapfile.c
parentnfsd4: use local variable in nfs4svc_encode_compoundres (diff)
parentLinux 2.6.34-rc6 (diff)
downloadlinux-5306293c9cd2caf41849cc909281bda628bb989e.tar.xz
linux-5306293c9cd2caf41849cc909281bda628bb989e.zip
Merge commit 'v2.6.34-rc6'
Conflicts: fs/nfsd/nfs4callback.c
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 84374d8cf814..6cd0a8f90dc7 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -723,6 +723,37 @@ int free_swap_and_cache(swp_entry_t entry)
return p != NULL;
}
+#ifdef CONFIG_CGROUP_MEM_RES_CTLR
+/**
+ * mem_cgroup_count_swap_user - count the user of a swap entry
+ * @ent: the swap entry to be checked
+ * @pagep: the pointer for the swap cache page of the entry to be stored
+ *
+ * Returns the number of the user of the swap entry. The number is valid only
+ * for swaps of anonymous pages.
+ * If the entry is found on swap cache, the page is stored to pagep with
+ * refcount of it being incremented.
+ */
+int mem_cgroup_count_swap_user(swp_entry_t ent, struct page **pagep)
+{
+ struct page *page;
+ struct swap_info_struct *p;
+ int count = 0;
+
+ page = find_get_page(&swapper_space, ent.val);
+ if (page)
+ count += page_mapcount(page);
+ p = swap_info_get(ent);
+ if (p) {
+ count += swap_count(p->swap_map[swp_offset(ent)]);
+ spin_unlock(&swap_lock);
+ }
+
+ *pagep = page;
+ return count;
+}
+#endif
+
#ifdef CONFIG_HIBERNATION
/*
* Find the swap type that corresponds to given device (if any).