aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-05-14 08:43:40 -0400
committerIngo Molnar <mingo@kernel.org>2012-05-14 08:43:40 -0400
commit9cba26e66d09bf394ae5a739627a1dc8b7cae6f4 (patch)
treef03743d576a0c7826b9921ad47e70370ebe80a22 /mm
parentec83db0f78cd44c3b586ec1c3a348d1a8a389797 (diff)
parent73eff9f56e15598c8399c0b86899fd889b97f085 (diff)
Merge branch 'perf/uprobes' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/uprobes
Diffstat (limited to 'mm')
-rw-r--r--mm/hugetlb.c2
-rw-r--r--mm/memblock.c7
-rw-r--r--mm/memcontrol.c7
-rw-r--r--mm/mmap.c59
-rw-r--r--mm/nommu.c41
-rw-r--r--mm/vmscan.c7
6 files changed, 99 insertions, 24 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b8ce6f450956..cd65cb19c941 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2791,6 +2791,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2791 * so no worry about deadlock. 2791 * so no worry about deadlock.
2792 */ 2792 */
2793 page = pte_page(entry); 2793 page = pte_page(entry);
2794 get_page(page);
2794 if (page != pagecache_page) 2795 if (page != pagecache_page)
2795 lock_page(page); 2796 lock_page(page);
2796 2797
@@ -2822,6 +2823,7 @@ out_page_table_lock:
2822 } 2823 }
2823 if (page != pagecache_page) 2824 if (page != pagecache_page)
2824 unlock_page(page); 2825 unlock_page(page);
2826 put_page(page);
2825 2827
2826out_mutex: 2828out_mutex:
2827 mutex_unlock(&hugetlb_instantiation_mutex); 2829 mutex_unlock(&hugetlb_instantiation_mutex);
diff --git a/mm/memblock.c b/mm/memblock.c
index 99f285599501..a44eab3157f8 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -330,6 +330,9 @@ static int __init_memblock memblock_add_region(struct memblock_type *type,
330 phys_addr_t end = base + memblock_cap_size(base, &size); 330 phys_addr_t end = base + memblock_cap_size(base, &size);
331 int i, nr_new; 331 int i, nr_new;
332 332
333 if (!size)
334 return 0;
335
333 /* special case for empty array */ 336 /* special case for empty array */
334 if (type->regions[0].size == 0) { 337 if (type->regions[0].size == 0) {
335 WARN_ON(type->cnt != 1 || type->total_size); 338 WARN_ON(type->cnt != 1 || type->total_size);
@@ -430,6 +433,9 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type,
430 433
431 *start_rgn = *end_rgn = 0; 434 *start_rgn = *end_rgn = 0;
432 435
436 if (!size)
437 return 0;
438
433 /* we'll create at most two more regions */ 439 /* we'll create at most two more regions */
434 while (type->cnt + 2 > type->max) 440 while (type->cnt + 2 > type->max)
435 if (memblock_double_array(type) < 0) 441 if (memblock_double_array(type) < 0)
@@ -514,7 +520,6 @@ int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
514 (unsigned long long)base, 520 (unsigned long long)base,
515 (unsigned long long)base + size, 521 (unsigned long long)base + size,
516 (void *)_RET_IP_); 522 (void *)_RET_IP_);
517 BUG_ON(0 == size);
518 523
519 return memblock_add_region(_rgn, base, size, MAX_NUMNODES); 524 return memblock_add_region(_rgn, base, size, MAX_NUMNODES);
520} 525}
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7d698df4a067..b868def9bcc1 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2165,7 +2165,7 @@ static int __cpuinit memcg_cpu_hotplug_callback(struct notifier_block *nb,
2165 if (action == CPU_ONLINE) 2165 if (action == CPU_ONLINE)
2166 return NOTIFY_OK; 2166 return NOTIFY_OK;
2167 2167
2168 if ((action != CPU_DEAD) || action != CPU_DEAD_FROZEN) 2168 if (action != CPU_DEAD && action != CPU_DEAD_FROZEN)
2169 return NOTIFY_OK; 2169 return NOTIFY_OK;
2170 2170
2171 for_each_mem_cgroup(iter) 2171 for_each_mem_cgroup(iter)
@@ -3392,6 +3392,7 @@ void mem_cgroup_replace_page_cache(struct page *oldpage,
3392 * the newpage may be on LRU(or pagevec for LRU) already. We lock 3392 * the newpage may be on LRU(or pagevec for LRU) already. We lock
3393 * LRU while we overwrite pc->mem_cgroup. 3393 * LRU while we overwrite pc->mem_cgroup.
3394 */ 3394 */
3395 pc = lookup_page_cgroup(newpage);
3395 __mem_cgroup_commit_charge(memcg, newpage, 1, pc, type, true); 3396 __mem_cgroup_commit_charge(memcg, newpage, 1, pc, type, true);
3396} 3397}
3397 3398
@@ -3763,7 +3764,7 @@ move_account:
3763 goto try_to_free; 3764 goto try_to_free;
3764 cond_resched(); 3765 cond_resched();
3765 /* "ret" should also be checked to ensure all lists are empty. */ 3766 /* "ret" should also be checked to ensure all lists are empty. */
3766 } while (memcg->res.usage > 0 || ret); 3767 } while (res_counter_read_u64(&memcg->res, RES_USAGE) > 0 || ret);
3767out: 3768out:
3768 css_put(&memcg->css); 3769 css_put(&memcg->css);
3769 return ret; 3770 return ret;
@@ -3778,7 +3779,7 @@ try_to_free:
3778 lru_add_drain_all(); 3779 lru_add_drain_all();
3779 /* try to free all pages in this cgroup */ 3780 /* try to free all pages in this cgroup */
3780 shrink = 1; 3781 shrink = 1;
3781 while (nr_retries && memcg->res.usage > 0) { 3782 while (nr_retries && res_counter_read_u64(&memcg->res, RES_USAGE) > 0) {
3782 int progress; 3783 int progress;
3783 3784
3784 if (signal_pending(current)) { 3785 if (signal_pending(current)) {
diff --git a/mm/mmap.c b/mm/mmap.c
index 15c21a150402..b8c4072dd9ca 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -241,6 +241,8 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
241 return next; 241 return next;
242} 242}
243 243
244static unsigned long do_brk(unsigned long addr, unsigned long len);
245
244SYSCALL_DEFINE1(brk, unsigned long, brk) 246SYSCALL_DEFINE1(brk, unsigned long, brk)
245{ 247{
246 unsigned long rlim, retval; 248 unsigned long rlim, retval;
@@ -969,7 +971,7 @@ static inline unsigned long round_hint_to_min(unsigned long hint)
969 * The caller must hold down_write(&current->mm->mmap_sem). 971 * The caller must hold down_write(&current->mm->mmap_sem).
970 */ 972 */
971 973
972unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, 974static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
973 unsigned long len, unsigned long prot, 975 unsigned long len, unsigned long prot,
974 unsigned long flags, unsigned long pgoff) 976 unsigned long flags, unsigned long pgoff)
975{ 977{
@@ -1105,7 +1107,32 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1105 1107
1106 return mmap_region(file, addr, len, flags, vm_flags, pgoff); 1108 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
1107} 1109}
1108EXPORT_SYMBOL(do_mmap_pgoff); 1110
1111unsigned long do_mmap(struct file *file, unsigned long addr,
1112 unsigned long len, unsigned long prot,
1113 unsigned long flag, unsigned long offset)
1114{
1115 if (unlikely(offset + PAGE_ALIGN(len) < offset))
1116 return -EINVAL;
1117 if (unlikely(offset & ~PAGE_MASK))
1118 return -EINVAL;
1119 return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
1120}
1121EXPORT_SYMBOL(do_mmap);
1122
1123unsigned long vm_mmap(struct file *file, unsigned long addr,
1124 unsigned long len, unsigned long prot,
1125 unsigned long flag, unsigned long offset)
1126{
1127 unsigned long ret;
1128 struct mm_struct *mm = current->mm;
1129
1130 down_write(&mm->mmap_sem);
1131 ret = do_mmap(file, addr, len, prot, flag, offset);
1132 up_write(&mm->mmap_sem);
1133 return ret;
1134}
1135EXPORT_SYMBOL(vm_mmap);
1109 1136
1110SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, 1137SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
1111 unsigned long, prot, unsigned long, flags, 1138 unsigned long, prot, unsigned long, flags,
@@ -2128,21 +2155,25 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
2128 2155
2129 return 0; 2156 return 0;
2130} 2157}
2131
2132EXPORT_SYMBOL(do_munmap); 2158EXPORT_SYMBOL(do_munmap);
2133 2159
2134SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len) 2160int vm_munmap(unsigned long start, size_t len)
2135{ 2161{
2136 int ret; 2162 int ret;
2137 struct mm_struct *mm = current->mm; 2163 struct mm_struct *mm = current->mm;
2138 2164
2139 profile_munmap(addr);
2140
2141 down_write(&mm->mmap_sem); 2165 down_write(&mm->mmap_sem);
2142 ret = do_munmap(mm, addr, len); 2166 ret = do_munmap(mm, start, len);
2143 up_write(&mm->mmap_sem); 2167 up_write(&mm->mmap_sem);
2144 return ret; 2168 return ret;
2145} 2169}
2170EXPORT_SYMBOL(vm_munmap);
2171
2172SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
2173{
2174 profile_munmap(addr);
2175 return vm_munmap(addr, len);
2176}
2146 2177
2147static inline void verify_mm_writelocked(struct mm_struct *mm) 2178static inline void verify_mm_writelocked(struct mm_struct *mm)
2148{ 2179{
@@ -2159,7 +2190,7 @@ static inline void verify_mm_writelocked(struct mm_struct *mm)
2159 * anonymous maps. eventually we may be able to do some 2190 * anonymous maps. eventually we may be able to do some
2160 * brk-specific accounting here. 2191 * brk-specific accounting here.
2161 */ 2192 */
2162unsigned long do_brk(unsigned long addr, unsigned long len) 2193static unsigned long do_brk(unsigned long addr, unsigned long len)
2163{ 2194{
2164 struct mm_struct * mm = current->mm; 2195 struct mm_struct * mm = current->mm;
2165 struct vm_area_struct * vma, * prev; 2196 struct vm_area_struct * vma, * prev;
@@ -2255,7 +2286,17 @@ out:
2255 return addr; 2286 return addr;
2256} 2287}
2257 2288
2258EXPORT_SYMBOL(do_brk); 2289unsigned long vm_brk(unsigned long addr, unsigned long len)
2290{
2291 struct mm_struct *mm = current->mm;
2292 unsigned long ret;
2293
2294 down_write(&mm->mmap_sem);
2295 ret = do_brk(addr, len);
2296 up_write(&mm->mmap_sem);
2297 return ret;
2298}
2299EXPORT_SYMBOL(vm_brk);
2259 2300
2260/* Release all mmaps. */ 2301/* Release all mmaps. */
2261void exit_mmap(struct mm_struct *mm) 2302void exit_mmap(struct mm_struct *mm)
diff --git a/mm/nommu.c b/mm/nommu.c
index f59e170fceb4..bb8f4f004a82 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1233,7 +1233,7 @@ enomem:
1233/* 1233/*
1234 * handle mapping creation for uClinux 1234 * handle mapping creation for uClinux
1235 */ 1235 */
1236unsigned long do_mmap_pgoff(struct file *file, 1236static unsigned long do_mmap_pgoff(struct file *file,
1237 unsigned long addr, 1237 unsigned long addr,
1238 unsigned long len, 1238 unsigned long len,
1239 unsigned long prot, 1239 unsigned long prot,
@@ -1470,7 +1470,32 @@ error_getting_region:
1470 show_free_areas(0); 1470 show_free_areas(0);
1471 return -ENOMEM; 1471 return -ENOMEM;
1472} 1472}
1473EXPORT_SYMBOL(do_mmap_pgoff); 1473
1474unsigned long do_mmap(struct file *file, unsigned long addr,
1475 unsigned long len, unsigned long prot,
1476 unsigned long flag, unsigned long offset)
1477{
1478 if (unlikely(offset + PAGE_ALIGN(len) < offset))
1479 return -EINVAL;
1480 if (unlikely(offset & ~PAGE_MASK))
1481 return -EINVAL;
1482 return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
1483}
1484EXPORT_SYMBOL(do_mmap);
1485
1486unsigned long vm_mmap(struct file *file, unsigned long addr,
1487 unsigned long len, unsigned long prot,
1488 unsigned long flag, unsigned long offset)
1489{
1490 unsigned long ret;
1491 struct mm_struct *mm = current->mm;
1492
1493 down_write(&mm->mmap_sem);
1494 ret = do_mmap(file, addr, len, prot, flag, offset);
1495 up_write(&mm->mmap_sem);
1496 return ret;
1497}
1498EXPORT_SYMBOL(vm_mmap);
1474 1499
1475SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, 1500SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
1476 unsigned long, prot, unsigned long, flags, 1501 unsigned long, prot, unsigned long, flags,
@@ -1709,16 +1734,22 @@ erase_whole_vma:
1709} 1734}
1710EXPORT_SYMBOL(do_munmap); 1735EXPORT_SYMBOL(do_munmap);
1711 1736
1712SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len) 1737int vm_munmap(unsigned long addr, size_t len)
1713{ 1738{
1714 int ret;
1715 struct mm_struct *mm = current->mm; 1739 struct mm_struct *mm = current->mm;
1740 int ret;
1716 1741
1717 down_write(&mm->mmap_sem); 1742 down_write(&mm->mmap_sem);
1718 ret = do_munmap(mm, addr, len); 1743 ret = do_munmap(mm, addr, len);
1719 up_write(&mm->mmap_sem); 1744 up_write(&mm->mmap_sem);
1720 return ret; 1745 return ret;
1721} 1746}
1747EXPORT_SYMBOL(vm_munmap);
1748
1749SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
1750{
1751 return vm_munmap(addr, len);
1752}
1722 1753
1723/* 1754/*
1724 * release all the mappings made in a process's VM space 1755 * release all the mappings made in a process's VM space
@@ -1744,7 +1775,7 @@ void exit_mmap(struct mm_struct *mm)
1744 kleave(""); 1775 kleave("");
1745} 1776}
1746 1777
1747unsigned long do_brk(unsigned long addr, unsigned long len) 1778unsigned long vm_brk(unsigned long addr, unsigned long len)
1748{ 1779{
1749 return -ENOMEM; 1780 return -ENOMEM;
1750} 1781}
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 33c332bbab73..1a518684a32f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2107,12 +2107,7 @@ restart:
2107 * with multiple processes reclaiming pages, the total 2107 * with multiple processes reclaiming pages, the total
2108 * freeing target can get unreasonably large. 2108 * freeing target can get unreasonably large.
2109 */ 2109 */
2110 if (nr_reclaimed >= nr_to_reclaim) 2110 if (nr_reclaimed >= nr_to_reclaim && priority < DEF_PRIORITY)
2111 nr_to_reclaim = 0;
2112 else
2113 nr_to_reclaim -= nr_reclaimed;
2114
2115 if (!nr_to_reclaim && priority < DEF_PRIORITY)
2116 break; 2111 break;
2117 } 2112 }
2118 blk_finish_plug(&plug); 2113 blk_finish_plug(&plug);