diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-08-22 00:06:51 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-08-22 00:06:51 -0400 |
commit | 8b53b57576292b92b27769f9e213df19b6e57786 (patch) | |
tree | cd851ce4fa71b2653f120d7f11a9c6cbcf311b19 /mm | |
parent | ab7e79243746e2a9c5f00243e60108189c44c9eb (diff) | |
parent | 38cc1c3df77c1bb739a4766788eb9fa49f16ffdf (diff) |
Merge branch 'x86/urgent' into x86/pat
Conflicts:
arch/x86/mm/pageattr.c
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/Kconfig | 3 | ||||
-rw-r--r-- | mm/bootmem.c | 2 | ||||
-rw-r--r-- | mm/hugetlb.c | 62 | ||||
-rw-r--r-- | mm/memcontrol.c | 2 | ||||
-rw-r--r-- | mm/mempolicy.c | 1 | ||||
-rw-r--r-- | mm/mmap.c | 20 | ||||
-rw-r--r-- | mm/oom_kill.c | 6 | ||||
-rw-r--r-- | mm/page_alloc.c | 2 | ||||
-rw-r--r-- | mm/sparse.c | 1 | ||||
-rw-r--r-- | mm/util.c | 15 |
10 files changed, 86 insertions, 28 deletions
diff --git a/mm/Kconfig b/mm/Kconfig index 446c6588c753..0bd9c2dbb2a0 100644 --- a/mm/Kconfig +++ b/mm/Kconfig | |||
@@ -77,9 +77,6 @@ config FLAT_NODE_MEM_MAP | |||
77 | def_bool y | 77 | def_bool y |
78 | depends on !SPARSEMEM | 78 | depends on !SPARSEMEM |
79 | 79 | ||
80 | config HAVE_GET_USER_PAGES_FAST | ||
81 | bool | ||
82 | |||
83 | # | 80 | # |
84 | # Both the NUMA code and DISCONTIGMEM use arrays of pg_data_t's | 81 | # Both the NUMA code and DISCONTIGMEM use arrays of pg_data_t's |
85 | # to represent different areas of memory. This variable allows | 82 | # to represent different areas of memory. This variable allows |
diff --git a/mm/bootmem.c b/mm/bootmem.c index 4af15d0340ad..e023c68b0255 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -473,7 +473,7 @@ find_block: | |||
473 | goto find_block; | 473 | goto find_block; |
474 | } | 474 | } |
475 | 475 | ||
476 | if (bdata->last_end_off && | 476 | if (bdata->last_end_off & (PAGE_SIZE - 1) && |
477 | PFN_DOWN(bdata->last_end_off) + 1 == sidx) | 477 | PFN_DOWN(bdata->last_end_off) + 1 == sidx) |
478 | start_off = ALIGN(bdata->last_end_off, align); | 478 | start_off = ALIGN(bdata->last_end_off, align); |
479 | else | 479 | else |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 757ca983fd99..67a71191136e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -565,7 +565,7 @@ static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid) | |||
565 | huge_page_order(h)); | 565 | huge_page_order(h)); |
566 | if (page) { | 566 | if (page) { |
567 | if (arch_prepare_hugepage(page)) { | 567 | if (arch_prepare_hugepage(page)) { |
568 | __free_pages(page, HUGETLB_PAGE_ORDER); | 568 | __free_pages(page, huge_page_order(h)); |
569 | return NULL; | 569 | return NULL; |
570 | } | 570 | } |
571 | prep_new_huge_page(h, page, nid); | 571 | prep_new_huge_page(h, page, nid); |
@@ -665,6 +665,11 @@ static struct page *alloc_buddy_huge_page(struct hstate *h, | |||
665 | __GFP_REPEAT|__GFP_NOWARN, | 665 | __GFP_REPEAT|__GFP_NOWARN, |
666 | huge_page_order(h)); | 666 | huge_page_order(h)); |
667 | 667 | ||
668 | if (page && arch_prepare_hugepage(page)) { | ||
669 | __free_pages(page, huge_page_order(h)); | ||
670 | return NULL; | ||
671 | } | ||
672 | |||
668 | spin_lock(&hugetlb_lock); | 673 | spin_lock(&hugetlb_lock); |
669 | if (page) { | 674 | if (page) { |
670 | /* | 675 | /* |
@@ -1937,6 +1942,18 @@ retry: | |||
1937 | lock_page(page); | 1942 | lock_page(page); |
1938 | } | 1943 | } |
1939 | 1944 | ||
1945 | /* | ||
1946 | * If we are going to COW a private mapping later, we examine the | ||
1947 | * pending reservations for this page now. This will ensure that | ||
1948 | * any allocations necessary to record that reservation occur outside | ||
1949 | * the spinlock. | ||
1950 | */ | ||
1951 | if (write_access && !(vma->vm_flags & VM_SHARED)) | ||
1952 | if (vma_needs_reservation(h, vma, address) < 0) { | ||
1953 | ret = VM_FAULT_OOM; | ||
1954 | goto backout_unlocked; | ||
1955 | } | ||
1956 | |||
1940 | spin_lock(&mm->page_table_lock); | 1957 | spin_lock(&mm->page_table_lock); |
1941 | size = i_size_read(mapping->host) >> huge_page_shift(h); | 1958 | size = i_size_read(mapping->host) >> huge_page_shift(h); |
1942 | if (idx >= size) | 1959 | if (idx >= size) |
@@ -1962,6 +1979,7 @@ out: | |||
1962 | 1979 | ||
1963 | backout: | 1980 | backout: |
1964 | spin_unlock(&mm->page_table_lock); | 1981 | spin_unlock(&mm->page_table_lock); |
1982 | backout_unlocked: | ||
1965 | unlock_page(page); | 1983 | unlock_page(page); |
1966 | put_page(page); | 1984 | put_page(page); |
1967 | goto out; | 1985 | goto out; |
@@ -1973,6 +1991,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1973 | pte_t *ptep; | 1991 | pte_t *ptep; |
1974 | pte_t entry; | 1992 | pte_t entry; |
1975 | int ret; | 1993 | int ret; |
1994 | struct page *pagecache_page = NULL; | ||
1976 | static DEFINE_MUTEX(hugetlb_instantiation_mutex); | 1995 | static DEFINE_MUTEX(hugetlb_instantiation_mutex); |
1977 | struct hstate *h = hstate_vma(vma); | 1996 | struct hstate *h = hstate_vma(vma); |
1978 | 1997 | ||
@@ -1989,25 +2008,44 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1989 | entry = huge_ptep_get(ptep); | 2008 | entry = huge_ptep_get(ptep); |
1990 | if (huge_pte_none(entry)) { | 2009 | if (huge_pte_none(entry)) { |
1991 | ret = hugetlb_no_page(mm, vma, address, ptep, write_access); | 2010 | ret = hugetlb_no_page(mm, vma, address, ptep, write_access); |
1992 | mutex_unlock(&hugetlb_instantiation_mutex); | 2011 | goto out_unlock; |
1993 | return ret; | ||
1994 | } | 2012 | } |
1995 | 2013 | ||
1996 | ret = 0; | 2014 | ret = 0; |
1997 | 2015 | ||
2016 | /* | ||
2017 | * If we are going to COW the mapping later, we examine the pending | ||
2018 | * reservations for this page now. This will ensure that any | ||
2019 | * allocations necessary to record that reservation occur outside the | ||
2020 | * spinlock. For private mappings, we also lookup the pagecache | ||
2021 | * page now as it is used to determine if a reservation has been | ||
2022 | * consumed. | ||
2023 | */ | ||
2024 | if (write_access && !pte_write(entry)) { | ||
2025 | if (vma_needs_reservation(h, vma, address) < 0) { | ||
2026 | ret = VM_FAULT_OOM; | ||
2027 | goto out_unlock; | ||
2028 | } | ||
2029 | |||
2030 | if (!(vma->vm_flags & VM_SHARED)) | ||
2031 | pagecache_page = hugetlbfs_pagecache_page(h, | ||
2032 | vma, address); | ||
2033 | } | ||
2034 | |||
1998 | spin_lock(&mm->page_table_lock); | 2035 | spin_lock(&mm->page_table_lock); |
1999 | /* Check for a racing update before calling hugetlb_cow */ | 2036 | /* Check for a racing update before calling hugetlb_cow */ |
2000 | if (likely(pte_same(entry, huge_ptep_get(ptep)))) | 2037 | if (likely(pte_same(entry, huge_ptep_get(ptep)))) |
2001 | if (write_access && !pte_write(entry)) { | 2038 | if (write_access && !pte_write(entry)) |
2002 | struct page *page; | 2039 | ret = hugetlb_cow(mm, vma, address, ptep, entry, |
2003 | page = hugetlbfs_pagecache_page(h, vma, address); | 2040 | pagecache_page); |
2004 | ret = hugetlb_cow(mm, vma, address, ptep, entry, page); | ||
2005 | if (page) { | ||
2006 | unlock_page(page); | ||
2007 | put_page(page); | ||
2008 | } | ||
2009 | } | ||
2010 | spin_unlock(&mm->page_table_lock); | 2041 | spin_unlock(&mm->page_table_lock); |
2042 | |||
2043 | if (pagecache_page) { | ||
2044 | unlock_page(pagecache_page); | ||
2045 | put_page(pagecache_page); | ||
2046 | } | ||
2047 | |||
2048 | out_unlock: | ||
2011 | mutex_unlock(&hugetlb_instantiation_mutex); | 2049 | mutex_unlock(&hugetlb_instantiation_mutex); |
2012 | 2050 | ||
2013 | return ret; | 2051 | return ret; |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7056c3bdb478..0f1f7a7374ba 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -796,6 +796,8 @@ int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask) | |||
796 | 796 | ||
797 | if (mem_cgroup_subsys.disabled) | 797 | if (mem_cgroup_subsys.disabled) |
798 | return 0; | 798 | return 0; |
799 | if (!mm) | ||
800 | return 0; | ||
799 | 801 | ||
800 | rcu_read_lock(); | 802 | rcu_read_lock(); |
801 | mem = mem_cgroup_from_task(rcu_dereference(mm->owner)); | 803 | mem = mem_cgroup_from_task(rcu_dereference(mm->owner)); |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index e550bec20582..83369058ec13 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -803,7 +803,6 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest, | |||
803 | int do_migrate_pages(struct mm_struct *mm, | 803 | int do_migrate_pages(struct mm_struct *mm, |
804 | const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags) | 804 | const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags) |
805 | { | 805 | { |
806 | LIST_HEAD(pagelist); | ||
807 | int busy = 0; | 806 | int busy = 0; |
808 | int err = 0; | 807 | int err = 0; |
809 | nodemask_t tmp; | 808 | nodemask_t tmp; |
@@ -2273,14 +2273,14 @@ int install_special_mapping(struct mm_struct *mm, | |||
2273 | 2273 | ||
2274 | static DEFINE_MUTEX(mm_all_locks_mutex); | 2274 | static DEFINE_MUTEX(mm_all_locks_mutex); |
2275 | 2275 | ||
2276 | static void vm_lock_anon_vma(struct anon_vma *anon_vma) | 2276 | static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma) |
2277 | { | 2277 | { |
2278 | if (!test_bit(0, (unsigned long *) &anon_vma->head.next)) { | 2278 | if (!test_bit(0, (unsigned long *) &anon_vma->head.next)) { |
2279 | /* | 2279 | /* |
2280 | * The LSB of head.next can't change from under us | 2280 | * The LSB of head.next can't change from under us |
2281 | * because we hold the mm_all_locks_mutex. | 2281 | * because we hold the mm_all_locks_mutex. |
2282 | */ | 2282 | */ |
2283 | spin_lock(&anon_vma->lock); | 2283 | spin_lock_nest_lock(&anon_vma->lock, &mm->mmap_sem); |
2284 | /* | 2284 | /* |
2285 | * We can safely modify head.next after taking the | 2285 | * We can safely modify head.next after taking the |
2286 | * anon_vma->lock. If some other vma in this mm shares | 2286 | * anon_vma->lock. If some other vma in this mm shares |
@@ -2296,7 +2296,7 @@ static void vm_lock_anon_vma(struct anon_vma *anon_vma) | |||
2296 | } | 2296 | } |
2297 | } | 2297 | } |
2298 | 2298 | ||
2299 | static void vm_lock_mapping(struct address_space *mapping) | 2299 | static void vm_lock_mapping(struct mm_struct *mm, struct address_space *mapping) |
2300 | { | 2300 | { |
2301 | if (!test_bit(AS_MM_ALL_LOCKS, &mapping->flags)) { | 2301 | if (!test_bit(AS_MM_ALL_LOCKS, &mapping->flags)) { |
2302 | /* | 2302 | /* |
@@ -2310,7 +2310,7 @@ static void vm_lock_mapping(struct address_space *mapping) | |||
2310 | */ | 2310 | */ |
2311 | if (test_and_set_bit(AS_MM_ALL_LOCKS, &mapping->flags)) | 2311 | if (test_and_set_bit(AS_MM_ALL_LOCKS, &mapping->flags)) |
2312 | BUG(); | 2312 | BUG(); |
2313 | spin_lock(&mapping->i_mmap_lock); | 2313 | spin_lock_nest_lock(&mapping->i_mmap_lock, &mm->mmap_sem); |
2314 | } | 2314 | } |
2315 | } | 2315 | } |
2316 | 2316 | ||
@@ -2358,11 +2358,17 @@ int mm_take_all_locks(struct mm_struct *mm) | |||
2358 | for (vma = mm->mmap; vma; vma = vma->vm_next) { | 2358 | for (vma = mm->mmap; vma; vma = vma->vm_next) { |
2359 | if (signal_pending(current)) | 2359 | if (signal_pending(current)) |
2360 | goto out_unlock; | 2360 | goto out_unlock; |
2361 | if (vma->anon_vma) | ||
2362 | vm_lock_anon_vma(vma->anon_vma); | ||
2363 | if (vma->vm_file && vma->vm_file->f_mapping) | 2361 | if (vma->vm_file && vma->vm_file->f_mapping) |
2364 | vm_lock_mapping(vma->vm_file->f_mapping); | 2362 | vm_lock_mapping(mm, vma->vm_file->f_mapping); |
2363 | } | ||
2364 | |||
2365 | for (vma = mm->mmap; vma; vma = vma->vm_next) { | ||
2366 | if (signal_pending(current)) | ||
2367 | goto out_unlock; | ||
2368 | if (vma->anon_vma) | ||
2369 | vm_lock_anon_vma(mm, vma->anon_vma); | ||
2365 | } | 2370 | } |
2371 | |||
2366 | ret = 0; | 2372 | ret = 0; |
2367 | 2373 | ||
2368 | out_unlock: | 2374 | out_unlock: |
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 8a5467ee6265..64e5b4bcd964 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/notifier.h> | 27 | #include <linux/notifier.h> |
28 | #include <linux/memcontrol.h> | 28 | #include <linux/memcontrol.h> |
29 | #include <linux/security.h> | ||
29 | 30 | ||
30 | int sysctl_panic_on_oom; | 31 | int sysctl_panic_on_oom; |
31 | int sysctl_oom_kill_allocating_task; | 32 | int sysctl_oom_kill_allocating_task; |
@@ -128,7 +129,8 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) | |||
128 | * Superuser processes are usually more important, so we make it | 129 | * Superuser processes are usually more important, so we make it |
129 | * less likely that we kill those. | 130 | * less likely that we kill those. |
130 | */ | 131 | */ |
131 | if (__capable(p, CAP_SYS_ADMIN) || __capable(p, CAP_SYS_RESOURCE)) | 132 | if (has_capability(p, CAP_SYS_ADMIN) || |
133 | has_capability(p, CAP_SYS_RESOURCE)) | ||
132 | points /= 4; | 134 | points /= 4; |
133 | 135 | ||
134 | /* | 136 | /* |
@@ -137,7 +139,7 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) | |||
137 | * tend to only have this flag set on applications they think | 139 | * tend to only have this flag set on applications they think |
138 | * of as important. | 140 | * of as important. |
139 | */ | 141 | */ |
140 | if (__capable(p, CAP_SYS_RAWIO)) | 142 | if (has_capability(p, CAP_SYS_RAWIO)) |
141 | points /= 4; | 143 | points /= 4; |
142 | 144 | ||
143 | /* | 145 | /* |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 401d104d2bb6..af982f7cdb2a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -4437,7 +4437,7 @@ void *__init alloc_large_system_hash(const char *tablename, | |||
4437 | do { | 4437 | do { |
4438 | size = bucketsize << log2qty; | 4438 | size = bucketsize << log2qty; |
4439 | if (flags & HASH_EARLY) | 4439 | if (flags & HASH_EARLY) |
4440 | table = alloc_bootmem(size); | 4440 | table = alloc_bootmem_nopanic(size); |
4441 | else if (hashdist) | 4441 | else if (hashdist) |
4442 | table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL); | 4442 | table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL); |
4443 | else { | 4443 | else { |
diff --git a/mm/sparse.c b/mm/sparse.c index 5d9dbbb9d39e..39db301b920d 100644 --- a/mm/sparse.c +++ b/mm/sparse.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <asm/dma.h> | 12 | #include <asm/dma.h> |
13 | #include <asm/pgalloc.h> | 13 | #include <asm/pgalloc.h> |
14 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
15 | #include "internal.h" | ||
16 | 15 | ||
17 | /* | 16 | /* |
18 | * Permanent SPARSEMEM data: | 17 | * Permanent SPARSEMEM data: |
@@ -171,3 +171,18 @@ void arch_pick_mmap_layout(struct mm_struct *mm) | |||
171 | mm->unmap_area = arch_unmap_area; | 171 | mm->unmap_area = arch_unmap_area; |
172 | } | 172 | } |
173 | #endif | 173 | #endif |
174 | |||
175 | int __attribute__((weak)) get_user_pages_fast(unsigned long start, | ||
176 | int nr_pages, int write, struct page **pages) | ||
177 | { | ||
178 | struct mm_struct *mm = current->mm; | ||
179 | int ret; | ||
180 | |||
181 | down_read(&mm->mmap_sem); | ||
182 | ret = get_user_pages(current, mm, start, nr_pages, | ||
183 | write, 0, pages, NULL); | ||
184 | up_read(&mm->mmap_sem); | ||
185 | |||
186 | return ret; | ||
187 | } | ||
188 | EXPORT_SYMBOL_GPL(get_user_pages_fast); | ||