]> bbs.cooldavid.org Git - net-next-2.6.git/blame - mm/rmap.c
ksm: fix mlockfreed to munlocked
[net-next-2.6.git] / mm / rmap.c
CommitLineData
1da177e4
LT
1/*
2 * mm/rmap.c - physical to virtual reverse mappings
3 *
4 * Copyright 2001, Rik van Riel <riel@conectiva.com.br>
5 * Released under the General Public License (GPL).
6 *
7 * Simple, low overhead reverse mapping scheme.
8 * Please try to keep this thing as modular as possible.
9 *
10 * Provides methods for unmapping each kind of mapped page:
11 * the anon methods track anonymous pages, and
12 * the file methods track pages belonging to an inode.
13 *
14 * Original design by Rik van Riel <riel@conectiva.com.br> 2001
15 * File methods by Dave McCracken <dmccr@us.ibm.com> 2003, 2004
16 * Anonymous methods by Andrea Arcangeli <andrea@suse.de> 2004
98f32602 17 * Contributions by Hugh Dickins 2003, 2004
1da177e4
LT
18 */
19
20/*
21 * Lock ordering in mm:
22 *
1b1dcc1b 23 * inode->i_mutex (while writing or truncating, not reading or faulting)
82591e6e
NP
24 * inode->i_alloc_sem (vmtruncate_range)
25 * mm->mmap_sem
26 * page->flags PG_locked (lock_page)
27 * mapping->i_mmap_lock
28 * anon_vma->lock
29 * mm->page_table_lock or pte_lock
30 * zone->lru_lock (in mark_page_accessed, isolate_lru_page)
31 * swap_lock (in swap_duplicate, swap_info_get)
32 * mmlist_lock (in mmput, drain_mmlist and others)
33 * mapping->private_lock (in __set_page_dirty_buffers)
34 * inode_lock (in set_page_dirty's __mark_inode_dirty)
35 * sb_lock (within inode_lock in fs/fs-writeback.c)
36 * mapping->tree_lock (widely used, in set_page_dirty,
37 * in arch-dependent flush_dcache_mmap_lock,
38 * within inode_lock in __sync_single_inode)
6a46079c
AK
39 *
40 * (code doesn't rely on that order so it could be switched around)
41 * ->tasklist_lock
42 * anon_vma->lock (memory_failure, collect_procs_anon)
43 * pte map lock
1da177e4
LT
44 */
45
46#include <linux/mm.h>
47#include <linux/pagemap.h>
48#include <linux/swap.h>
49#include <linux/swapops.h>
50#include <linux/slab.h>
51#include <linux/init.h>
52#include <linux/rmap.h>
53#include <linux/rcupdate.h>
a48d07af 54#include <linux/module.h>
8a9f3ccd 55#include <linux/memcontrol.h>
cddb8a5c 56#include <linux/mmu_notifier.h>
64cdd548 57#include <linux/migrate.h>
1da177e4
LT
58
59#include <asm/tlbflush.h>
60
b291f000
NP
61#include "internal.h"
62
fdd2e5f8
AB
63static struct kmem_cache *anon_vma_cachep;
64
65static inline struct anon_vma *anon_vma_alloc(void)
66{
67 return kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
68}
69
70static inline void anon_vma_free(struct anon_vma *anon_vma)
71{
72 kmem_cache_free(anon_vma_cachep, anon_vma);
73}
1da177e4 74
d9d332e0
LT
75/**
76 * anon_vma_prepare - attach an anon_vma to a memory region
77 * @vma: the memory region in question
78 *
79 * This makes sure the memory mapping described by 'vma' has
80 * an 'anon_vma' attached to it, so that we can associate the
81 * anonymous pages mapped into it with that anon_vma.
82 *
83 * The common case will be that we already have one, but if
84 * if not we either need to find an adjacent mapping that we
85 * can re-use the anon_vma from (very common when the only
86 * reason for splitting a vma has been mprotect()), or we
87 * allocate a new one.
88 *
89 * Anon-vma allocations are very subtle, because we may have
90 * optimistically looked up an anon_vma in page_lock_anon_vma()
91 * and that may actually touch the spinlock even in the newly
92 * allocated vma (it depends on RCU to make sure that the
93 * anon_vma isn't actually destroyed).
94 *
95 * As a result, we need to do proper anon_vma locking even
96 * for the new allocation. At the same time, we do not want
97 * to do any locking for the common case of already having
98 * an anon_vma.
99 *
100 * This must be called with the mmap_sem held for reading.
101 */
1da177e4
LT
102int anon_vma_prepare(struct vm_area_struct *vma)
103{
104 struct anon_vma *anon_vma = vma->anon_vma;
105
106 might_sleep();
107 if (unlikely(!anon_vma)) {
108 struct mm_struct *mm = vma->vm_mm;
d9d332e0 109 struct anon_vma *allocated;
1da177e4
LT
110
111 anon_vma = find_mergeable_anon_vma(vma);
d9d332e0
LT
112 allocated = NULL;
113 if (!anon_vma) {
1da177e4
LT
114 anon_vma = anon_vma_alloc();
115 if (unlikely(!anon_vma))
116 return -ENOMEM;
117 allocated = anon_vma;
1da177e4 118 }
d9d332e0 119 spin_lock(&anon_vma->lock);
1da177e4
LT
120
121 /* page_table_lock to protect against threads */
122 spin_lock(&mm->page_table_lock);
123 if (likely(!vma->anon_vma)) {
124 vma->anon_vma = anon_vma;
0697212a 125 list_add_tail(&vma->anon_vma_node, &anon_vma->head);
1da177e4
LT
126 allocated = NULL;
127 }
128 spin_unlock(&mm->page_table_lock);
129
d9d332e0 130 spin_unlock(&anon_vma->lock);
1da177e4
LT
131 if (unlikely(allocated))
132 anon_vma_free(allocated);
133 }
134 return 0;
135}
136
137void __anon_vma_merge(struct vm_area_struct *vma, struct vm_area_struct *next)
138{
139 BUG_ON(vma->anon_vma != next->anon_vma);
140 list_del(&next->anon_vma_node);
141}
142
143void __anon_vma_link(struct vm_area_struct *vma)
144{
145 struct anon_vma *anon_vma = vma->anon_vma;
146
30acbaba 147 if (anon_vma)
0697212a 148 list_add_tail(&vma->anon_vma_node, &anon_vma->head);
1da177e4
LT
149}
150
151void anon_vma_link(struct vm_area_struct *vma)
152{
153 struct anon_vma *anon_vma = vma->anon_vma;
154
155 if (anon_vma) {
156 spin_lock(&anon_vma->lock);
0697212a 157 list_add_tail(&vma->anon_vma_node, &anon_vma->head);
1da177e4
LT
158 spin_unlock(&anon_vma->lock);
159 }
160}
161
162void anon_vma_unlink(struct vm_area_struct *vma)
163{
164 struct anon_vma *anon_vma = vma->anon_vma;
165 int empty;
166
167 if (!anon_vma)
168 return;
169
170 spin_lock(&anon_vma->lock);
1da177e4
LT
171 list_del(&vma->anon_vma_node);
172
173 /* We must garbage collect the anon_vma if it's empty */
174 empty = list_empty(&anon_vma->head);
175 spin_unlock(&anon_vma->lock);
176
177 if (empty)
178 anon_vma_free(anon_vma);
179}
180
51cc5068 181static void anon_vma_ctor(void *data)
1da177e4 182{
a35afb83 183 struct anon_vma *anon_vma = data;
1da177e4 184
a35afb83
CL
185 spin_lock_init(&anon_vma->lock);
186 INIT_LIST_HEAD(&anon_vma->head);
1da177e4
LT
187}
188
189void __init anon_vma_init(void)
190{
191 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
20c2df83 192 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
1da177e4
LT
193}
194
195/*
196 * Getting a lock on a stable anon_vma from a page off the LRU is
197 * tricky: page_lock_anon_vma rely on RCU to guard against the races.
198 */
10be22df 199struct anon_vma *page_lock_anon_vma(struct page *page)
1da177e4 200{
34bbd704 201 struct anon_vma *anon_vma;
1da177e4
LT
202 unsigned long anon_mapping;
203
204 rcu_read_lock();
205 anon_mapping = (unsigned long) page->mapping;
3ca7b3c5 206 if ((anon_mapping & PAGE_MAPPING_FLAGS) != PAGE_MAPPING_ANON)
1da177e4
LT
207 goto out;
208 if (!page_mapped(page))
209 goto out;
210
211 anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
212 spin_lock(&anon_vma->lock);
34bbd704 213 return anon_vma;
1da177e4
LT
214out:
215 rcu_read_unlock();
34bbd704
ON
216 return NULL;
217}
218
10be22df 219void page_unlock_anon_vma(struct anon_vma *anon_vma)
34bbd704
ON
220{
221 spin_unlock(&anon_vma->lock);
222 rcu_read_unlock();
1da177e4
LT
223}
224
225/*
3ad33b24
LS
226 * At what user virtual address is page expected in @vma?
227 * Returns virtual address or -EFAULT if page's index/offset is not
228 * within the range mapped the @vma.
1da177e4
LT
229 */
230static inline unsigned long
231vma_address(struct page *page, struct vm_area_struct *vma)
232{
233 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
234 unsigned long address;
235
236 address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
237 if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
3ad33b24 238 /* page should be within @vma mapping range */
1da177e4
LT
239 return -EFAULT;
240 }
241 return address;
242}
243
244/*
bf89c8c8
HS
245 * At what user virtual address is page expected in vma?
246 * checking that the page matches the vma.
1da177e4
LT
247 */
248unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
249{
250 if (PageAnon(page)) {
3ca7b3c5 251 if (vma->anon_vma != page_anon_vma(page))
1da177e4
LT
252 return -EFAULT;
253 } else if (page->mapping && !(vma->vm_flags & VM_NONLINEAR)) {
ee498ed7
HD
254 if (!vma->vm_file ||
255 vma->vm_file->f_mapping != page->mapping)
1da177e4
LT
256 return -EFAULT;
257 } else
258 return -EFAULT;
259 return vma_address(page, vma);
260}
261
81b4082d
ND
262/*
263 * Check that @page is mapped at @address into @mm.
264 *
479db0bf
NP
265 * If @sync is false, page_check_address may perform a racy check to avoid
266 * the page table lock when the pte is not present (helpful when reclaiming
267 * highly shared pages).
268 *
b8072f09 269 * On success returns with pte mapped and locked.
81b4082d 270 */
ceffc078 271pte_t *page_check_address(struct page *page, struct mm_struct *mm,
479db0bf 272 unsigned long address, spinlock_t **ptlp, int sync)
81b4082d
ND
273{
274 pgd_t *pgd;
275 pud_t *pud;
276 pmd_t *pmd;
277 pte_t *pte;
c0718806 278 spinlock_t *ptl;
81b4082d 279
81b4082d 280 pgd = pgd_offset(mm, address);
c0718806
HD
281 if (!pgd_present(*pgd))
282 return NULL;
283
284 pud = pud_offset(pgd, address);
285 if (!pud_present(*pud))
286 return NULL;
287
288 pmd = pmd_offset(pud, address);
289 if (!pmd_present(*pmd))
290 return NULL;
291
292 pte = pte_offset_map(pmd, address);
293 /* Make a quick check before getting the lock */
479db0bf 294 if (!sync && !pte_present(*pte)) {
c0718806
HD
295 pte_unmap(pte);
296 return NULL;
297 }
298
4c21e2f2 299 ptl = pte_lockptr(mm, pmd);
c0718806
HD
300 spin_lock(ptl);
301 if (pte_present(*pte) && page_to_pfn(page) == pte_pfn(*pte)) {
302 *ptlp = ptl;
303 return pte;
81b4082d 304 }
c0718806
HD
305 pte_unmap_unlock(pte, ptl);
306 return NULL;
81b4082d
ND
307}
308
b291f000
NP
309/**
310 * page_mapped_in_vma - check whether a page is really mapped in a VMA
311 * @page: the page to test
312 * @vma: the VMA to test
313 *
314 * Returns 1 if the page is mapped into the page tables of the VMA, 0
315 * if the page is not mapped into the page tables of this VMA. Only
316 * valid for normal file or anonymous VMAs.
317 */
6a46079c 318int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma)
b291f000
NP
319{
320 unsigned long address;
321 pte_t *pte;
322 spinlock_t *ptl;
323
324 address = vma_address(page, vma);
325 if (address == -EFAULT) /* out of vma range */
326 return 0;
327 pte = page_check_address(page, vma->vm_mm, address, &ptl, 1);
328 if (!pte) /* the page is not in this mm */
329 return 0;
330 pte_unmap_unlock(pte, ptl);
331
332 return 1;
333}
334
1da177e4
LT
335/*
336 * Subfunctions of page_referenced: page_referenced_one called
337 * repeatedly from either page_referenced_anon or page_referenced_file.
338 */
1cb1729b
HD
339static int page_referenced_one(struct page *page, struct vm_area_struct *vma,
340 unsigned long address, unsigned int *mapcount,
6fe6b7e3 341 unsigned long *vm_flags)
1da177e4
LT
342{
343 struct mm_struct *mm = vma->vm_mm;
1da177e4 344 pte_t *pte;
c0718806 345 spinlock_t *ptl;
1da177e4
LT
346 int referenced = 0;
347
479db0bf 348 pte = page_check_address(page, mm, address, &ptl, 0);
c0718806
HD
349 if (!pte)
350 goto out;
1da177e4 351
b291f000
NP
352 /*
353 * Don't want to elevate referenced for mlocked page that gets this far,
354 * in order that it progresses to try_to_unmap and is moved to the
355 * unevictable list.
356 */
5a9bbdcd 357 if (vma->vm_flags & VM_LOCKED) {
5a9bbdcd 358 *mapcount = 1; /* break early from loop */
03ef83af 359 *vm_flags |= VM_LOCKED;
b291f000
NP
360 goto out_unmap;
361 }
362
4917e5d0
JW
363 if (ptep_clear_flush_young_notify(vma, address, pte)) {
364 /*
365 * Don't treat a reference through a sequentially read
366 * mapping as such. If the page has been used in
367 * another mapping, we will catch it; if this other
368 * mapping is already gone, the unmap path will have
369 * set PG_referenced or activated the page.
370 */
371 if (likely(!VM_SequentialReadHint(vma)))
372 referenced++;
373 }
1da177e4 374
c0718806
HD
375 /* Pretend the page is referenced if the task has the
376 swap token and is in the middle of a page fault. */
f7b7fd8f 377 if (mm != current->mm && has_swap_token(mm) &&
c0718806
HD
378 rwsem_is_locked(&mm->mmap_sem))
379 referenced++;
380
b291f000 381out_unmap:
c0718806
HD
382 (*mapcount)--;
383 pte_unmap_unlock(pte, ptl);
273f047e 384
6fe6b7e3
WF
385 if (referenced)
386 *vm_flags |= vma->vm_flags;
273f047e 387out:
1da177e4
LT
388 return referenced;
389}
390
bed7161a 391static int page_referenced_anon(struct page *page,
6fe6b7e3
WF
392 struct mem_cgroup *mem_cont,
393 unsigned long *vm_flags)
1da177e4
LT
394{
395 unsigned int mapcount;
396 struct anon_vma *anon_vma;
397 struct vm_area_struct *vma;
398 int referenced = 0;
399
400 anon_vma = page_lock_anon_vma(page);
401 if (!anon_vma)
402 return referenced;
403
404 mapcount = page_mapcount(page);
405 list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
1cb1729b
HD
406 unsigned long address = vma_address(page, vma);
407 if (address == -EFAULT)
408 continue;
bed7161a
BS
409 /*
410 * If we are reclaiming on behalf of a cgroup, skip
411 * counting on behalf of references from different
412 * cgroups
413 */
bd845e38 414 if (mem_cont && !mm_match_cgroup(vma->vm_mm, mem_cont))
bed7161a 415 continue;
1cb1729b 416 referenced += page_referenced_one(page, vma, address,
6fe6b7e3 417 &mapcount, vm_flags);
1da177e4
LT
418 if (!mapcount)
419 break;
420 }
34bbd704
ON
421
422 page_unlock_anon_vma(anon_vma);
1da177e4
LT
423 return referenced;
424}
425
426/**
427 * page_referenced_file - referenced check for object-based rmap
428 * @page: the page we're checking references on.
43d8eac4 429 * @mem_cont: target memory controller
6fe6b7e3 430 * @vm_flags: collect encountered vma->vm_flags who actually referenced the page
1da177e4
LT
431 *
432 * For an object-based mapped page, find all the places it is mapped and
433 * check/clear the referenced flag. This is done by following the page->mapping
434 * pointer, then walking the chain of vmas it holds. It returns the number
435 * of references it found.
436 *
437 * This function is only called from page_referenced for object-based pages.
438 */
bed7161a 439static int page_referenced_file(struct page *page,
6fe6b7e3
WF
440 struct mem_cgroup *mem_cont,
441 unsigned long *vm_flags)
1da177e4
LT
442{
443 unsigned int mapcount;
444 struct address_space *mapping = page->mapping;
445 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
446 struct vm_area_struct *vma;
447 struct prio_tree_iter iter;
448 int referenced = 0;
449
450 /*
451 * The caller's checks on page->mapping and !PageAnon have made
452 * sure that this is a file page: the check for page->mapping
453 * excludes the case just before it gets set on an anon page.
454 */
455 BUG_ON(PageAnon(page));
456
457 /*
458 * The page lock not only makes sure that page->mapping cannot
459 * suddenly be NULLified by truncation, it makes sure that the
460 * structure at mapping cannot be freed and reused yet,
461 * so we can safely take mapping->i_mmap_lock.
462 */
463 BUG_ON(!PageLocked(page));
464
465 spin_lock(&mapping->i_mmap_lock);
466
467 /*
468 * i_mmap_lock does not stabilize mapcount at all, but mapcount
469 * is more likely to be accurate if we note it after spinning.
470 */
471 mapcount = page_mapcount(page);
472
473 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
1cb1729b
HD
474 unsigned long address = vma_address(page, vma);
475 if (address == -EFAULT)
476 continue;
bed7161a
BS
477 /*
478 * If we are reclaiming on behalf of a cgroup, skip
479 * counting on behalf of references from different
480 * cgroups
481 */
bd845e38 482 if (mem_cont && !mm_match_cgroup(vma->vm_mm, mem_cont))
bed7161a 483 continue;
1cb1729b 484 referenced += page_referenced_one(page, vma, address,
6fe6b7e3 485 &mapcount, vm_flags);
1da177e4
LT
486 if (!mapcount)
487 break;
488 }
489
490 spin_unlock(&mapping->i_mmap_lock);
491 return referenced;
492}
493
494/**
495 * page_referenced - test if the page was referenced
496 * @page: the page to test
497 * @is_locked: caller holds lock on the page
43d8eac4 498 * @mem_cont: target memory controller
6fe6b7e3 499 * @vm_flags: collect encountered vma->vm_flags who actually referenced the page
1da177e4
LT
500 *
501 * Quick test_and_clear_referenced for all mappings to a page,
502 * returns the number of ptes which referenced the page.
503 */
6fe6b7e3
WF
504int page_referenced(struct page *page,
505 int is_locked,
506 struct mem_cgroup *mem_cont,
507 unsigned long *vm_flags)
1da177e4
LT
508{
509 int referenced = 0;
510
1da177e4
LT
511 if (TestClearPageReferenced(page))
512 referenced++;
513
6fe6b7e3 514 *vm_flags = 0;
3ca7b3c5 515 if (page_mapped(page) && page_rmapping(page)) {
1da177e4 516 if (PageAnon(page))
6fe6b7e3
WF
517 referenced += page_referenced_anon(page, mem_cont,
518 vm_flags);
1da177e4 519 else if (is_locked)
6fe6b7e3
WF
520 referenced += page_referenced_file(page, mem_cont,
521 vm_flags);
529ae9aa 522 else if (!trylock_page(page))
1da177e4
LT
523 referenced++;
524 else {
525 if (page->mapping)
6fe6b7e3
WF
526 referenced += page_referenced_file(page,
527 mem_cont, vm_flags);
1da177e4
LT
528 unlock_page(page);
529 }
530 }
5b7baf05
CB
531
532 if (page_test_and_clear_young(page))
533 referenced++;
534
1da177e4
LT
535 return referenced;
536}
537
1cb1729b
HD
538static int page_mkclean_one(struct page *page, struct vm_area_struct *vma,
539 unsigned long address)
d08b3851
PZ
540{
541 struct mm_struct *mm = vma->vm_mm;
c2fda5fe 542 pte_t *pte;
d08b3851
PZ
543 spinlock_t *ptl;
544 int ret = 0;
545
479db0bf 546 pte = page_check_address(page, mm, address, &ptl, 1);
d08b3851
PZ
547 if (!pte)
548 goto out;
549
c2fda5fe
PZ
550 if (pte_dirty(*pte) || pte_write(*pte)) {
551 pte_t entry;
d08b3851 552
c2fda5fe 553 flush_cache_page(vma, address, pte_pfn(*pte));
cddb8a5c 554 entry = ptep_clear_flush_notify(vma, address, pte);
c2fda5fe
PZ
555 entry = pte_wrprotect(entry);
556 entry = pte_mkclean(entry);
d6e88e67 557 set_pte_at(mm, address, pte, entry);
c2fda5fe
PZ
558 ret = 1;
559 }
d08b3851 560
d08b3851
PZ
561 pte_unmap_unlock(pte, ptl);
562out:
563 return ret;
564}
565
566static int page_mkclean_file(struct address_space *mapping, struct page *page)
567{
568 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
569 struct vm_area_struct *vma;
570 struct prio_tree_iter iter;
571 int ret = 0;
572
573 BUG_ON(PageAnon(page));
574
575 spin_lock(&mapping->i_mmap_lock);
576 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
1cb1729b
HD
577 if (vma->vm_flags & VM_SHARED) {
578 unsigned long address = vma_address(page, vma);
579 if (address == -EFAULT)
580 continue;
581 ret += page_mkclean_one(page, vma, address);
582 }
d08b3851
PZ
583 }
584 spin_unlock(&mapping->i_mmap_lock);
585 return ret;
586}
587
588int page_mkclean(struct page *page)
589{
590 int ret = 0;
591
592 BUG_ON(!PageLocked(page));
593
594 if (page_mapped(page)) {
595 struct address_space *mapping = page_mapping(page);
ce7e9fae 596 if (mapping) {
d08b3851 597 ret = page_mkclean_file(mapping, page);
ce7e9fae
CB
598 if (page_test_dirty(page)) {
599 page_clear_dirty(page);
600 ret = 1;
601 }
6c210482 602 }
d08b3851
PZ
603 }
604
605 return ret;
606}
60b59bea 607EXPORT_SYMBOL_GPL(page_mkclean);
d08b3851 608
9617d95e 609/**
43d8eac4 610 * __page_set_anon_rmap - setup new anonymous rmap
9617d95e
NP
611 * @page: the page to add the mapping to
612 * @vma: the vm area in which the mapping is added
613 * @address: the user virtual address mapped
614 */
615static void __page_set_anon_rmap(struct page *page,
616 struct vm_area_struct *vma, unsigned long address)
617{
618 struct anon_vma *anon_vma = vma->anon_vma;
619
620 BUG_ON(!anon_vma);
621 anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
622 page->mapping = (struct address_space *) anon_vma;
623
624 page->index = linear_page_index(vma, address);
625
a74609fa
NP
626 /*
627 * nr_mapped state can be updated without turning off
628 * interrupts because it is not modified via interrupt.
629 */
f3dbd344 630 __inc_zone_page_state(page, NR_ANON_PAGES);
9617d95e
NP
631}
632
c97a9e10 633/**
43d8eac4 634 * __page_check_anon_rmap - sanity check anonymous rmap addition
c97a9e10
NP
635 * @page: the page to add the mapping to
636 * @vma: the vm area in which the mapping is added
637 * @address: the user virtual address mapped
638 */
639static void __page_check_anon_rmap(struct page *page,
640 struct vm_area_struct *vma, unsigned long address)
641{
642#ifdef CONFIG_DEBUG_VM
643 /*
644 * The page's anon-rmap details (mapping and index) are guaranteed to
645 * be set up correctly at this point.
646 *
647 * We have exclusion against page_add_anon_rmap because the caller
648 * always holds the page locked, except if called from page_dup_rmap,
649 * in which case the page is already known to be setup.
650 *
651 * We have exclusion against page_add_new_anon_rmap because those pages
652 * are initially only visible via the pagetables, and the pte is locked
653 * over the call to page_add_new_anon_rmap.
654 */
655 struct anon_vma *anon_vma = vma->anon_vma;
656 anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
657 BUG_ON(page->mapping != (struct address_space *)anon_vma);
658 BUG_ON(page->index != linear_page_index(vma, address));
659#endif
660}
661
1da177e4
LT
662/**
663 * page_add_anon_rmap - add pte mapping to an anonymous page
664 * @page: the page to add the mapping to
665 * @vma: the vm area in which the mapping is added
666 * @address: the user virtual address mapped
667 *
c97a9e10 668 * The caller needs to hold the pte lock and the page must be locked.
1da177e4
LT
669 */
670void page_add_anon_rmap(struct page *page,
671 struct vm_area_struct *vma, unsigned long address)
672{
c97a9e10
NP
673 VM_BUG_ON(!PageLocked(page));
674 VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
9617d95e
NP
675 if (atomic_inc_and_test(&page->_mapcount))
676 __page_set_anon_rmap(page, vma, address);
69029cd5 677 else
c97a9e10 678 __page_check_anon_rmap(page, vma, address);
1da177e4
LT
679}
680
43d8eac4 681/**
9617d95e
NP
682 * page_add_new_anon_rmap - add pte mapping to a new anonymous page
683 * @page: the page to add the mapping to
684 * @vma: the vm area in which the mapping is added
685 * @address: the user virtual address mapped
686 *
687 * Same as page_add_anon_rmap but must only be called on *new* pages.
688 * This means the inc-and-test can be bypassed.
c97a9e10 689 * Page does not have to be locked.
9617d95e
NP
690 */
691void page_add_new_anon_rmap(struct page *page,
692 struct vm_area_struct *vma, unsigned long address)
693{
b5934c53 694 VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
cbf84b7a
HD
695 SetPageSwapBacked(page);
696 atomic_set(&page->_mapcount, 0); /* increment count (starts at -1) */
9617d95e 697 __page_set_anon_rmap(page, vma, address);
b5934c53 698 if (page_evictable(page, vma))
cbf84b7a 699 lru_cache_add_lru(page, LRU_ACTIVE_ANON);
b5934c53
HD
700 else
701 add_page_to_unevictable_list(page);
9617d95e
NP
702}
703
1da177e4
LT
704/**
705 * page_add_file_rmap - add pte mapping to a file page
706 * @page: the page to add the mapping to
707 *
b8072f09 708 * The caller needs to hold the pte lock.
1da177e4
LT
709 */
710void page_add_file_rmap(struct page *page)
711{
d69b042f 712 if (atomic_inc_and_test(&page->_mapcount)) {
65ba55f5 713 __inc_zone_page_state(page, NR_FILE_MAPPED);
d69b042f
BS
714 mem_cgroup_update_mapped_file_stat(page, 1);
715 }
1da177e4
LT
716}
717
718/**
719 * page_remove_rmap - take down pte mapping from a page
720 * @page: page to remove mapping from
721 *
b8072f09 722 * The caller needs to hold the pte lock.
1da177e4 723 */
edc315fd 724void page_remove_rmap(struct page *page)
1da177e4 725{
b904dcfe
KM
726 /* page still mapped by someone else? */
727 if (!atomic_add_negative(-1, &page->_mapcount))
728 return;
729
730 /*
731 * Now that the last pte has gone, s390 must transfer dirty
732 * flag from storage key to struct page. We can usually skip
733 * this if the page is anon, so about to be freed; but perhaps
734 * not if it's in swapcache - there might be another pte slot
735 * containing the swap entry, but page not yet written to swap.
736 */
737 if ((!PageAnon(page) || PageSwapCache(page)) && page_test_dirty(page)) {
738 page_clear_dirty(page);
739 set_page_dirty(page);
1da177e4 740 }
b904dcfe
KM
741 if (PageAnon(page)) {
742 mem_cgroup_uncharge_page(page);
743 __dec_zone_page_state(page, NR_ANON_PAGES);
744 } else {
745 __dec_zone_page_state(page, NR_FILE_MAPPED);
746 }
747 mem_cgroup_update_mapped_file_stat(page, -1);
748 /*
749 * It would be tidy to reset the PageAnon mapping here,
750 * but that might overwrite a racing page_add_anon_rmap
751 * which increments mapcount after us but sets mapping
752 * before us: so leave the reset to free_hot_cold_page,
753 * and remember that it's only reliable while mapped.
754 * Leaving it set also helps swapoff to reinstate ptes
755 * faster for those pages still in swapcache.
756 */
1da177e4
LT
757}
758
759/*
760 * Subfunctions of try_to_unmap: try_to_unmap_one called
761 * repeatedly from either try_to_unmap_anon or try_to_unmap_file.
762 */
a48d07af 763static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1cb1729b 764 unsigned long address, enum ttu_flags flags)
1da177e4
LT
765{
766 struct mm_struct *mm = vma->vm_mm;
1da177e4
LT
767 pte_t *pte;
768 pte_t pteval;
c0718806 769 spinlock_t *ptl;
1da177e4
LT
770 int ret = SWAP_AGAIN;
771
479db0bf 772 pte = page_check_address(page, mm, address, &ptl, 0);
c0718806 773 if (!pte)
81b4082d 774 goto out;
1da177e4
LT
775
776 /*
777 * If the page is mlock()d, we cannot swap it out.
778 * If it's recently referenced (perhaps page_referenced
779 * skipped over this mm) then we should reactivate it.
780 */
14fa31b8 781 if (!(flags & TTU_IGNORE_MLOCK)) {
b291f000
NP
782 if (vma->vm_flags & VM_LOCKED) {
783 ret = SWAP_MLOCK;
784 goto out_unmap;
785 }
af8e3354 786 if (TTU_ACTION(flags) == TTU_MUNLOCK)
53f79acb 787 goto out_unmap;
14fa31b8
AK
788 }
789 if (!(flags & TTU_IGNORE_ACCESS)) {
b291f000
NP
790 if (ptep_clear_flush_young_notify(vma, address, pte)) {
791 ret = SWAP_FAIL;
792 goto out_unmap;
793 }
794 }
1da177e4 795
1da177e4
LT
796 /* Nuke the page table entry. */
797 flush_cache_page(vma, address, page_to_pfn(page));
cddb8a5c 798 pteval = ptep_clear_flush_notify(vma, address, pte);
1da177e4
LT
799
800 /* Move the dirty bit to the physical page now the pte is gone. */
801 if (pte_dirty(pteval))
802 set_page_dirty(page);
803
365e9c87
HD
804 /* Update high watermark before we lower rss */
805 update_hiwater_rss(mm);
806
888b9f7c
AK
807 if (PageHWPoison(page) && !(flags & TTU_IGNORE_HWPOISON)) {
808 if (PageAnon(page))
809 dec_mm_counter(mm, anon_rss);
810 else
811 dec_mm_counter(mm, file_rss);
812 set_pte_at(mm, address, pte,
813 swp_entry_to_pte(make_hwpoison_entry(page)));
814 } else if (PageAnon(page)) {
4c21e2f2 815 swp_entry_t entry = { .val = page_private(page) };
0697212a
CL
816
817 if (PageSwapCache(page)) {
818 /*
819 * Store the swap location in the pte.
820 * See handle_pte_fault() ...
821 */
570a335b
HD
822 if (swap_duplicate(entry) < 0) {
823 set_pte_at(mm, address, pte, pteval);
824 ret = SWAP_FAIL;
825 goto out_unmap;
826 }
0697212a
CL
827 if (list_empty(&mm->mmlist)) {
828 spin_lock(&mmlist_lock);
829 if (list_empty(&mm->mmlist))
830 list_add(&mm->mmlist, &init_mm.mmlist);
831 spin_unlock(&mmlist_lock);
832 }
442c9137 833 dec_mm_counter(mm, anon_rss);
64cdd548 834 } else if (PAGE_MIGRATION) {
0697212a
CL
835 /*
836 * Store the pfn of the page in a special migration
837 * pte. do_swap_page() will wait until the migration
838 * pte is removed and then restart fault handling.
839 */
14fa31b8 840 BUG_ON(TTU_ACTION(flags) != TTU_MIGRATION);
0697212a 841 entry = make_migration_entry(page, pte_write(pteval));
1da177e4
LT
842 }
843 set_pte_at(mm, address, pte, swp_entry_to_pte(entry));
844 BUG_ON(pte_file(*pte));
14fa31b8 845 } else if (PAGE_MIGRATION && (TTU_ACTION(flags) == TTU_MIGRATION)) {
04e62a29
CL
846 /* Establish migration entry for a file page */
847 swp_entry_t entry;
848 entry = make_migration_entry(page, pte_write(pteval));
849 set_pte_at(mm, address, pte, swp_entry_to_pte(entry));
850 } else
4294621f 851 dec_mm_counter(mm, file_rss);
1da177e4 852
edc315fd 853 page_remove_rmap(page);
1da177e4
LT
854 page_cache_release(page);
855
856out_unmap:
c0718806 857 pte_unmap_unlock(pte, ptl);
53f79acb 858
af8e3354 859 if (ret == SWAP_MLOCK) {
53f79acb
HD
860 ret = SWAP_AGAIN;
861 if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
862 if (vma->vm_flags & VM_LOCKED) {
863 mlock_vma_page(page);
864 ret = SWAP_MLOCK;
865 }
866 up_read(&vma->vm_mm->mmap_sem);
867 }
868 }
1da177e4
LT
869out:
870 return ret;
871}
872
873/*
874 * objrmap doesn't work for nonlinear VMAs because the assumption that
875 * offset-into-file correlates with offset-into-virtual-addresses does not hold.
876 * Consequently, given a particular page and its ->index, we cannot locate the
877 * ptes which are mapping that page without an exhaustive linear search.
878 *
879 * So what this code does is a mini "virtual scan" of each nonlinear VMA which
880 * maps the file to which the target page belongs. The ->vm_private_data field
881 * holds the current cursor into that scan. Successive searches will circulate
882 * around the vma's virtual address space.
883 *
884 * So as more replacement pressure is applied to the pages in a nonlinear VMA,
885 * more scanning pressure is placed against them as well. Eventually pages
886 * will become fully unmapped and are eligible for eviction.
887 *
888 * For very sparsely populated VMAs this is a little inefficient - chances are
889 * there there won't be many ptes located within the scan cluster. In this case
890 * maybe we could scan further - to the end of the pte page, perhaps.
b291f000
NP
891 *
892 * Mlocked pages: check VM_LOCKED under mmap_sem held for read, if we can
893 * acquire it without blocking. If vma locked, mlock the pages in the cluster,
894 * rather than unmapping them. If we encounter the "check_page" that vmscan is
895 * trying to unmap, return SWAP_MLOCK, else default SWAP_AGAIN.
1da177e4
LT
896 */
897#define CLUSTER_SIZE min(32*PAGE_SIZE, PMD_SIZE)
898#define CLUSTER_MASK (~(CLUSTER_SIZE - 1))
899
b291f000
NP
900static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
901 struct vm_area_struct *vma, struct page *check_page)
1da177e4
LT
902{
903 struct mm_struct *mm = vma->vm_mm;
904 pgd_t *pgd;
905 pud_t *pud;
906 pmd_t *pmd;
c0718806 907 pte_t *pte;
1da177e4 908 pte_t pteval;
c0718806 909 spinlock_t *ptl;
1da177e4
LT
910 struct page *page;
911 unsigned long address;
912 unsigned long end;
b291f000
NP
913 int ret = SWAP_AGAIN;
914 int locked_vma = 0;
1da177e4 915
1da177e4
LT
916 address = (vma->vm_start + cursor) & CLUSTER_MASK;
917 end = address + CLUSTER_SIZE;
918 if (address < vma->vm_start)
919 address = vma->vm_start;
920 if (end > vma->vm_end)
921 end = vma->vm_end;
922
923 pgd = pgd_offset(mm, address);
924 if (!pgd_present(*pgd))
b291f000 925 return ret;
1da177e4
LT
926
927 pud = pud_offset(pgd, address);
928 if (!pud_present(*pud))
b291f000 929 return ret;
1da177e4
LT
930
931 pmd = pmd_offset(pud, address);
932 if (!pmd_present(*pmd))
b291f000
NP
933 return ret;
934
935 /*
af8e3354 936 * If we can acquire the mmap_sem for read, and vma is VM_LOCKED,
b291f000
NP
937 * keep the sem while scanning the cluster for mlocking pages.
938 */
af8e3354 939 if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
b291f000
NP
940 locked_vma = (vma->vm_flags & VM_LOCKED);
941 if (!locked_vma)
942 up_read(&vma->vm_mm->mmap_sem); /* don't need it */
943 }
c0718806
HD
944
945 pte = pte_offset_map_lock(mm, pmd, address, &ptl);
1da177e4 946
365e9c87
HD
947 /* Update high watermark before we lower rss */
948 update_hiwater_rss(mm);
949
c0718806 950 for (; address < end; pte++, address += PAGE_SIZE) {
1da177e4
LT
951 if (!pte_present(*pte))
952 continue;
6aab341e
LT
953 page = vm_normal_page(vma, address, *pte);
954 BUG_ON(!page || PageAnon(page));
1da177e4 955
b291f000
NP
956 if (locked_vma) {
957 mlock_vma_page(page); /* no-op if already mlocked */
958 if (page == check_page)
959 ret = SWAP_MLOCK;
960 continue; /* don't unmap */
961 }
962
cddb8a5c 963 if (ptep_clear_flush_young_notify(vma, address, pte))
1da177e4
LT
964 continue;
965
966 /* Nuke the page table entry. */
eca35133 967 flush_cache_page(vma, address, pte_pfn(*pte));
cddb8a5c 968 pteval = ptep_clear_flush_notify(vma, address, pte);
1da177e4
LT
969
970 /* If nonlinear, store the file page offset in the pte. */
971 if (page->index != linear_page_index(vma, address))
972 set_pte_at(mm, address, pte, pgoff_to_pte(page->index));
973
974 /* Move the dirty bit to the physical page now the pte is gone. */
975 if (pte_dirty(pteval))
976 set_page_dirty(page);
977
edc315fd 978 page_remove_rmap(page);
1da177e4 979 page_cache_release(page);
4294621f 980 dec_mm_counter(mm, file_rss);
1da177e4
LT
981 (*mapcount)--;
982 }
c0718806 983 pte_unmap_unlock(pte - 1, ptl);
b291f000
NP
984 if (locked_vma)
985 up_read(&vma->vm_mm->mmap_sem);
986 return ret;
1da177e4
LT
987}
988
b291f000
NP
989/**
990 * try_to_unmap_anon - unmap or unlock anonymous page using the object-based
991 * rmap method
992 * @page: the page to unmap/unlock
8051be5e 993 * @flags: action and flags
b291f000
NP
994 *
995 * Find all the mappings of a page using the mapping pointer and the vma chains
996 * contained in the anon_vma struct it points to.
997 *
998 * This function is only called from try_to_unmap/try_to_munlock for
999 * anonymous pages.
1000 * When called from try_to_munlock(), the mmap_sem of the mm containing the vma
1001 * where the page was found will be held for write. So, we won't recheck
1002 * vm_flags for that VMA. That should be OK, because that vma shouldn't be
1003 * 'LOCKED.
1004 */
14fa31b8 1005static int try_to_unmap_anon(struct page *page, enum ttu_flags flags)
1da177e4
LT
1006{
1007 struct anon_vma *anon_vma;
1008 struct vm_area_struct *vma;
1009 int ret = SWAP_AGAIN;
b291f000 1010
1da177e4
LT
1011 anon_vma = page_lock_anon_vma(page);
1012 if (!anon_vma)
1013 return ret;
1014
1015 list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
1cb1729b
HD
1016 unsigned long address = vma_address(page, vma);
1017 if (address == -EFAULT)
1018 continue;
1019 ret = try_to_unmap_one(page, vma, address, flags);
53f79acb
HD
1020 if (ret != SWAP_AGAIN || !page_mapped(page))
1021 break;
1da177e4 1022 }
34bbd704
ON
1023
1024 page_unlock_anon_vma(anon_vma);
1da177e4
LT
1025 return ret;
1026}
1027
1028/**
b291f000
NP
1029 * try_to_unmap_file - unmap/unlock file page using the object-based rmap method
1030 * @page: the page to unmap/unlock
14fa31b8 1031 * @flags: action and flags
1da177e4
LT
1032 *
1033 * Find all the mappings of a page using the mapping pointer and the vma chains
1034 * contained in the address_space struct it points to.
1035 *
b291f000
NP
1036 * This function is only called from try_to_unmap/try_to_munlock for
1037 * object-based pages.
1038 * When called from try_to_munlock(), the mmap_sem of the mm containing the vma
1039 * where the page was found will be held for write. So, we won't recheck
1040 * vm_flags for that VMA. That should be OK, because that vma shouldn't be
1041 * 'LOCKED.
1da177e4 1042 */
14fa31b8 1043static int try_to_unmap_file(struct page *page, enum ttu_flags flags)
1da177e4
LT
1044{
1045 struct address_space *mapping = page->mapping;
1046 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
1047 struct vm_area_struct *vma;
1048 struct prio_tree_iter iter;
1049 int ret = SWAP_AGAIN;
1050 unsigned long cursor;
1051 unsigned long max_nl_cursor = 0;
1052 unsigned long max_nl_size = 0;
1053 unsigned int mapcount;
1054
1055 spin_lock(&mapping->i_mmap_lock);
1056 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
1cb1729b
HD
1057 unsigned long address = vma_address(page, vma);
1058 if (address == -EFAULT)
1059 continue;
1060 ret = try_to_unmap_one(page, vma, address, flags);
53f79acb
HD
1061 if (ret != SWAP_AGAIN || !page_mapped(page))
1062 goto out;
1da177e4
LT
1063 }
1064
1065 if (list_empty(&mapping->i_mmap_nonlinear))
1066 goto out;
1067
53f79acb
HD
1068 /*
1069 * We don't bother to try to find the munlocked page in nonlinears.
1070 * It's costly. Instead, later, page reclaim logic may call
1071 * try_to_unmap(TTU_MUNLOCK) and recover PG_mlocked lazily.
1072 */
1073 if (TTU_ACTION(flags) == TTU_MUNLOCK)
1074 goto out;
1075
1da177e4
LT
1076 list_for_each_entry(vma, &mapping->i_mmap_nonlinear,
1077 shared.vm_set.list) {
1da177e4
LT
1078 cursor = (unsigned long) vma->vm_private_data;
1079 if (cursor > max_nl_cursor)
1080 max_nl_cursor = cursor;
1081 cursor = vma->vm_end - vma->vm_start;
1082 if (cursor > max_nl_size)
1083 max_nl_size = cursor;
1084 }
1085
b291f000 1086 if (max_nl_size == 0) { /* all nonlinears locked or reserved ? */
1da177e4
LT
1087 ret = SWAP_FAIL;
1088 goto out;
1089 }
1090
1091 /*
1092 * We don't try to search for this page in the nonlinear vmas,
1093 * and page_referenced wouldn't have found it anyway. Instead
1094 * just walk the nonlinear vmas trying to age and unmap some.
1095 * The mapcount of the page we came in with is irrelevant,
1096 * but even so use it as a guide to how hard we should try?
1097 */
1098 mapcount = page_mapcount(page);
1099 if (!mapcount)
1100 goto out;
1101 cond_resched_lock(&mapping->i_mmap_lock);
1102
1103 max_nl_size = (max_nl_size + CLUSTER_SIZE - 1) & CLUSTER_MASK;
1104 if (max_nl_cursor == 0)
1105 max_nl_cursor = CLUSTER_SIZE;
1106
1107 do {
1108 list_for_each_entry(vma, &mapping->i_mmap_nonlinear,
1109 shared.vm_set.list) {
1da177e4 1110 cursor = (unsigned long) vma->vm_private_data;
839b9685 1111 while ( cursor < max_nl_cursor &&
1da177e4 1112 cursor < vma->vm_end - vma->vm_start) {
53f79acb
HD
1113 if (try_to_unmap_cluster(cursor, &mapcount,
1114 vma, page) == SWAP_MLOCK)
1115 ret = SWAP_MLOCK;
1da177e4
LT
1116 cursor += CLUSTER_SIZE;
1117 vma->vm_private_data = (void *) cursor;
1118 if ((int)mapcount <= 0)
1119 goto out;
1120 }
1121 vma->vm_private_data = (void *) max_nl_cursor;
1122 }
1123 cond_resched_lock(&mapping->i_mmap_lock);
1124 max_nl_cursor += CLUSTER_SIZE;
1125 } while (max_nl_cursor <= max_nl_size);
1126
1127 /*
1128 * Don't loop forever (perhaps all the remaining pages are
1129 * in locked vmas). Reset cursor on all unreserved nonlinear
1130 * vmas, now forgetting on which ones it had fallen behind.
1131 */
101d2be7
HD
1132 list_for_each_entry(vma, &mapping->i_mmap_nonlinear, shared.vm_set.list)
1133 vma->vm_private_data = NULL;
1da177e4
LT
1134out:
1135 spin_unlock(&mapping->i_mmap_lock);
1136 return ret;
1137}
1138
1139/**
1140 * try_to_unmap - try to remove all page table mappings to a page
1141 * @page: the page to get unmapped
14fa31b8 1142 * @flags: action and flags
1da177e4
LT
1143 *
1144 * Tries to remove all the page table entries which are mapping this
1145 * page, used in the pageout path. Caller must hold the page lock.
1146 * Return values are:
1147 *
1148 * SWAP_SUCCESS - we succeeded in removing all mappings
1149 * SWAP_AGAIN - we missed a mapping, try again later
1150 * SWAP_FAIL - the page is unswappable
b291f000 1151 * SWAP_MLOCK - page is mlocked.
1da177e4 1152 */
14fa31b8 1153int try_to_unmap(struct page *page, enum ttu_flags flags)
1da177e4
LT
1154{
1155 int ret;
1156
1da177e4
LT
1157 BUG_ON(!PageLocked(page));
1158
1159 if (PageAnon(page))
14fa31b8 1160 ret = try_to_unmap_anon(page, flags);
1da177e4 1161 else
14fa31b8 1162 ret = try_to_unmap_file(page, flags);
b291f000 1163 if (ret != SWAP_MLOCK && !page_mapped(page))
1da177e4
LT
1164 ret = SWAP_SUCCESS;
1165 return ret;
1166}
81b4082d 1167
b291f000
NP
1168/**
1169 * try_to_munlock - try to munlock a page
1170 * @page: the page to be munlocked
1171 *
1172 * Called from munlock code. Checks all of the VMAs mapping the page
1173 * to make sure nobody else has this page mlocked. The page will be
1174 * returned with PG_mlocked cleared if no other vmas have it mlocked.
1175 *
1176 * Return values are:
1177 *
53f79acb 1178 * SWAP_AGAIN - no vma is holding page mlocked, or,
b291f000
NP
1179 * SWAP_AGAIN - page mapped in mlocked vma -- couldn't acquire mmap sem
1180 * SWAP_MLOCK - page is now mlocked.
1181 */
1182int try_to_munlock(struct page *page)
1183{
1184 VM_BUG_ON(!PageLocked(page) || PageLRU(page));
1185
1186 if (PageAnon(page))
14fa31b8 1187 return try_to_unmap_anon(page, TTU_MUNLOCK);
b291f000 1188 else
14fa31b8 1189 return try_to_unmap_file(page, TTU_MUNLOCK);
b291f000 1190}
68377659 1191