From 95e28a3f876b9efd9ab5f87788d59ca94a80386a Mon Sep 17 00:00:00 2001 From: Dan Magenheimer Date: Thu, 20 Sep 2012 12:16:52 -0700 Subject: [PATCH] --- yaml --- r: 329133 b: refs/heads/master c: e3483a5f3a8ef448c229a2aceca9b2ad6a46b8ec h: refs/heads/master i: 329131: 38489a2a2721ae0b45a8aab4eb1ea85dfc13a208 v: v3 --- [refs] | 2 +- trunk/include/linux/frontswap.h | 2 ++ trunk/mm/frontswap.c | 23 ++++++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index b775a1de2212..93cec308c1bb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a00bb1e9fc0925c0061e9d844523a3a47a7e2f7f +refs/heads/master: e3483a5f3a8ef448c229a2aceca9b2ad6a46b8ec diff --git a/trunk/include/linux/frontswap.h b/trunk/include/linux/frontswap.h index 0e4e2eec5c1d..30442547b9e6 100644 --- a/trunk/include/linux/frontswap.h +++ b/trunk/include/linux/frontswap.h @@ -19,6 +19,8 @@ extern struct frontswap_ops extern void frontswap_shrink(unsigned long); extern unsigned long frontswap_curr_pages(void); extern void frontswap_writethrough(bool); +#define FRONTSWAP_HAS_EXCLUSIVE_GETS +extern void frontswap_tmem_exclusive_gets(bool); extern void __frontswap_init(unsigned type); extern int __frontswap_store(struct page *page); diff --git a/trunk/mm/frontswap.c b/trunk/mm/frontswap.c index 0547a35f798b..2890e67d6026 100644 --- a/trunk/mm/frontswap.c +++ b/trunk/mm/frontswap.c @@ -44,6 +44,13 @@ EXPORT_SYMBOL(frontswap_enabled); */ static bool frontswap_writethrough_enabled __read_mostly; +/* + * If enabled, the underlying tmem implementation is capable of doing + * exclusive gets, so frontswap_load, on a successful tmem_get must + * mark the page as no longer in frontswap AND mark it dirty. + */ +static bool frontswap_tmem_exclusive_gets_enabled __read_mostly; + #ifdef CONFIG_DEBUG_FS /* * Counters available via /sys/kernel/debug/frontswap (if debugfs is @@ -96,6 +103,15 @@ void frontswap_writethrough(bool enable) } EXPORT_SYMBOL(frontswap_writethrough); +/* + * Enable/disable frontswap exclusive gets (see above). + */ +void frontswap_tmem_exclusive_gets(bool enable) +{ + frontswap_tmem_exclusive_gets_enabled = enable; +} +EXPORT_SYMBOL(frontswap_tmem_exclusive_gets); + /* * Called when a swap device is swapon'd. */ @@ -174,8 +190,13 @@ int __frontswap_load(struct page *page) BUG_ON(sis == NULL); if (frontswap_test(sis, offset)) ret = frontswap_ops.load(type, offset, page); - if (ret == 0) + if (ret == 0) { inc_frontswap_loads(); + if (frontswap_tmem_exclusive_gets_enabled) { + SetPageDirty(page); + frontswap_clear(sis, offset); + } + } return ret; } EXPORT_SYMBOL(__frontswap_load);