diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/filemap.c | 12 | ||||
-rw-r--r-- | mm/memory.c | 18 | ||||
-rw-r--r-- | mm/migrate.c | 4 | ||||
-rw-r--r-- | mm/mlock.c | 2 | ||||
-rw-r--r-- | mm/mm_init.c | 8 | ||||
-rw-r--r-- | mm/mmap.c | 2 | ||||
-rw-r--r-- | mm/nommu.c | 21 | ||||
-rw-r--r-- | mm/rmap.c | 2 | ||||
-rw-r--r-- | mm/shmem.c | 4 | ||||
-rw-r--r-- | mm/swap.c | 2 | ||||
-rw-r--r-- | mm/swap_state.c | 8 | ||||
-rw-r--r-- | mm/swapfile.c | 2 | ||||
-rw-r--r-- | mm/truncate.c | 4 | ||||
-rw-r--r-- | mm/vmscan.c | 4 |
14 files changed, 61 insertions, 32 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index d97d1ad5547..54e96865085 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -558,14 +558,14 @@ EXPORT_SYMBOL(wait_on_page_bit); | |||
558 | * But that's OK - sleepers in wait_on_page_writeback() just go back to sleep. | 558 | * But that's OK - sleepers in wait_on_page_writeback() just go back to sleep. |
559 | * | 559 | * |
560 | * The first mb is necessary to safely close the critical section opened by the | 560 | * The first mb is necessary to safely close the critical section opened by the |
561 | * TestSetPageLocked(), the second mb is necessary to enforce ordering between | 561 | * test_and_set_bit() to lock the page; the second mb is necessary to enforce |
562 | * the clear_bit and the read of the waitqueue (to avoid SMP races with a | 562 | * ordering between the clear_bit and the read of the waitqueue (to avoid SMP |
563 | * parallel wait_on_page_locked()). | 563 | * races with a parallel wait_on_page_locked()). |
564 | */ | 564 | */ |
565 | void unlock_page(struct page *page) | 565 | void unlock_page(struct page *page) |
566 | { | 566 | { |
567 | smp_mb__before_clear_bit(); | 567 | smp_mb__before_clear_bit(); |
568 | if (!TestClearPageLocked(page)) | 568 | if (!test_and_clear_bit(PG_locked, &page->flags)) |
569 | BUG(); | 569 | BUG(); |
570 | smp_mb__after_clear_bit(); | 570 | smp_mb__after_clear_bit(); |
571 | wake_up_page(page, PG_locked); | 571 | wake_up_page(page, PG_locked); |
@@ -931,7 +931,7 @@ grab_cache_page_nowait(struct address_space *mapping, pgoff_t index) | |||
931 | struct page *page = find_get_page(mapping, index); | 931 | struct page *page = find_get_page(mapping, index); |
932 | 932 | ||
933 | if (page) { | 933 | if (page) { |
934 | if (!TestSetPageLocked(page)) | 934 | if (trylock_page(page)) |
935 | return page; | 935 | return page; |
936 | page_cache_release(page); | 936 | page_cache_release(page); |
937 | return NULL; | 937 | return NULL; |
@@ -1027,7 +1027,7 @@ find_page: | |||
1027 | if (inode->i_blkbits == PAGE_CACHE_SHIFT || | 1027 | if (inode->i_blkbits == PAGE_CACHE_SHIFT || |
1028 | !mapping->a_ops->is_partially_uptodate) | 1028 | !mapping->a_ops->is_partially_uptodate) |
1029 | goto page_not_up_to_date; | 1029 | goto page_not_up_to_date; |
1030 | if (TestSetPageLocked(page)) | 1030 | if (!trylock_page(page)) |
1031 | goto page_not_up_to_date; | 1031 | goto page_not_up_to_date; |
1032 | if (!mapping->a_ops->is_partially_uptodate(page, | 1032 | if (!mapping->a_ops->is_partially_uptodate(page, |
1033 | desc, offset)) | 1033 | desc, offset)) |
diff --git a/mm/memory.c b/mm/memory.c index 6793b9c6810..1002f473f49 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -1789,7 +1789,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1789 | * not dirty accountable. | 1789 | * not dirty accountable. |
1790 | */ | 1790 | */ |
1791 | if (PageAnon(old_page)) { | 1791 | if (PageAnon(old_page)) { |
1792 | if (!TestSetPageLocked(old_page)) { | 1792 | if (trylock_page(old_page)) { |
1793 | reuse = can_share_swap_page(old_page); | 1793 | reuse = can_share_swap_page(old_page); |
1794 | unlock_page(old_page); | 1794 | unlock_page(old_page); |
1795 | } | 1795 | } |
@@ -2765,16 +2765,26 @@ int make_pages_present(unsigned long addr, unsigned long end) | |||
2765 | 2765 | ||
2766 | vma = find_vma(current->mm, addr); | 2766 | vma = find_vma(current->mm, addr); |
2767 | if (!vma) | 2767 | if (!vma) |
2768 | return -1; | 2768 | return -ENOMEM; |
2769 | write = (vma->vm_flags & VM_WRITE) != 0; | 2769 | write = (vma->vm_flags & VM_WRITE) != 0; |
2770 | BUG_ON(addr >= end); | 2770 | BUG_ON(addr >= end); |
2771 | BUG_ON(end > vma->vm_end); | 2771 | BUG_ON(end > vma->vm_end); |
2772 | len = DIV_ROUND_UP(end, PAGE_SIZE) - addr/PAGE_SIZE; | 2772 | len = DIV_ROUND_UP(end, PAGE_SIZE) - addr/PAGE_SIZE; |
2773 | ret = get_user_pages(current, current->mm, addr, | 2773 | ret = get_user_pages(current, current->mm, addr, |
2774 | len, write, 0, NULL, NULL); | 2774 | len, write, 0, NULL, NULL); |
2775 | if (ret < 0) | 2775 | if (ret < 0) { |
2776 | /* | ||
2777 | SUS require strange return value to mlock | ||
2778 | - invalid addr generate to ENOMEM. | ||
2779 | - out of memory should generate EAGAIN. | ||
2780 | */ | ||
2781 | if (ret == -EFAULT) | ||
2782 | ret = -ENOMEM; | ||
2783 | else if (ret == -ENOMEM) | ||
2784 | ret = -EAGAIN; | ||
2776 | return ret; | 2785 | return ret; |
2777 | return ret == len ? 0 : -1; | 2786 | } |
2787 | return ret == len ? 0 : -ENOMEM; | ||
2778 | } | 2788 | } |
2779 | 2789 | ||
2780 | #if !defined(__HAVE_ARCH_GATE_AREA) | 2790 | #if !defined(__HAVE_ARCH_GATE_AREA) |
diff --git a/mm/migrate.c b/mm/migrate.c index 153572fb60b..2a80136b23b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -605,7 +605,7 @@ static int move_to_new_page(struct page *newpage, struct page *page) | |||
605 | * establishing additional references. We are the only one | 605 | * establishing additional references. We are the only one |
606 | * holding a reference to the new page at this point. | 606 | * holding a reference to the new page at this point. |
607 | */ | 607 | */ |
608 | if (TestSetPageLocked(newpage)) | 608 | if (!trylock_page(newpage)) |
609 | BUG(); | 609 | BUG(); |
610 | 610 | ||
611 | /* Prepare mapping for the new page.*/ | 611 | /* Prepare mapping for the new page.*/ |
@@ -667,7 +667,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private, | |||
667 | BUG_ON(charge); | 667 | BUG_ON(charge); |
668 | 668 | ||
669 | rc = -EAGAIN; | 669 | rc = -EAGAIN; |
670 | if (TestSetPageLocked(page)) { | 670 | if (!trylock_page(page)) { |
671 | if (!force) | 671 | if (!force) |
672 | goto move_newpage; | 672 | goto move_newpage; |
673 | lock_page(page); | 673 | lock_page(page); |
diff --git a/mm/mlock.c b/mm/mlock.c index 7b2656055d6..01fbe93eff5 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -78,8 +78,6 @@ success: | |||
78 | 78 | ||
79 | mm->locked_vm -= pages; | 79 | mm->locked_vm -= pages; |
80 | out: | 80 | out: |
81 | if (ret == -ENOMEM) | ||
82 | ret = -EAGAIN; | ||
83 | return ret; | 81 | return ret; |
84 | } | 82 | } |
85 | 83 | ||
diff --git a/mm/mm_init.c b/mm/mm_init.c index c6af41ea999..936ef2efd89 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c | |||
@@ -14,6 +14,10 @@ | |||
14 | #ifdef CONFIG_DEBUG_MEMORY_INIT | 14 | #ifdef CONFIG_DEBUG_MEMORY_INIT |
15 | int __meminitdata mminit_loglevel; | 15 | int __meminitdata mminit_loglevel; |
16 | 16 | ||
17 | #ifndef SECTIONS_SHIFT | ||
18 | #define SECTIONS_SHIFT 0 | ||
19 | #endif | ||
20 | |||
17 | /* The zonelists are simply reported, validation is manual. */ | 21 | /* The zonelists are simply reported, validation is manual. */ |
18 | void mminit_verify_zonelist(void) | 22 | void mminit_verify_zonelist(void) |
19 | { | 23 | { |
@@ -74,11 +78,7 @@ void __init mminit_verify_pageflags_layout(void) | |||
74 | NR_PAGEFLAGS); | 78 | NR_PAGEFLAGS); |
75 | mminit_dprintk(MMINIT_TRACE, "pageflags_layout_shifts", | 79 | mminit_dprintk(MMINIT_TRACE, "pageflags_layout_shifts", |
76 | "Section %d Node %d Zone %d\n", | 80 | "Section %d Node %d Zone %d\n", |
77 | #ifdef SECTIONS_SHIFT | ||
78 | SECTIONS_SHIFT, | 81 | SECTIONS_SHIFT, |
79 | #else | ||
80 | 0, | ||
81 | #endif | ||
82 | NODES_SHIFT, | 82 | NODES_SHIFT, |
83 | ZONES_SHIFT); | 83 | ZONES_SHIFT); |
84 | mminit_dprintk(MMINIT_TRACE, "pageflags_layout_offsets", | 84 | mminit_dprintk(MMINIT_TRACE, "pageflags_layout_offsets", |
@@ -370,7 +370,7 @@ find_vma_prepare(struct mm_struct *mm, unsigned long addr, | |||
370 | if (vma_tmp->vm_end > addr) { | 370 | if (vma_tmp->vm_end > addr) { |
371 | vma = vma_tmp; | 371 | vma = vma_tmp; |
372 | if (vma_tmp->vm_start <= addr) | 372 | if (vma_tmp->vm_start <= addr) |
373 | return vma; | 373 | break; |
374 | __rb_link = &__rb_parent->rb_left; | 374 | __rb_link = &__rb_parent->rb_left; |
375 | } else { | 375 | } else { |
376 | rb_prev = __rb_parent; | 376 | rb_prev = __rb_parent; |
diff --git a/mm/nommu.c b/mm/nommu.c index 5edccd9c921..ed75bc962fb 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -266,6 +266,27 @@ void *vmalloc_node(unsigned long size, int node) | |||
266 | } | 266 | } |
267 | EXPORT_SYMBOL(vmalloc_node); | 267 | EXPORT_SYMBOL(vmalloc_node); |
268 | 268 | ||
269 | #ifndef PAGE_KERNEL_EXEC | ||
270 | # define PAGE_KERNEL_EXEC PAGE_KERNEL | ||
271 | #endif | ||
272 | |||
273 | /** | ||
274 | * vmalloc_exec - allocate virtually contiguous, executable memory | ||
275 | * @size: allocation size | ||
276 | * | ||
277 | * Kernel-internal function to allocate enough pages to cover @size | ||
278 | * the page level allocator and map them into contiguous and | ||
279 | * executable kernel virtual space. | ||
280 | * | ||
281 | * For tight control over page level allocator and protection flags | ||
282 | * use __vmalloc() instead. | ||
283 | */ | ||
284 | |||
285 | void *vmalloc_exec(unsigned long size) | ||
286 | { | ||
287 | return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC); | ||
288 | } | ||
289 | |||
269 | /** | 290 | /** |
270 | * vmalloc_32 - allocate virtually contiguous memory (32bit addressable) | 291 | * vmalloc_32 - allocate virtually contiguous memory (32bit addressable) |
271 | * @size: allocation size | 292 | * @size: allocation size |
@@ -422,7 +422,7 @@ int page_referenced(struct page *page, int is_locked, | |||
422 | referenced += page_referenced_anon(page, mem_cont); | 422 | referenced += page_referenced_anon(page, mem_cont); |
423 | else if (is_locked) | 423 | else if (is_locked) |
424 | referenced += page_referenced_file(page, mem_cont); | 424 | referenced += page_referenced_file(page, mem_cont); |
425 | else if (TestSetPageLocked(page)) | 425 | else if (!trylock_page(page)) |
426 | referenced++; | 426 | referenced++; |
427 | else { | 427 | else { |
428 | if (page->mapping) | 428 | if (page->mapping) |
diff --git a/mm/shmem.c b/mm/shmem.c index c1e5a3b4f75..04fb4f1ab88 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -1265,7 +1265,7 @@ repeat: | |||
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | /* We have to do this with page locked to prevent races */ | 1267 | /* We have to do this with page locked to prevent races */ |
1268 | if (TestSetPageLocked(swappage)) { | 1268 | if (!trylock_page(swappage)) { |
1269 | shmem_swp_unmap(entry); | 1269 | shmem_swp_unmap(entry); |
1270 | spin_unlock(&info->lock); | 1270 | spin_unlock(&info->lock); |
1271 | wait_on_page_locked(swappage); | 1271 | wait_on_page_locked(swappage); |
@@ -1329,7 +1329,7 @@ repeat: | |||
1329 | shmem_swp_unmap(entry); | 1329 | shmem_swp_unmap(entry); |
1330 | filepage = find_get_page(mapping, idx); | 1330 | filepage = find_get_page(mapping, idx); |
1331 | if (filepage && | 1331 | if (filepage && |
1332 | (!PageUptodate(filepage) || TestSetPageLocked(filepage))) { | 1332 | (!PageUptodate(filepage) || !trylock_page(filepage))) { |
1333 | spin_unlock(&info->lock); | 1333 | spin_unlock(&info->lock); |
1334 | wait_on_page_locked(filepage); | 1334 | wait_on_page_locked(filepage); |
1335 | page_cache_release(filepage); | 1335 | page_cache_release(filepage); |
@@ -444,7 +444,7 @@ void pagevec_strip(struct pagevec *pvec) | |||
444 | for (i = 0; i < pagevec_count(pvec); i++) { | 444 | for (i = 0; i < pagevec_count(pvec); i++) { |
445 | struct page *page = pvec->pages[i]; | 445 | struct page *page = pvec->pages[i]; |
446 | 446 | ||
447 | if (PagePrivate(page) && !TestSetPageLocked(page)) { | 447 | if (PagePrivate(page) && trylock_page(page)) { |
448 | if (PagePrivate(page)) | 448 | if (PagePrivate(page)) |
449 | try_to_release_page(page, 0); | 449 | try_to_release_page(page, 0); |
450 | unlock_page(page); | 450 | unlock_page(page); |
diff --git a/mm/swap_state.c b/mm/swap_state.c index b8035b05512..167cf2dc8a0 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c | |||
@@ -201,7 +201,7 @@ void delete_from_swap_cache(struct page *page) | |||
201 | */ | 201 | */ |
202 | static inline void free_swap_cache(struct page *page) | 202 | static inline void free_swap_cache(struct page *page) |
203 | { | 203 | { |
204 | if (PageSwapCache(page) && !TestSetPageLocked(page)) { | 204 | if (PageSwapCache(page) && trylock_page(page)) { |
205 | remove_exclusive_swap_page(page); | 205 | remove_exclusive_swap_page(page); |
206 | unlock_page(page); | 206 | unlock_page(page); |
207 | } | 207 | } |
@@ -302,9 +302,9 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, | |||
302 | * re-using the just freed swap entry for an existing page. | 302 | * re-using the just freed swap entry for an existing page. |
303 | * May fail (-ENOMEM) if radix-tree node allocation failed. | 303 | * May fail (-ENOMEM) if radix-tree node allocation failed. |
304 | */ | 304 | */ |
305 | SetPageLocked(new_page); | 305 | set_page_locked(new_page); |
306 | err = add_to_swap_cache(new_page, entry, gfp_mask & GFP_KERNEL); | 306 | err = add_to_swap_cache(new_page, entry, gfp_mask & GFP_KERNEL); |
307 | if (!err) { | 307 | if (likely(!err)) { |
308 | /* | 308 | /* |
309 | * Initiate read into locked page and return. | 309 | * Initiate read into locked page and return. |
310 | */ | 310 | */ |
@@ -312,7 +312,7 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, | |||
312 | swap_readpage(NULL, new_page); | 312 | swap_readpage(NULL, new_page); |
313 | return new_page; | 313 | return new_page; |
314 | } | 314 | } |
315 | ClearPageLocked(new_page); | 315 | clear_page_locked(new_page); |
316 | swap_free(entry); | 316 | swap_free(entry); |
317 | } while (err != -ENOMEM); | 317 | } while (err != -ENOMEM); |
318 | 318 | ||
diff --git a/mm/swapfile.c b/mm/swapfile.c index bb7f79641f9..1e330f2998f 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -403,7 +403,7 @@ void free_swap_and_cache(swp_entry_t entry) | |||
403 | if (p) { | 403 | if (p) { |
404 | if (swap_entry_free(p, swp_offset(entry)) == 1) { | 404 | if (swap_entry_free(p, swp_offset(entry)) == 1) { |
405 | page = find_get_page(&swapper_space, entry.val); | 405 | page = find_get_page(&swapper_space, entry.val); |
406 | if (page && unlikely(TestSetPageLocked(page))) { | 406 | if (page && unlikely(!trylock_page(page))) { |
407 | page_cache_release(page); | 407 | page_cache_release(page); |
408 | page = NULL; | 408 | page = NULL; |
409 | } | 409 | } |
diff --git a/mm/truncate.c b/mm/truncate.c index 894e9a70699..250505091d3 100644 --- a/mm/truncate.c +++ b/mm/truncate.c | |||
@@ -187,7 +187,7 @@ void truncate_inode_pages_range(struct address_space *mapping, | |||
187 | if (page_index > next) | 187 | if (page_index > next) |
188 | next = page_index; | 188 | next = page_index; |
189 | next++; | 189 | next++; |
190 | if (TestSetPageLocked(page)) | 190 | if (!trylock_page(page)) |
191 | continue; | 191 | continue; |
192 | if (PageWriteback(page)) { | 192 | if (PageWriteback(page)) { |
193 | unlock_page(page); | 193 | unlock_page(page); |
@@ -280,7 +280,7 @@ unsigned long __invalidate_mapping_pages(struct address_space *mapping, | |||
280 | pgoff_t index; | 280 | pgoff_t index; |
281 | int lock_failed; | 281 | int lock_failed; |
282 | 282 | ||
283 | lock_failed = TestSetPageLocked(page); | 283 | lock_failed = !trylock_page(page); |
284 | 284 | ||
285 | /* | 285 | /* |
286 | * We really shouldn't be looking at the ->index of an | 286 | * We really shouldn't be looking at the ->index of an |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 75be453628b..1ff1a58e7c1 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -496,7 +496,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, | |||
496 | page = lru_to_page(page_list); | 496 | page = lru_to_page(page_list); |
497 | list_del(&page->lru); | 497 | list_del(&page->lru); |
498 | 498 | ||
499 | if (TestSetPageLocked(page)) | 499 | if (!trylock_page(page)) |
500 | goto keep; | 500 | goto keep; |
501 | 501 | ||
502 | VM_BUG_ON(PageActive(page)); | 502 | VM_BUG_ON(PageActive(page)); |
@@ -582,7 +582,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, | |||
582 | * A synchronous write - probably a ramdisk. Go | 582 | * A synchronous write - probably a ramdisk. Go |
583 | * ahead and try to reclaim the page. | 583 | * ahead and try to reclaim the page. |
584 | */ | 584 | */ |
585 | if (TestSetPageLocked(page)) | 585 | if (!trylock_page(page)) |
586 | goto keep; | 586 | goto keep; |
587 | if (PageDirty(page) || PageWriteback(page)) | 587 | if (PageDirty(page) || PageWriteback(page)) |
588 | goto keep_locked; | 588 | goto keep_locked; |