aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swap_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swap_state.c')
-rw-r--r--mm/swap_state.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 3ecea98ecb45..42cd38eba79f 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -109,8 +109,6 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp_mask)
109 */ 109 */
110void __delete_from_swap_cache(struct page *page) 110void __delete_from_swap_cache(struct page *page)
111{ 111{
112 swp_entry_t ent = {.val = page_private(page)};
113
114 VM_BUG_ON(!PageLocked(page)); 112 VM_BUG_ON(!PageLocked(page));
115 VM_BUG_ON(!PageSwapCache(page)); 113 VM_BUG_ON(!PageSwapCache(page));
116 VM_BUG_ON(PageWriteback(page)); 114 VM_BUG_ON(PageWriteback(page));
@@ -121,13 +119,11 @@ void __delete_from_swap_cache(struct page *page)
121 total_swapcache_pages--; 119 total_swapcache_pages--;
122 __dec_zone_page_state(page, NR_FILE_PAGES); 120 __dec_zone_page_state(page, NR_FILE_PAGES);
123 INC_CACHE_INFO(del_total); 121 INC_CACHE_INFO(del_total);
124 mem_cgroup_uncharge_swapcache(page, ent);
125} 122}
126 123
127/** 124/**
128 * add_to_swap - allocate swap space for a page 125 * add_to_swap - allocate swap space for a page
129 * @page: page we want to move to swap 126 * @page: page we want to move to swap
130 * @gfp_mask: memory allocation flags
131 * 127 *
132 * Allocate swap space for the page and add the page to the 128 * Allocate swap space for the page and add the page to the
133 * swap cache. Caller needs to hold the page lock. 129 * swap cache. Caller needs to hold the page lock.
@@ -165,11 +161,11 @@ int add_to_swap(struct page *page)
165 return 1; 161 return 1;
166 case -EEXIST: 162 case -EEXIST:
167 /* Raced with "speculative" read_swap_cache_async */ 163 /* Raced with "speculative" read_swap_cache_async */
168 swap_free(entry); 164 swapcache_free(entry, NULL);
169 continue; 165 continue;
170 default: 166 default:
171 /* -ENOMEM radix-tree allocation failure */ 167 /* -ENOMEM radix-tree allocation failure */
172 swap_free(entry); 168 swapcache_free(entry, NULL);
173 return 0; 169 return 0;
174 } 170 }
175 } 171 }
@@ -191,7 +187,7 @@ void delete_from_swap_cache(struct page *page)
191 __delete_from_swap_cache(page); 187 __delete_from_swap_cache(page);
192 spin_unlock_irq(&swapper_space.tree_lock); 188 spin_unlock_irq(&swapper_space.tree_lock);
193 189
194 swap_free(entry); 190 swapcache_free(entry, page);
195 page_cache_release(page); 191 page_cache_release(page);
196} 192}
197 193
@@ -295,7 +291,10 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
295 /* 291 /*
296 * Swap entry may have been freed since our caller observed it. 292 * Swap entry may have been freed since our caller observed it.
297 */ 293 */
298 if (!swap_duplicate(entry)) 294 err = swapcache_prepare(entry);
295 if (err == -EEXIST) /* seems racy */
296 continue;
297 if (err) /* swp entry is obsolete ? */
299 break; 298 break;
300 299
301 /* 300 /*
@@ -314,12 +313,12 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
314 * Initiate read into locked page and return. 313 * Initiate read into locked page and return.
315 */ 314 */
316 lru_cache_add_anon(new_page); 315 lru_cache_add_anon(new_page);
317 swap_readpage(NULL, new_page); 316 swap_readpage(new_page);
318 return new_page; 317 return new_page;
319 } 318 }
320 ClearPageSwapBacked(new_page); 319 ClearPageSwapBacked(new_page);
321 __clear_page_locked(new_page); 320 __clear_page_locked(new_page);
322 swap_free(entry); 321 swapcache_free(entry, NULL);
323 } while (err != -ENOMEM); 322 } while (err != -ENOMEM);
324 323
325 if (new_page) 324 if (new_page)