diff options
author | Tim Gardner <tim.gardner@canonical.com> | 2009-03-15 13:38:17 -0600 |
---|---|---|
committer | John Rigby <john.rigby@linaro.org> | 2011-10-17 02:31:45 -0600 |
commit | cf4d5016dee277f4313a0a8a7afe5111b420fb0a (patch) | |
tree | 9f9a2a78cfd2ead03f07a344465596c51dc22399 | |
parent | b49f4014de07f2c96c3d325ffe08164dda056d1e (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>
-rw-r--r-- | include/linux/swap.h | 2 | ||||
-rw-r--r-- | mm/swapfile.c | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index a273468f828..8f2401cf4fa 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -194,6 +194,7 @@ struct swap_info_struct { struct block_device *bdev; /* swap device or bdev of swap file */ struct file *swap_file; /* seldom referenced */ unsigned int old_block_size; /* seldom referenced */ + void (*notify_swap_entry_free_fn) (unsigned long); }; struct swap_list_t { @@ -343,6 +344,7 @@ extern sector_t swapdev_block(int, pgoff_t); extern int reuse_swap_page(struct page *); extern int try_to_free_swap(struct page *); struct backing_dev_info; +extern void set_notify_swap_entry_free(unsigned, void (*) (unsigned long)); /* linux/mm/thrash.c */ extern struct mm_struct *swap_token_mm; diff --git a/mm/swapfile.c b/mm/swapfile.c index ff8dc1a18cb..5434ca75f3d 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; } @@ -2299,6 +2305,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. */ |