[Devel] [PATCH RHEL7 COMMIT] tswap: introduce tswap_delete_page helper
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Jun 22 02:38:16 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.15
------>
commit 95fbad6502f46b44e5d929fb8144f938eaa21054
Author: Vladimir Davydov <vdavydov at parallels.com>
Date: Mon Jun 22 13:38:16 2015 +0400
tswap: introduce tswap_delete_page helper
Patchset description:
Patches 1 and 2 fix memory corruption caused by tswap:
https://jira.sw.ru/browse/PSBM-34269
Patch 5 fixes pinning a page in tswap.
Patch 7 fixes indefinitely long stalls during tswap reclaim.
Patch 3, 4, and 6 do cleanup.
Vladimir Davydov (6):
tswap: enable exclusive gets
tswap: do not allocate a page on store if there is already one
tswap: introduce tswap_delete_page helper
tswap: shrink tswap page if swapcache page is uptodate
tswap: use global lock to protect lru lists
tswap: do not writeback pages on reclaim
Weijie Yang (1):
mm: frontswap: invalidate expired data on a dup-store failure
###############################################################
This patch description:
For the sake of the following changes.
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
mm/tswap.c | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/mm/tswap.c b/mm/tswap.c
index c31047a..1c19499 100644
--- a/mm/tswap.c
+++ b/mm/tswap.c
@@ -86,6 +86,22 @@ static int tswap_insert_page(swp_entry_t entry, struct page *page)
return err;
}
+static struct page *tswap_delete_page(swp_entry_t entry)
+{
+ struct page *page;
+
+ spin_lock(&tswap_lock);
+ page = radix_tree_delete(&tswap_page_tree, entry.val);
+ if (page)
+ tswap_nr_pages--;
+ spin_unlock(&tswap_lock);
+ if (page) {
+ BUG_ON(page_private(page) != entry.val);
+ tswap_lru_del(page);
+ }
+ return page;
+}
+
static unsigned long tswap_shrink_count(struct shrinker *shrink,
struct shrink_control *sc)
{
@@ -262,31 +278,24 @@ copy:
static int tswap_frontswap_load(unsigned type, pgoff_t offset,
struct page *page)
{
- swp_entry_t entry = swp_entry(type, offset);
struct page *cache_page;
- spin_lock(&tswap_lock);
- cache_page = radix_tree_delete(&tswap_page_tree, entry.val);
- if (cache_page)
- tswap_nr_pages--;
- spin_unlock(&tswap_lock);
-
+ cache_page = tswap_delete_page(swp_entry(type, offset));
if (!cache_page)
return -1;
- BUG_ON(page_private(cache_page) != entry.val);
- tswap_lru_del(cache_page);
-
- if (page)
- copy_highpage(page, cache_page);
+ copy_highpage(page, cache_page);
put_page(cache_page);
-
return 0;
}
static void tswap_frontswap_invalidate_page(unsigned type, pgoff_t offset)
{
- (void)tswap_frontswap_load(type, offset, NULL);
+ struct page *cache_page;
+
+ cache_page = tswap_delete_page(swp_entry(type, offset));
+ if (cache_page)
+ put_page(cache_page);
}
static void tswap_frontswap_invalidate_area(unsigned type)
More information about the Devel
mailing list