lkml.org 
[lkml]   [2013]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFCv2][PATCH 4/5] break out mapping "freepage" code
From
Date

From: Dave Hansen <dave.hansen@linux.intel.com>

__remove_mapping() only deals with pages with mappings, meaning
page cache and swap cache.

At this point, the page has been removed from the mapping's radix
tree, and we need to ensure that any fs-specific (or swap-
specific) resources are freed up.

We will be using this function from a second location in a
following patch.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Mel Gorman <mgorman@suse.de>
---

linux.git-davehans/mm/vmscan.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)

diff -puN mm/vmscan.c~free_mapping_page mm/vmscan.c
--- linux.git/mm/vmscan.c~free_mapping_page 2013-05-16 13:27:25.520174273 -0700
+++ linux.git-davehans/mm/vmscan.c 2013-05-16 13:27:25.525174493 -0700
@@ -497,6 +497,24 @@ static int __remove_mapping(struct addre
return 1;
}

+/*
+ * Release any resources the mapping had tied up in
+ * the page.
+ */
+static void mapping_release_page(struct address_space *mapping,
+ struct page *page)
+{
+ if (PageSwapCache(page)) {
+ swapcache_free_page_entry(page);
+ } else {
+ void (*freepage)(struct page *);
+ freepage = mapping->a_ops->freepage;
+ mem_cgroup_uncharge_cache_page(page);
+ if (freepage != NULL)
+ freepage(page);
+ }
+}
+
static int lock_remove_mapping(struct address_space *mapping, struct page *page)
{
int ret;
@@ -510,15 +528,7 @@ static int lock_remove_mapping(struct ad
if (!ret)
return 0;

- if (PageSwapCache(page)) {
- swapcache_free_page_entry(page);
- } else {
- void (*freepage)(struct page *);
- freepage = mapping->a_ops->freepage;
- mem_cgroup_uncharge_cache_page(page);
- if (freepage != NULL)
- freepage(page);
- }
+ mapping_release_page(mapping, page);
return ret;
}

_

\
 
 \ /
  Last update: 2013-05-16 23:21    [W:0.088 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site