summaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>2016-04-01 08:29:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-04-04 13:41:08 -0400
commit09cbfeaf1a5a67bfb3201e0c83c810cecb2efa5a (patch)
tree6cdf210c9c0f981cd22544feeba701892ec19464 /mm/swapfile.c
parentc05c2ec96bb8b7310da1055c7b9d786a3ec6dc0c (diff)
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time ago with promise that one day it will be possible to implement page cache with bigger chunks than PAGE_SIZE. This promise never materialized. And unlikely will. We have many places where PAGE_CACHE_SIZE assumed to be equal to PAGE_SIZE. And it's constant source of confusion on whether PAGE_CACHE_* or PAGE_* constant should be used in a particular case, especially on the border between fs and mm. Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much breakage to be doable. Let's stop pretending that pages in page cache are special. They are not. The changes are pretty straight-forward: - <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN}; - page_cache_get() -> get_page(); - page_cache_release() -> put_page(); This patch contains automated changes generated with coccinelle using script below. For some reason, coccinelle doesn't patch header files. I've called spatch for them manually. The only adjustment after coccinelle is revert of changes to PAGE_CAHCE_ALIGN definition: we are going to drop it later. There are few places in the code where coccinelle didn't reach. I'll fix them manually in a separate patch. Comments and documentation also will be addressed with the separate patch. virtual patch @@ expression E; @@ - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ expression E; @@ - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ @@ - PAGE_CACHE_SHIFT + PAGE_SHIFT @@ @@ - PAGE_CACHE_SIZE + PAGE_SIZE @@ @@ - PAGE_CACHE_MASK + PAGE_MASK @@ expression E; @@ - PAGE_CACHE_ALIGN(E) + PAGE_ALIGN(E) @@ expression E; @@ - page_cache_get(E) + get_page(E) @@ expression E; @@ - page_cache_release(E) + put_page(E) Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 560ad380634c..83874eced5bf 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -119,7 +119,7 @@ __try_to_reclaim_swap(struct swap_info_struct *si, unsigned long offset)
119 ret = try_to_free_swap(page); 119 ret = try_to_free_swap(page);
120 unlock_page(page); 120 unlock_page(page);
121 } 121 }
122 page_cache_release(page); 122 put_page(page);
123 return ret; 123 return ret;
124} 124}
125 125
@@ -1000,7 +1000,7 @@ int free_swap_and_cache(swp_entry_t entry)
1000 page = find_get_page(swap_address_space(entry), 1000 page = find_get_page(swap_address_space(entry),
1001 entry.val); 1001 entry.val);
1002 if (page && !trylock_page(page)) { 1002 if (page && !trylock_page(page)) {
1003 page_cache_release(page); 1003 put_page(page);
1004 page = NULL; 1004 page = NULL;
1005 } 1005 }
1006 } 1006 }
@@ -1017,7 +1017,7 @@ int free_swap_and_cache(swp_entry_t entry)
1017 SetPageDirty(page); 1017 SetPageDirty(page);
1018 } 1018 }
1019 unlock_page(page); 1019 unlock_page(page);
1020 page_cache_release(page); 1020 put_page(page);
1021 } 1021 }
1022 return p != NULL; 1022 return p != NULL;
1023} 1023}
@@ -1518,7 +1518,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
1518 } 1518 }
1519 if (retval) { 1519 if (retval) {
1520 unlock_page(page); 1520 unlock_page(page);
1521 page_cache_release(page); 1521 put_page(page);
1522 break; 1522 break;
1523 } 1523 }
1524 1524
@@ -1570,7 +1570,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
1570 */ 1570 */
1571 SetPageDirty(page); 1571 SetPageDirty(page);
1572 unlock_page(page); 1572 unlock_page(page);
1573 page_cache_release(page); 1573 put_page(page);
1574 1574
1575 /* 1575 /*
1576 * Make sure that we aren't completely killing 1576 * Make sure that we aren't completely killing
@@ -2574,7 +2574,7 @@ bad_swap:
2574out: 2574out:
2575 if (page && !IS_ERR(page)) { 2575 if (page && !IS_ERR(page)) {
2576 kunmap(page); 2576 kunmap(page);
2577 page_cache_release(page); 2577 put_page(page);
2578 } 2578 }
2579 if (name) 2579 if (name)
2580 putname(name); 2580 putname(name);