diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 9 | ||||
-rw-r--r-- | mm/oom_kill.c | 62 | ||||
-rw-r--r-- | mm/page_alloc.c | 28 | ||||
-rw-r--r-- | mm/readahead.c | 1 | ||||
-rw-r--r-- | mm/shmem.c | 2 | ||||
-rw-r--r-- | mm/slab.c | 18 | ||||
-rw-r--r-- | mm/vmscan.c | 8 |
7 files changed, 65 insertions, 63 deletions
@@ -61,7 +61,7 @@ pgprot_t protection_map[16] = { | |||
61 | 61 | ||
62 | int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */ | 62 | int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */ |
63 | int sysctl_overcommit_ratio = 50; /* default is 50% */ | 63 | int sysctl_overcommit_ratio = 50; /* default is 50% */ |
64 | int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT; | 64 | int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT; |
65 | atomic_t vm_committed_space = ATOMIC_INIT(0); | 65 | atomic_t vm_committed_space = ATOMIC_INIT(0); |
66 | 66 | ||
67 | /* | 67 | /* |
@@ -203,13 +203,6 @@ static void remove_vm_struct(struct vm_area_struct *vma) | |||
203 | kmem_cache_free(vm_area_cachep, vma); | 203 | kmem_cache_free(vm_area_cachep, vma); |
204 | } | 204 | } |
205 | 205 | ||
206 | /* | ||
207 | * sys_brk() for the most part doesn't need the global kernel | ||
208 | * lock, except when an application is doing something nasty | ||
209 | * like trying to un-brk an area that has already been mapped | ||
210 | * to a regular file. in this case, the unmapping will need | ||
211 | * to invoke file system routines that need the global lock. | ||
212 | */ | ||
213 | asmlinkage unsigned long sys_brk(unsigned long brk) | 206 | asmlinkage unsigned long sys_brk(unsigned long brk) |
214 | { | 207 | { |
215 | unsigned long rlim, retval; | 208 | unsigned long rlim, retval; |
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 1e56076672f5..5ec8da12cfd9 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -6,8 +6,8 @@ | |||
6 | * for goading me into coding this file... | 6 | * for goading me into coding this file... |
7 | * | 7 | * |
8 | * The routines in this file are used to kill a process when | 8 | * The routines in this file are used to kill a process when |
9 | * we're seriously out of memory. This gets called from kswapd() | 9 | * we're seriously out of memory. This gets called from __alloc_pages() |
10 | * in linux/mm/vmscan.c when we really run out of memory. | 10 | * in mm/page_alloc.c when we really run out of memory. |
11 | * | 11 | * |
12 | * Since we won't call these routines often (on a well-configured | 12 | * Since we won't call these routines often (on a well-configured |
13 | * machine) this file will double as a 'coding guide' and a signpost | 13 | * machine) this file will double as a 'coding guide' and a signpost |
@@ -20,13 +20,14 @@ | |||
20 | #include <linux/swap.h> | 20 | #include <linux/swap.h> |
21 | #include <linux/timex.h> | 21 | #include <linux/timex.h> |
22 | #include <linux/jiffies.h> | 22 | #include <linux/jiffies.h> |
23 | #include <linux/cpuset.h> | ||
23 | 24 | ||
24 | /* #define DEBUG */ | 25 | /* #define DEBUG */ |
25 | 26 | ||
26 | /** | 27 | /** |
27 | * oom_badness - calculate a numeric value for how bad this task has been | 28 | * oom_badness - calculate a numeric value for how bad this task has been |
28 | * @p: task struct of which task we should calculate | 29 | * @p: task struct of which task we should calculate |
29 | * @p: current uptime in seconds | 30 | * @uptime: current uptime in seconds |
30 | * | 31 | * |
31 | * The formula used is relatively simple and documented inline in the | 32 | * The formula used is relatively simple and documented inline in the |
32 | * function. The main rationale is that we want to select a good task | 33 | * function. The main rationale is that we want to select a good task |
@@ -57,9 +58,9 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) | |||
57 | 58 | ||
58 | /* | 59 | /* |
59 | * Processes which fork a lot of child processes are likely | 60 | * Processes which fork a lot of child processes are likely |
60 | * a good choice. We add the vmsize of the childs if they | 61 | * a good choice. We add the vmsize of the children if they |
61 | * have an own mm. This prevents forking servers to flood the | 62 | * have an own mm. This prevents forking servers to flood the |
62 | * machine with an endless amount of childs | 63 | * machine with an endless amount of children |
63 | */ | 64 | */ |
64 | list_for_each(tsk, &p->children) { | 65 | list_for_each(tsk, &p->children) { |
65 | struct task_struct *chld; | 66 | struct task_struct *chld; |
@@ -143,28 +144,36 @@ static struct task_struct * select_bad_process(void) | |||
143 | struct timespec uptime; | 144 | struct timespec uptime; |
144 | 145 | ||
145 | do_posix_clock_monotonic_gettime(&uptime); | 146 | do_posix_clock_monotonic_gettime(&uptime); |
146 | do_each_thread(g, p) | 147 | do_each_thread(g, p) { |
148 | unsigned long points; | ||
149 | int releasing; | ||
150 | |||
147 | /* skip the init task with pid == 1 */ | 151 | /* skip the init task with pid == 1 */ |
148 | if (p->pid > 1 && p->oomkilladj != OOM_DISABLE) { | 152 | if (p->pid == 1) |
149 | unsigned long points; | 153 | continue; |
150 | 154 | if (p->oomkilladj == OOM_DISABLE) | |
151 | /* | 155 | continue; |
152 | * This is in the process of releasing memory so wait it | 156 | /* If p's nodes don't overlap ours, it won't help to kill p. */ |
153 | * to finish before killing some other task by mistake. | 157 | if (!cpuset_excl_nodes_overlap(p)) |
154 | */ | 158 | continue; |
155 | if ((unlikely(test_tsk_thread_flag(p, TIF_MEMDIE)) || (p->flags & PF_EXITING)) && | 159 | |
156 | !(p->flags & PF_DEAD)) | 160 | /* |
157 | return ERR_PTR(-1UL); | 161 | * This is in the process of releasing memory so for wait it |
158 | if (p->flags & PF_SWAPOFF) | 162 | * to finish before killing some other task by mistake. |
159 | return p; | 163 | */ |
160 | 164 | releasing = test_tsk_thread_flag(p, TIF_MEMDIE) || | |
161 | points = badness(p, uptime.tv_sec); | 165 | p->flags & PF_EXITING; |
162 | if (points > maxpoints || !chosen) { | 166 | if (releasing && !(p->flags & PF_DEAD)) |
163 | chosen = p; | 167 | return ERR_PTR(-1UL); |
164 | maxpoints = points; | 168 | if (p->flags & PF_SWAPOFF) |
165 | } | 169 | return p; |
170 | |||
171 | points = badness(p, uptime.tv_sec); | ||
172 | if (points > maxpoints || !chosen) { | ||
173 | chosen = p; | ||
174 | maxpoints = points; | ||
166 | } | 175 | } |
167 | while_each_thread(g, p); | 176 | } while_each_thread(g, p); |
168 | return chosen; | 177 | return chosen; |
169 | } | 178 | } |
170 | 179 | ||
@@ -189,7 +198,8 @@ static void __oom_kill_task(task_t *p) | |||
189 | return; | 198 | return; |
190 | } | 199 | } |
191 | task_unlock(p); | 200 | task_unlock(p); |
192 | printk(KERN_ERR "Out of Memory: Killed process %d (%s).\n", p->pid, p->comm); | 201 | printk(KERN_ERR "Out of Memory: Killed process %d (%s).\n", |
202 | p->pid, p->comm); | ||
193 | 203 | ||
194 | /* | 204 | /* |
195 | * We give our sacrificial lamb high priority and access to | 205 | * We give our sacrificial lamb high priority and access to |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b06a9636d971..3974fd81d27c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -42,13 +42,13 @@ | |||
42 | * MCD - HACK: Find somewhere to initialize this EARLY, or make this | 42 | * MCD - HACK: Find somewhere to initialize this EARLY, or make this |
43 | * initializer cleaner | 43 | * initializer cleaner |
44 | */ | 44 | */ |
45 | nodemask_t node_online_map = { { [0] = 1UL } }; | 45 | nodemask_t node_online_map __read_mostly = { { [0] = 1UL } }; |
46 | EXPORT_SYMBOL(node_online_map); | 46 | EXPORT_SYMBOL(node_online_map); |
47 | nodemask_t node_possible_map = NODE_MASK_ALL; | 47 | nodemask_t node_possible_map __read_mostly = NODE_MASK_ALL; |
48 | EXPORT_SYMBOL(node_possible_map); | 48 | EXPORT_SYMBOL(node_possible_map); |
49 | struct pglist_data *pgdat_list; | 49 | struct pglist_data *pgdat_list __read_mostly; |
50 | unsigned long totalram_pages; | 50 | unsigned long totalram_pages __read_mostly; |
51 | unsigned long totalhigh_pages; | 51 | unsigned long totalhigh_pages __read_mostly; |
52 | long nr_swap_pages; | 52 | long nr_swap_pages; |
53 | 53 | ||
54 | /* | 54 | /* |
@@ -68,7 +68,7 @@ EXPORT_SYMBOL(nr_swap_pages); | |||
68 | * Used by page_zone() to look up the address of the struct zone whose | 68 | * Used by page_zone() to look up the address of the struct zone whose |
69 | * id is encoded in the upper bits of page->flags | 69 | * id is encoded in the upper bits of page->flags |
70 | */ | 70 | */ |
71 | struct zone *zone_table[1 << ZONETABLE_SHIFT]; | 71 | struct zone *zone_table[1 << ZONETABLE_SHIFT] __read_mostly; |
72 | EXPORT_SYMBOL(zone_table); | 72 | EXPORT_SYMBOL(zone_table); |
73 | 73 | ||
74 | static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" }; | 74 | static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" }; |
@@ -806,11 +806,14 @@ __alloc_pages(unsigned int __nocast gfp_mask, unsigned int order, | |||
806 | classzone_idx = zone_idx(zones[0]); | 806 | classzone_idx = zone_idx(zones[0]); |
807 | 807 | ||
808 | restart: | 808 | restart: |
809 | /* Go through the zonelist once, looking for a zone with enough free */ | 809 | /* |
810 | * Go through the zonelist once, looking for a zone with enough free. | ||
811 | * See also cpuset_zone_allowed() comment in kernel/cpuset.c. | ||
812 | */ | ||
810 | for (i = 0; (z = zones[i]) != NULL; i++) { | 813 | for (i = 0; (z = zones[i]) != NULL; i++) { |
811 | int do_reclaim = should_reclaim_zone(z, gfp_mask); | 814 | int do_reclaim = should_reclaim_zone(z, gfp_mask); |
812 | 815 | ||
813 | if (!cpuset_zone_allowed(z)) | 816 | if (!cpuset_zone_allowed(z, __GFP_HARDWALL)) |
814 | continue; | 817 | continue; |
815 | 818 | ||
816 | /* | 819 | /* |
@@ -845,6 +848,7 @@ zone_reclaim_retry: | |||
845 | * | 848 | * |
846 | * This is the last chance, in general, before the goto nopage. | 849 | * This is the last chance, in general, before the goto nopage. |
847 | * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc. | 850 | * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc. |
851 | * See also cpuset_zone_allowed() comment in kernel/cpuset.c. | ||
848 | */ | 852 | */ |
849 | for (i = 0; (z = zones[i]) != NULL; i++) { | 853 | for (i = 0; (z = zones[i]) != NULL; i++) { |
850 | if (!zone_watermark_ok(z, order, z->pages_min, | 854 | if (!zone_watermark_ok(z, order, z->pages_min, |
@@ -852,7 +856,7 @@ zone_reclaim_retry: | |||
852 | gfp_mask & __GFP_HIGH)) | 856 | gfp_mask & __GFP_HIGH)) |
853 | continue; | 857 | continue; |
854 | 858 | ||
855 | if (wait && !cpuset_zone_allowed(z)) | 859 | if (wait && !cpuset_zone_allowed(z, gfp_mask)) |
856 | continue; | 860 | continue; |
857 | 861 | ||
858 | page = buffered_rmqueue(z, order, gfp_mask); | 862 | page = buffered_rmqueue(z, order, gfp_mask); |
@@ -867,7 +871,7 @@ zone_reclaim_retry: | |||
867 | if (!(gfp_mask & __GFP_NOMEMALLOC)) { | 871 | if (!(gfp_mask & __GFP_NOMEMALLOC)) { |
868 | /* go through the zonelist yet again, ignoring mins */ | 872 | /* go through the zonelist yet again, ignoring mins */ |
869 | for (i = 0; (z = zones[i]) != NULL; i++) { | 873 | for (i = 0; (z = zones[i]) != NULL; i++) { |
870 | if (!cpuset_zone_allowed(z)) | 874 | if (!cpuset_zone_allowed(z, gfp_mask)) |
871 | continue; | 875 | continue; |
872 | page = buffered_rmqueue(z, order, gfp_mask); | 876 | page = buffered_rmqueue(z, order, gfp_mask); |
873 | if (page) | 877 | if (page) |
@@ -903,7 +907,7 @@ rebalance: | |||
903 | gfp_mask & __GFP_HIGH)) | 907 | gfp_mask & __GFP_HIGH)) |
904 | continue; | 908 | continue; |
905 | 909 | ||
906 | if (!cpuset_zone_allowed(z)) | 910 | if (!cpuset_zone_allowed(z, gfp_mask)) |
907 | continue; | 911 | continue; |
908 | 912 | ||
909 | page = buffered_rmqueue(z, order, gfp_mask); | 913 | page = buffered_rmqueue(z, order, gfp_mask); |
@@ -922,7 +926,7 @@ rebalance: | |||
922 | classzone_idx, 0, 0)) | 926 | classzone_idx, 0, 0)) |
923 | continue; | 927 | continue; |
924 | 928 | ||
925 | if (!cpuset_zone_allowed(z)) | 929 | if (!cpuset_zone_allowed(z, __GFP_HARDWALL)) |
926 | continue; | 930 | continue; |
927 | 931 | ||
928 | page = buffered_rmqueue(z, order, gfp_mask); | 932 | page = buffered_rmqueue(z, order, gfp_mask); |
diff --git a/mm/readahead.c b/mm/readahead.c index b840e7c6ea74..d0b50034e245 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
@@ -540,6 +540,7 @@ void handle_ra_miss(struct address_space *mapping, | |||
540 | { | 540 | { |
541 | ra->flags |= RA_FLAG_MISS; | 541 | ra->flags |= RA_FLAG_MISS; |
542 | ra->flags &= ~RA_FLAG_INCACHE; | 542 | ra->flags &= ~RA_FLAG_INCACHE; |
543 | ra->cache_hit = 0; | ||
543 | } | 544 | } |
544 | 545 | ||
545 | /* | 546 | /* |
diff --git a/mm/shmem.c b/mm/shmem.c index bdc4bbb6ddbb..db2c9e8d9909 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -180,7 +180,7 @@ static struct inode_operations shmem_inode_operations; | |||
180 | static struct inode_operations shmem_dir_inode_operations; | 180 | static struct inode_operations shmem_dir_inode_operations; |
181 | static struct vm_operations_struct shmem_vm_ops; | 181 | static struct vm_operations_struct shmem_vm_ops; |
182 | 182 | ||
183 | static struct backing_dev_info shmem_backing_dev_info = { | 183 | static struct backing_dev_info shmem_backing_dev_info __read_mostly = { |
184 | .ra_pages = 0, /* No readahead */ | 184 | .ra_pages = 0, /* No readahead */ |
185 | .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, | 185 | .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, |
186 | .unplug_io_fn = default_unplug_io_fn, | 186 | .unplug_io_fn = default_unplug_io_fn, |
@@ -2558,24 +2558,18 @@ void kmem_cache_free(kmem_cache_t *cachep, void *objp) | |||
2558 | EXPORT_SYMBOL(kmem_cache_free); | 2558 | EXPORT_SYMBOL(kmem_cache_free); |
2559 | 2559 | ||
2560 | /** | 2560 | /** |
2561 | * kcalloc - allocate memory for an array. The memory is set to zero. | 2561 | * kzalloc - allocate memory. The memory is set to zero. |
2562 | * @n: number of elements. | 2562 | * @size: how many bytes of memory are required. |
2563 | * @size: element size. | ||
2564 | * @flags: the type of memory to allocate. | 2563 | * @flags: the type of memory to allocate. |
2565 | */ | 2564 | */ |
2566 | void *kcalloc(size_t n, size_t size, unsigned int __nocast flags) | 2565 | void *kzalloc(size_t size, unsigned int __nocast flags) |
2567 | { | 2566 | { |
2568 | void *ret = NULL; | 2567 | void *ret = kmalloc(size, flags); |
2569 | |||
2570 | if (n != 0 && size > INT_MAX / n) | ||
2571 | return ret; | ||
2572 | |||
2573 | ret = kmalloc(n * size, flags); | ||
2574 | if (ret) | 2568 | if (ret) |
2575 | memset(ret, 0, n * size); | 2569 | memset(ret, 0, size); |
2576 | return ret; | 2570 | return ret; |
2577 | } | 2571 | } |
2578 | EXPORT_SYMBOL(kcalloc); | 2572 | EXPORT_SYMBOL(kzalloc); |
2579 | 2573 | ||
2580 | /** | 2574 | /** |
2581 | * kfree - free previously allocated memory | 2575 | * kfree - free previously allocated memory |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 0095533cdde9..a740778f688d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -894,7 +894,7 @@ shrink_caches(struct zone **zones, struct scan_control *sc) | |||
894 | if (zone->present_pages == 0) | 894 | if (zone->present_pages == 0) |
895 | continue; | 895 | continue; |
896 | 896 | ||
897 | if (!cpuset_zone_allowed(zone)) | 897 | if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) |
898 | continue; | 898 | continue; |
899 | 899 | ||
900 | zone->temp_priority = sc->priority; | 900 | zone->temp_priority = sc->priority; |
@@ -940,7 +940,7 @@ int try_to_free_pages(struct zone **zones, unsigned int gfp_mask) | |||
940 | for (i = 0; zones[i] != NULL; i++) { | 940 | for (i = 0; zones[i] != NULL; i++) { |
941 | struct zone *zone = zones[i]; | 941 | struct zone *zone = zones[i]; |
942 | 942 | ||
943 | if (!cpuset_zone_allowed(zone)) | 943 | if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) |
944 | continue; | 944 | continue; |
945 | 945 | ||
946 | zone->temp_priority = DEF_PRIORITY; | 946 | zone->temp_priority = DEF_PRIORITY; |
@@ -986,7 +986,7 @@ out: | |||
986 | for (i = 0; zones[i] != 0; i++) { | 986 | for (i = 0; zones[i] != 0; i++) { |
987 | struct zone *zone = zones[i]; | 987 | struct zone *zone = zones[i]; |
988 | 988 | ||
989 | if (!cpuset_zone_allowed(zone)) | 989 | if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) |
990 | continue; | 990 | continue; |
991 | 991 | ||
992 | zone->prev_priority = zone->temp_priority; | 992 | zone->prev_priority = zone->temp_priority; |
@@ -1256,7 +1256,7 @@ void wakeup_kswapd(struct zone *zone, int order) | |||
1256 | return; | 1256 | return; |
1257 | if (pgdat->kswapd_max_order < order) | 1257 | if (pgdat->kswapd_max_order < order) |
1258 | pgdat->kswapd_max_order = order; | 1258 | pgdat->kswapd_max_order = order; |
1259 | if (!cpuset_zone_allowed(zone)) | 1259 | if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) |
1260 | return; | 1260 | return; |
1261 | if (!waitqueue_active(&zone->zone_pgdat->kswapd_wait)) | 1261 | if (!waitqueue_active(&zone->zone_pgdat->kswapd_wait)) |
1262 | return; | 1262 | return; |