aboutsummaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorTim Gardner <tim.gardner@canonical.com>2009-03-15 13:38:17 -0600
committerJohn Rigby <john.rigby@linaro.org>2011-11-16 14:21:52 -0700
commit77cf5592498679ff28886123a744f030e5544df7 (patch)
treeb24cba499a1a21480fd12e4a896ff3b2e3e8667d /mm
parent4058fe6c098422061a079b534a305b8e24010ef9 (diff)
UBUNTU: SAUCE: (no-up) swap: Add notify_swap_entry_free callback for compcache
Code is required for ubuntu/compcache Signed-off-by: Ben Collins <ben.collins@canonical.com> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/swapfile.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 17bc224bce6..69a1fbcacea 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -562,6 +562,12 @@ static unsigned char swap_entry_free(struct swap_info_struct *p,
disk->fops->swap_slot_free_notify(p->bdev, offset);
}
+ if (!swap_count(count)) {
+ mem_cgroup_uncharge_swap(entry);
+ if (p->notify_swap_entry_free_fn)
+ p->notify_swap_entry_free_fn(offset);
+ }
+
return usage;
}
@@ -2290,6 +2296,23 @@ int swapcache_prepare(swp_entry_t entry)
}
/*
+ * Sets callback for event when swap_map[offset] == 0
+ * i.e. page at this swap offset is not longer used.
+ *
+ * type: identifies swap file
+ * fn: callback function
+ */
+void set_notify_swap_entry_free(unsigned type, void (*fn) (unsigned long))
+{
+ struct swap_info_struct *sis;
+ sis = swap_info[type];
+ BUG_ON(!sis);
+ sis->notify_swap_entry_free_fn = fn;
+ return;
+}
+EXPORT_SYMBOL(set_notify_swap_entry_free);
+
+/*
* swap_lock prevents swap_map being freed. Don't grab an extra
* reference on the swaphandle, it doesn't matter if it becomes unused.
*/