* [PATCH v4 1/6] Introduce delete_from_page_cache
2011-02-06 10:47 [PATCH v4 0/6] Change page reference handling semantic of page cache Minchan Kim
@ 2011-02-06 10:48 ` Minchan Kim
2011-02-06 10:48 ` [PATCH v4 2/6] hugetlbfs: Change remove_from_page_cache Minchan Kim
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2011-02-06 10:48 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, LKML, KAMEZAWA Hiroyuki, Hugh Dickins, Mel Gorman,
KOSAKI Motohiro, Johannes Weiner, Minchan Kim, Christoph Hellwig
This function works as just wrapper remove_from_page_cache.
The difference is that it decreases page references in itself.
So caller have to make sure it has a page reference before calling.
This patch is ready for removing remove_from_page_cache.
Cc: Christoph Hellwig <hch@infradead.org>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
---
include/linux/pagemap.h | 1 +
mm/filemap.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 26946ad..a943985 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -457,6 +457,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
pgoff_t index, gfp_t gfp_mask);
extern void remove_from_page_cache(struct page *page);
extern void __remove_from_page_cache(struct page *page);
+extern void delete_from_page_cache(struct page *page);
int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask);
/*
diff --git a/mm/filemap.c b/mm/filemap.c
index 3c89c96..f056d0c 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -166,6 +166,22 @@ void remove_from_page_cache(struct page *page)
}
EXPORT_SYMBOL(remove_from_page_cache);
+/**
+ * delete_from_page_cache - delete page from page cache
+ * @page: the page which the kernel is trying to remove from page cache
+ *
+ * This must be called only on pages that have
+ * been verified to be in the page cache and locked.
+ * It will never put the page into the free list,
+ * the caller has a reference on the page.
+ */
+void delete_from_page_cache(struct page *page)
+{
+ remove_from_page_cache(page);
+ page_cache_release(page);
+}
+EXPORT_SYMBOL(delete_from_page_cache);
+
static int sync_page(void *word)
{
struct address_space *mapping;
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 2/6] hugetlbfs: Change remove_from_page_cache
2011-02-06 10:47 [PATCH v4 0/6] Change page reference handling semantic of page cache Minchan Kim
2011-02-06 10:48 ` [PATCH v4 1/6] Introduce delete_from_page_cache Minchan Kim
@ 2011-02-06 10:48 ` Minchan Kim
2011-02-06 10:48 ` [PATCH v4 3/6] shmem: " Minchan Kim
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2011-02-06 10:48 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, LKML, KAMEZAWA Hiroyuki, Hugh Dickins, Mel Gorman,
KOSAKI Motohiro, Johannes Weiner, Minchan Kim, William Irwin
This patch series changes remove_from_page_cache's page ref counting
rule. Page cache ref count is decreased in delete_from_page_cache.
So we don't need decreasing page reference by caller.
Cc: William Irwin <wli@holomorphy.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
---
fs/hugetlbfs/inode.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 9885082..b9eeb1c 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -332,8 +332,7 @@ static void truncate_huge_page(struct page *page)
{
cancel_dirty_page(page, /* No IO accounting for huge pages? */0);
ClearPageUptodate(page);
- remove_from_page_cache(page);
- put_page(page);
+ delete_from_page_cache(page);
}
static void truncate_hugepages(struct inode *inode, loff_t lstart)
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 3/6] shmem: Change remove_from_page_cache
2011-02-06 10:47 [PATCH v4 0/6] Change page reference handling semantic of page cache Minchan Kim
2011-02-06 10:48 ` [PATCH v4 1/6] Introduce delete_from_page_cache Minchan Kim
2011-02-06 10:48 ` [PATCH v4 2/6] hugetlbfs: Change remove_from_page_cache Minchan Kim
@ 2011-02-06 10:48 ` Minchan Kim
2011-02-06 10:48 ` [PATCH v4 4/6] truncate: " Minchan Kim
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2011-02-06 10:48 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, LKML, KAMEZAWA Hiroyuki, Hugh Dickins, Mel Gorman,
KOSAKI Motohiro, Johannes Weiner, Minchan Kim
This patch series changes remove_from_page_cache's page ref counting
rule. Page cache ref count is decreased in delete_from_page_cache.
So we don't need decreasing page reference by caller.
Acked-by:Hugh Dickins <hughd@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
---
mm/shmem.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 7c9cdc6..4549134 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1081,7 +1081,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
shmem_recalc_inode(inode);
if (swap.val && add_to_swap_cache(page, swap, GFP_ATOMIC) == 0) {
- remove_from_page_cache(page);
+ delete_from_page_cache(page);
shmem_swp_set(info, entry, swap.val);
shmem_swp_unmap(entry);
if (list_empty(&info->swaplist))
@@ -1091,7 +1091,6 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
spin_unlock(&info->lock);
swap_shmem_alloc(swap);
BUG_ON(page_mapped(page));
- page_cache_release(page); /* pagecache ref */
swap_writepage(page, wbc);
if (inode) {
mutex_lock(&shmem_swaplist_mutex);
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 4/6] truncate: Change remove_from_page_cache
2011-02-06 10:47 [PATCH v4 0/6] Change page reference handling semantic of page cache Minchan Kim
` (2 preceding siblings ...)
2011-02-06 10:48 ` [PATCH v4 3/6] shmem: " Minchan Kim
@ 2011-02-06 10:48 ` Minchan Kim
2011-02-06 10:48 ` [PATCH v4 5/6] Good bye remove_from_page_cache Minchan Kim
2011-02-06 10:48 ` [PATCH v4 6/6] Change __remove_from_page_cache Minchan Kim
5 siblings, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2011-02-06 10:48 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, LKML, KAMEZAWA Hiroyuki, Hugh Dickins, Mel Gorman,
KOSAKI Motohiro, Johannes Weiner, Minchan Kim, Dan Magenheimer,
Andi Kleen, Nick Piggin, Al Viro
This patch series changes remove_from_page_cache's page ref counting
rule. Page cache ref count is decreased in delete_from_page_cache.
So we don't need decreasing page reference by caller.
Cc: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Nick Piggin <npiggin@kernel.dk>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
---
mm/truncate.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/mm/truncate.c b/mm/truncate.c
index 4d415b3..faf65a5 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -108,13 +108,12 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
cancel_dirty_page(page, PAGE_CACHE_SIZE);
clear_page_mlock(page);
- remove_from_page_cache(page);
+ delete_from_page_cache(page);
ClearPageMappedToDisk(page);
- /* this must be after the remove_from_page_cache which
+ /* this must be after the delete_from_page_cache which
* calls cleancache_put_page (and note page->mapping is now NULL)
*/
cleancache_flush_page(mapping, page);
- page_cache_release(page); /* pagecache ref */
return 0;
}
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 5/6] Good bye remove_from_page_cache
2011-02-06 10:47 [PATCH v4 0/6] Change page reference handling semantic of page cache Minchan Kim
` (3 preceding siblings ...)
2011-02-06 10:48 ` [PATCH v4 4/6] truncate: " Minchan Kim
@ 2011-02-06 10:48 ` Minchan Kim
2011-02-06 10:48 ` [PATCH v4 6/6] Change __remove_from_page_cache Minchan Kim
5 siblings, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2011-02-06 10:48 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, LKML, KAMEZAWA Hiroyuki, Hugh Dickins, Mel Gorman,
KOSAKI Motohiro, Johannes Weiner, Minchan Kim, Christoph Hellwig
Now delete_from_page_cache replaces remove_from_page_cache.
So we remove remove_from_page_cache so fs or something out of
mainline will notice it when compile time and can fix it.
Cc: Christoph Hellwig <hch@infradead.org>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
---
include/linux/pagemap.h | 1 -
mm/filemap.c | 26 ++++++++++----------------
2 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index a943985..631b1b6 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -455,7 +455,6 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
pgoff_t index, gfp_t gfp_mask);
int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
pgoff_t index, gfp_t gfp_mask);
-extern void remove_from_page_cache(struct page *page);
extern void __remove_from_page_cache(struct page *page);
extern void delete_from_page_cache(struct page *page);
int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask);
diff --git a/mm/filemap.c b/mm/filemap.c
index f056d0c..5f3a389 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -148,7 +148,16 @@ void __remove_from_page_cache(struct page *page)
}
}
-void remove_from_page_cache(struct page *page)
+/**
+ * delete_from_page_cache - delete page from page cache
+ * @page: the page which the kernel is trying to remove from page cache
+ *
+ * This must be called only on pages that have
+ * been verified to be in the page cache and locked.
+ * It will never put the page into the free list,
+ * the caller has a reference on the page.
+ */
+void delete_from_page_cache(struct page *page)
{
struct address_space *mapping = page->mapping;
void (*freepage)(struct page *);
@@ -163,21 +172,6 @@ void remove_from_page_cache(struct page *page)
if (freepage)
freepage(page);
-}
-EXPORT_SYMBOL(remove_from_page_cache);
-
-/**
- * delete_from_page_cache - delete page from page cache
- * @page: the page which the kernel is trying to remove from page cache
- *
- * This must be called only on pages that have
- * been verified to be in the page cache and locked.
- * It will never put the page into the free list,
- * the caller has a reference on the page.
- */
-void delete_from_page_cache(struct page *page)
-{
- remove_from_page_cache(page);
page_cache_release(page);
}
EXPORT_SYMBOL(delete_from_page_cache);
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 6/6] Change __remove_from_page_cache
2011-02-06 10:47 [PATCH v4 0/6] Change page reference handling semantic of page cache Minchan Kim
` (4 preceding siblings ...)
2011-02-06 10:48 ` [PATCH v4 5/6] Good bye remove_from_page_cache Minchan Kim
@ 2011-02-06 10:48 ` Minchan Kim
5 siblings, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2011-02-06 10:48 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, LKML, KAMEZAWA Hiroyuki, Hugh Dickins, Mel Gorman,
KOSAKI Motohiro, Johannes Weiner, Minchan Kim, Christoph Hellwig
Now we renamed remove_from_page_cache with delete_from_page_cache.
As consistency of __remove_from_swap_cache and remove_from_swap_cache,
We change internal page cache handling function name, too.
Cc: Christoph Hellwig <hch@infradead.org>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
---
include/linux/pagemap.h | 2 +-
mm/filemap.c | 8 ++++----
mm/memory-failure.c | 2 +-
mm/truncate.c | 2 +-
mm/vmscan.c | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 631b1b6..e407601 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -455,7 +455,7 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
pgoff_t index, gfp_t gfp_mask);
int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
pgoff_t index, gfp_t gfp_mask);
-extern void __remove_from_page_cache(struct page *page);
+extern void __delete_from_page_cache(struct page *page);
extern void delete_from_page_cache(struct page *page);
int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask);
diff --git a/mm/filemap.c b/mm/filemap.c
index 5f3a389..351571f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -109,11 +109,11 @@
*/
/*
- * Remove a page from the page cache and free it. Caller has to make
+ * Delete a page from the page cache and free it. Caller has to make
* sure the page is locked and that nobody else uses it - or that usage
* is safe. The caller must hold the mapping's tree_lock.
*/
-void __remove_from_page_cache(struct page *page)
+void __delete_from_page_cache(struct page *page)
{
struct address_space *mapping = page->mapping;
@@ -166,7 +166,7 @@ void delete_from_page_cache(struct page *page)
freepage = mapping->a_ops->freepage;
spin_lock_irq(&mapping->tree_lock);
- __remove_from_page_cache(page);
+ __delete_from_page_cache(page);
spin_unlock_irq(&mapping->tree_lock);
mem_cgroup_uncharge_cache_page(page);
@@ -453,7 +453,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
new->index = offset;
spin_lock_irq(&mapping->tree_lock);
- __remove_from_page_cache(old);
+ __delete_from_page_cache(old);
error = radix_tree_insert(&mapping->page_tree, offset, new);
BUG_ON(error);
mapping->nrpages++;
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 0207c2f..f15ceea 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1130,7 +1130,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
/*
* Now take care of user space mappings.
- * Abort on fail: __remove_from_page_cache() assumes unmapped page.
+ * Abort on fail: __delete_from_page_cache() assumes unmapped page.
*/
if (hwpoison_user_mappings(p, pfn, trapno) != SWAP_SUCCESS) {
printk(KERN_ERR "MCE %#lx: cannot unmap page, give up\n", pfn);
diff --git a/mm/truncate.c b/mm/truncate.c
index faf65a5..94be6c0 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -394,7 +394,7 @@ invalidate_complete_page2(struct address_space *mapping, struct page *page)
clear_page_mlock(page);
BUG_ON(page_has_private(page));
- __remove_from_page_cache(page);
+ __delete_from_page_cache(page);
spin_unlock_irq(&mapping->tree_lock);
mem_cgroup_uncharge_cache_page(page);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 148c6e6..43bfc4e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -514,7 +514,7 @@ static int __remove_mapping(struct address_space *mapping, struct page *page)
freepage = mapping->a_ops->freepage;
- __remove_from_page_cache(page);
+ __delete_from_page_cache(page);
spin_unlock_irq(&mapping->tree_lock);
mem_cgroup_uncharge_cache_page(page);
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread