diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/backing-dev.c | 52 | ||||
-rw-r--r-- | mm/compaction.c | 156 | ||||
-rw-r--r-- | mm/filemap.c | 7 | ||||
-rw-r--r-- | mm/huge_memory.c | 1 | ||||
-rw-r--r-- | mm/internal.h | 1 | ||||
-rw-r--r-- | mm/memblock.c | 2 | ||||
-rw-r--r-- | mm/memory_hotplug.c | 16 | ||||
-rw-r--r-- | mm/mempolicy.c | 2 | ||||
-rw-r--r-- | mm/mmap.c | 7 | ||||
-rw-r--r-- | mm/page-writeback.c | 1 | ||||
-rw-r--r-- | mm/page_alloc.c | 40 | ||||
-rw-r--r-- | mm/slab.c | 95 | ||||
-rw-r--r-- | mm/slob.c | 31 | ||||
-rw-r--r-- | mm/slub.c | 45 | ||||
-rw-r--r-- | mm/vmscan.c | 1 |
15 files changed, 247 insertions, 210 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 6b4718e2ee34..b41823cc05e6 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c | |||
@@ -39,12 +39,6 @@ DEFINE_SPINLOCK(bdi_lock); | |||
39 | LIST_HEAD(bdi_list); | 39 | LIST_HEAD(bdi_list); |
40 | LIST_HEAD(bdi_pending_list); | 40 | LIST_HEAD(bdi_pending_list); |
41 | 41 | ||
42 | static struct task_struct *sync_supers_tsk; | ||
43 | static struct timer_list sync_supers_timer; | ||
44 | |||
45 | static int bdi_sync_supers(void *); | ||
46 | static void sync_supers_timer_fn(unsigned long); | ||
47 | |||
48 | void bdi_lock_two(struct bdi_writeback *wb1, struct bdi_writeback *wb2) | 42 | void bdi_lock_two(struct bdi_writeback *wb1, struct bdi_writeback *wb2) |
49 | { | 43 | { |
50 | if (wb1 < wb2) { | 44 | if (wb1 < wb2) { |
@@ -250,12 +244,6 @@ static int __init default_bdi_init(void) | |||
250 | { | 244 | { |
251 | int err; | 245 | int err; |
252 | 246 | ||
253 | sync_supers_tsk = kthread_run(bdi_sync_supers, NULL, "sync_supers"); | ||
254 | BUG_ON(IS_ERR(sync_supers_tsk)); | ||
255 | |||
256 | setup_timer(&sync_supers_timer, sync_supers_timer_fn, 0); | ||
257 | bdi_arm_supers_timer(); | ||
258 | |||
259 | err = bdi_init(&default_backing_dev_info); | 247 | err = bdi_init(&default_backing_dev_info); |
260 | if (!err) | 248 | if (!err) |
261 | bdi_register(&default_backing_dev_info, NULL, "default"); | 249 | bdi_register(&default_backing_dev_info, NULL, "default"); |
@@ -270,46 +258,6 @@ int bdi_has_dirty_io(struct backing_dev_info *bdi) | |||
270 | return wb_has_dirty_io(&bdi->wb); | 258 | return wb_has_dirty_io(&bdi->wb); |
271 | } | 259 | } |
272 | 260 | ||
273 | /* | ||
274 | * kupdated() used to do this. We cannot do it from the bdi_forker_thread() | ||
275 | * or we risk deadlocking on ->s_umount. The longer term solution would be | ||
276 | * to implement sync_supers_bdi() or similar and simply do it from the | ||
277 | * bdi writeback thread individually. | ||
278 | */ | ||
279 | static int bdi_sync_supers(void *unused) | ||
280 | { | ||
281 | set_user_nice(current, 0); | ||
282 | |||
283 | while (!kthread_should_stop()) { | ||
284 | set_current_state(TASK_INTERRUPTIBLE); | ||
285 | schedule(); | ||
286 | |||
287 | /* | ||
288 | * Do this periodically, like kupdated() did before. | ||
289 | */ | ||
290 | sync_supers(); | ||
291 | } | ||
292 | |||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | void bdi_arm_supers_timer(void) | ||
297 | { | ||
298 | unsigned long next; | ||
299 | |||
300 | if (!dirty_writeback_interval) | ||
301 | return; | ||
302 | |||
303 | next = msecs_to_jiffies(dirty_writeback_interval * 10) + jiffies; | ||
304 | mod_timer(&sync_supers_timer, round_jiffies_up(next)); | ||
305 | } | ||
306 | |||
307 | static void sync_supers_timer_fn(unsigned long unused) | ||
308 | { | ||
309 | wake_up_process(sync_supers_tsk); | ||
310 | bdi_arm_supers_timer(); | ||
311 | } | ||
312 | |||
313 | static void wakeup_timer_fn(unsigned long data) | 261 | static void wakeup_timer_fn(unsigned long data) |
314 | { | 262 | { |
315 | struct backing_dev_info *bdi = (struct backing_dev_info *)data; | 263 | struct backing_dev_info *bdi = (struct backing_dev_info *)data; |
diff --git a/mm/compaction.c b/mm/compaction.c index e78cb9688421..7fcd3a52e68d 100644 --- a/mm/compaction.c +++ b/mm/compaction.c | |||
@@ -51,6 +51,47 @@ static inline bool migrate_async_suitable(int migratetype) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | /* | 53 | /* |
54 | * Compaction requires the taking of some coarse locks that are potentially | ||
55 | * very heavily contended. Check if the process needs to be scheduled or | ||
56 | * if the lock is contended. For async compaction, back out in the event | ||
57 | * if contention is severe. For sync compaction, schedule. | ||
58 | * | ||
59 | * Returns true if the lock is held. | ||
60 | * Returns false if the lock is released and compaction should abort | ||
61 | */ | ||
62 | static bool compact_checklock_irqsave(spinlock_t *lock, unsigned long *flags, | ||
63 | bool locked, struct compact_control *cc) | ||
64 | { | ||
65 | if (need_resched() || spin_is_contended(lock)) { | ||
66 | if (locked) { | ||
67 | spin_unlock_irqrestore(lock, *flags); | ||
68 | locked = false; | ||
69 | } | ||
70 | |||
71 | /* async aborts if taking too long or contended */ | ||
72 | if (!cc->sync) { | ||
73 | if (cc->contended) | ||
74 | *cc->contended = true; | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | cond_resched(); | ||
79 | if (fatal_signal_pending(current)) | ||
80 | return false; | ||
81 | } | ||
82 | |||
83 | if (!locked) | ||
84 | spin_lock_irqsave(lock, *flags); | ||
85 | return true; | ||
86 | } | ||
87 | |||
88 | static inline bool compact_trylock_irqsave(spinlock_t *lock, | ||
89 | unsigned long *flags, struct compact_control *cc) | ||
90 | { | ||
91 | return compact_checklock_irqsave(lock, flags, false, cc); | ||
92 | } | ||
93 | |||
94 | /* | ||
54 | * Isolate free pages onto a private freelist. Caller must hold zone->lock. | 95 | * Isolate free pages onto a private freelist. Caller must hold zone->lock. |
55 | * If @strict is true, will abort returning 0 on any invalid PFNs or non-free | 96 | * If @strict is true, will abort returning 0 on any invalid PFNs or non-free |
56 | * pages inside of the pageblock (even though it may still end up isolating | 97 | * pages inside of the pageblock (even though it may still end up isolating |
@@ -173,7 +214,7 @@ isolate_freepages_range(unsigned long start_pfn, unsigned long end_pfn) | |||
173 | } | 214 | } |
174 | 215 | ||
175 | /* Update the number of anon and file isolated pages in the zone */ | 216 | /* Update the number of anon and file isolated pages in the zone */ |
176 | static void acct_isolated(struct zone *zone, struct compact_control *cc) | 217 | static void acct_isolated(struct zone *zone, bool locked, struct compact_control *cc) |
177 | { | 218 | { |
178 | struct page *page; | 219 | struct page *page; |
179 | unsigned int count[2] = { 0, }; | 220 | unsigned int count[2] = { 0, }; |
@@ -181,8 +222,14 @@ static void acct_isolated(struct zone *zone, struct compact_control *cc) | |||
181 | list_for_each_entry(page, &cc->migratepages, lru) | 222 | list_for_each_entry(page, &cc->migratepages, lru) |
182 | count[!!page_is_file_cache(page)]++; | 223 | count[!!page_is_file_cache(page)]++; |
183 | 224 | ||
184 | __mod_zone_page_state(zone, NR_ISOLATED_ANON, count[0]); | 225 | /* If locked we can use the interrupt unsafe versions */ |
185 | __mod_zone_page_state(zone, NR_ISOLATED_FILE, count[1]); | 226 | if (locked) { |
227 | __mod_zone_page_state(zone, NR_ISOLATED_ANON, count[0]); | ||
228 | __mod_zone_page_state(zone, NR_ISOLATED_FILE, count[1]); | ||
229 | } else { | ||
230 | mod_zone_page_state(zone, NR_ISOLATED_ANON, count[0]); | ||
231 | mod_zone_page_state(zone, NR_ISOLATED_FILE, count[1]); | ||
232 | } | ||
186 | } | 233 | } |
187 | 234 | ||
188 | /* Similar to reclaim, but different enough that they don't share logic */ | 235 | /* Similar to reclaim, but different enough that they don't share logic */ |
@@ -228,6 +275,8 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc, | |||
228 | struct list_head *migratelist = &cc->migratepages; | 275 | struct list_head *migratelist = &cc->migratepages; |
229 | isolate_mode_t mode = 0; | 276 | isolate_mode_t mode = 0; |
230 | struct lruvec *lruvec; | 277 | struct lruvec *lruvec; |
278 | unsigned long flags; | ||
279 | bool locked; | ||
231 | 280 | ||
232 | /* | 281 | /* |
233 | * Ensure that there are not too many pages isolated from the LRU | 282 | * Ensure that there are not too many pages isolated from the LRU |
@@ -247,25 +296,22 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc, | |||
247 | 296 | ||
248 | /* Time to isolate some pages for migration */ | 297 | /* Time to isolate some pages for migration */ |
249 | cond_resched(); | 298 | cond_resched(); |
250 | spin_lock_irq(&zone->lru_lock); | 299 | spin_lock_irqsave(&zone->lru_lock, flags); |
300 | locked = true; | ||
251 | for (; low_pfn < end_pfn; low_pfn++) { | 301 | for (; low_pfn < end_pfn; low_pfn++) { |
252 | struct page *page; | 302 | struct page *page; |
253 | bool locked = true; | ||
254 | 303 | ||
255 | /* give a chance to irqs before checking need_resched() */ | 304 | /* give a chance to irqs before checking need_resched() */ |
256 | if (!((low_pfn+1) % SWAP_CLUSTER_MAX)) { | 305 | if (!((low_pfn+1) % SWAP_CLUSTER_MAX)) { |
257 | spin_unlock_irq(&zone->lru_lock); | 306 | spin_unlock_irqrestore(&zone->lru_lock, flags); |
258 | locked = false; | 307 | locked = false; |
259 | } | 308 | } |
260 | if (need_resched() || spin_is_contended(&zone->lru_lock)) { | 309 | |
261 | if (locked) | 310 | /* Check if it is ok to still hold the lock */ |
262 | spin_unlock_irq(&zone->lru_lock); | 311 | locked = compact_checklock_irqsave(&zone->lru_lock, &flags, |
263 | cond_resched(); | 312 | locked, cc); |
264 | spin_lock_irq(&zone->lru_lock); | 313 | if (!locked) |
265 | if (fatal_signal_pending(current)) | 314 | break; |
266 | break; | ||
267 | } else if (!locked) | ||
268 | spin_lock_irq(&zone->lru_lock); | ||
269 | 315 | ||
270 | /* | 316 | /* |
271 | * migrate_pfn does not necessarily start aligned to a | 317 | * migrate_pfn does not necessarily start aligned to a |
@@ -349,9 +395,10 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc, | |||
349 | } | 395 | } |
350 | } | 396 | } |
351 | 397 | ||
352 | acct_isolated(zone, cc); | 398 | acct_isolated(zone, locked, cc); |
353 | 399 | ||
354 | spin_unlock_irq(&zone->lru_lock); | 400 | if (locked) |
401 | spin_unlock_irqrestore(&zone->lru_lock, flags); | ||
355 | 402 | ||
356 | trace_mm_compaction_isolate_migratepages(nr_scanned, nr_isolated); | 403 | trace_mm_compaction_isolate_migratepages(nr_scanned, nr_isolated); |
357 | 404 | ||
@@ -384,6 +431,20 @@ static bool suitable_migration_target(struct page *page) | |||
384 | } | 431 | } |
385 | 432 | ||
386 | /* | 433 | /* |
434 | * Returns the start pfn of the last page block in a zone. This is the starting | ||
435 | * point for full compaction of a zone. Compaction searches for free pages from | ||
436 | * the end of each zone, while isolate_freepages_block scans forward inside each | ||
437 | * page block. | ||
438 | */ | ||
439 | static unsigned long start_free_pfn(struct zone *zone) | ||
440 | { | ||
441 | unsigned long free_pfn; | ||
442 | free_pfn = zone->zone_start_pfn + zone->spanned_pages; | ||
443 | free_pfn &= ~(pageblock_nr_pages-1); | ||
444 | return free_pfn; | ||
445 | } | ||
446 | |||
447 | /* | ||
387 | * Based on information in the current compact_control, find blocks | 448 | * Based on information in the current compact_control, find blocks |
388 | * suitable for isolating free pages from and then isolate them. | 449 | * suitable for isolating free pages from and then isolate them. |
389 | */ | 450 | */ |
@@ -422,17 +483,6 @@ static void isolate_freepages(struct zone *zone, | |||
422 | pfn -= pageblock_nr_pages) { | 483 | pfn -= pageblock_nr_pages) { |
423 | unsigned long isolated; | 484 | unsigned long isolated; |
424 | 485 | ||
425 | /* | ||
426 | * Skip ahead if another thread is compacting in the area | ||
427 | * simultaneously. If we wrapped around, we can only skip | ||
428 | * ahead if zone->compact_cached_free_pfn also wrapped to | ||
429 | * above our starting point. | ||
430 | */ | ||
431 | if (cc->order > 0 && (!cc->wrapped || | ||
432 | zone->compact_cached_free_pfn > | ||
433 | cc->start_free_pfn)) | ||
434 | pfn = min(pfn, zone->compact_cached_free_pfn); | ||
435 | |||
436 | if (!pfn_valid(pfn)) | 486 | if (!pfn_valid(pfn)) |
437 | continue; | 487 | continue; |
438 | 488 | ||
@@ -458,7 +508,16 @@ static void isolate_freepages(struct zone *zone, | |||
458 | * are disabled | 508 | * are disabled |
459 | */ | 509 | */ |
460 | isolated = 0; | 510 | isolated = 0; |
461 | spin_lock_irqsave(&zone->lock, flags); | 511 | |
512 | /* | ||
513 | * The zone lock must be held to isolate freepages. This | ||
514 | * unfortunately this is a very coarse lock and can be | ||
515 | * heavily contended if there are parallel allocations | ||
516 | * or parallel compactions. For async compaction do not | ||
517 | * spin on the lock | ||
518 | */ | ||
519 | if (!compact_trylock_irqsave(&zone->lock, &flags, cc)) | ||
520 | break; | ||
462 | if (suitable_migration_target(page)) { | 521 | if (suitable_migration_target(page)) { |
463 | end_pfn = min(pfn + pageblock_nr_pages, zone_end_pfn); | 522 | end_pfn = min(pfn + pageblock_nr_pages, zone_end_pfn); |
464 | isolated = isolate_freepages_block(pfn, end_pfn, | 523 | isolated = isolate_freepages_block(pfn, end_pfn, |
@@ -474,7 +533,15 @@ static void isolate_freepages(struct zone *zone, | |||
474 | */ | 533 | */ |
475 | if (isolated) { | 534 | if (isolated) { |
476 | high_pfn = max(high_pfn, pfn); | 535 | high_pfn = max(high_pfn, pfn); |
477 | if (cc->order > 0) | 536 | |
537 | /* | ||
538 | * If the free scanner has wrapped, update | ||
539 | * compact_cached_free_pfn to point to the highest | ||
540 | * pageblock with free pages. This reduces excessive | ||
541 | * scanning of full pageblocks near the end of the | ||
542 | * zone | ||
543 | */ | ||
544 | if (cc->order > 0 && cc->wrapped) | ||
478 | zone->compact_cached_free_pfn = high_pfn; | 545 | zone->compact_cached_free_pfn = high_pfn; |
479 | } | 546 | } |
480 | } | 547 | } |
@@ -484,6 +551,11 @@ static void isolate_freepages(struct zone *zone, | |||
484 | 551 | ||
485 | cc->free_pfn = high_pfn; | 552 | cc->free_pfn = high_pfn; |
486 | cc->nr_freepages = nr_freepages; | 553 | cc->nr_freepages = nr_freepages; |
554 | |||
555 | /* If compact_cached_free_pfn is reset then set it now */ | ||
556 | if (cc->order > 0 && !cc->wrapped && | ||
557 | zone->compact_cached_free_pfn == start_free_pfn(zone)) | ||
558 | zone->compact_cached_free_pfn = high_pfn; | ||
487 | } | 559 | } |
488 | 560 | ||
489 | /* | 561 | /* |
@@ -570,20 +642,6 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone, | |||
570 | return ISOLATE_SUCCESS; | 642 | return ISOLATE_SUCCESS; |
571 | } | 643 | } |
572 | 644 | ||
573 | /* | ||
574 | * Returns the start pfn of the last page block in a zone. This is the starting | ||
575 | * point for full compaction of a zone. Compaction searches for free pages from | ||
576 | * the end of each zone, while isolate_freepages_block scans forward inside each | ||
577 | * page block. | ||
578 | */ | ||
579 | static unsigned long start_free_pfn(struct zone *zone) | ||
580 | { | ||
581 | unsigned long free_pfn; | ||
582 | free_pfn = zone->zone_start_pfn + zone->spanned_pages; | ||
583 | free_pfn &= ~(pageblock_nr_pages-1); | ||
584 | return free_pfn; | ||
585 | } | ||
586 | |||
587 | static int compact_finished(struct zone *zone, | 645 | static int compact_finished(struct zone *zone, |
588 | struct compact_control *cc) | 646 | struct compact_control *cc) |
589 | { | 647 | { |
@@ -771,7 +829,7 @@ out: | |||
771 | 829 | ||
772 | static unsigned long compact_zone_order(struct zone *zone, | 830 | static unsigned long compact_zone_order(struct zone *zone, |
773 | int order, gfp_t gfp_mask, | 831 | int order, gfp_t gfp_mask, |
774 | bool sync) | 832 | bool sync, bool *contended) |
775 | { | 833 | { |
776 | struct compact_control cc = { | 834 | struct compact_control cc = { |
777 | .nr_freepages = 0, | 835 | .nr_freepages = 0, |
@@ -780,6 +838,7 @@ static unsigned long compact_zone_order(struct zone *zone, | |||
780 | .migratetype = allocflags_to_migratetype(gfp_mask), | 838 | .migratetype = allocflags_to_migratetype(gfp_mask), |
781 | .zone = zone, | 839 | .zone = zone, |
782 | .sync = sync, | 840 | .sync = sync, |
841 | .contended = contended, | ||
783 | }; | 842 | }; |
784 | INIT_LIST_HEAD(&cc.freepages); | 843 | INIT_LIST_HEAD(&cc.freepages); |
785 | INIT_LIST_HEAD(&cc.migratepages); | 844 | INIT_LIST_HEAD(&cc.migratepages); |
@@ -801,7 +860,7 @@ int sysctl_extfrag_threshold = 500; | |||
801 | */ | 860 | */ |
802 | unsigned long try_to_compact_pages(struct zonelist *zonelist, | 861 | unsigned long try_to_compact_pages(struct zonelist *zonelist, |
803 | int order, gfp_t gfp_mask, nodemask_t *nodemask, | 862 | int order, gfp_t gfp_mask, nodemask_t *nodemask, |
804 | bool sync) | 863 | bool sync, bool *contended) |
805 | { | 864 | { |
806 | enum zone_type high_zoneidx = gfp_zone(gfp_mask); | 865 | enum zone_type high_zoneidx = gfp_zone(gfp_mask); |
807 | int may_enter_fs = gfp_mask & __GFP_FS; | 866 | int may_enter_fs = gfp_mask & __GFP_FS; |
@@ -825,7 +884,8 @@ unsigned long try_to_compact_pages(struct zonelist *zonelist, | |||
825 | nodemask) { | 884 | nodemask) { |
826 | int status; | 885 | int status; |
827 | 886 | ||
828 | status = compact_zone_order(zone, order, gfp_mask, sync); | 887 | status = compact_zone_order(zone, order, gfp_mask, sync, |
888 | contended); | ||
829 | rc = max(status, rc); | 889 | rc = max(status, rc); |
830 | 890 | ||
831 | /* If a normal allocation would succeed, stop compacting */ | 891 | /* If a normal allocation would succeed, stop compacting */ |
@@ -861,7 +921,7 @@ static int __compact_pgdat(pg_data_t *pgdat, struct compact_control *cc) | |||
861 | if (cc->order > 0) { | 921 | if (cc->order > 0) { |
862 | int ok = zone_watermark_ok(zone, cc->order, | 922 | int ok = zone_watermark_ok(zone, cc->order, |
863 | low_wmark_pages(zone), 0, 0); | 923 | low_wmark_pages(zone), 0, 0); |
864 | if (ok && cc->order > zone->compact_order_failed) | 924 | if (ok && cc->order >= zone->compact_order_failed) |
865 | zone->compact_order_failed = cc->order + 1; | 925 | zone->compact_order_failed = cc->order + 1; |
866 | /* Currently async compaction is never deferred. */ | 926 | /* Currently async compaction is never deferred. */ |
867 | else if (!ok && cc->sync) | 927 | else if (!ok && cc->sync) |
diff --git a/mm/filemap.c b/mm/filemap.c index fa5ca304148e..384344575c37 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1412,12 +1412,8 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, | |||
1412 | retval = filemap_write_and_wait_range(mapping, pos, | 1412 | retval = filemap_write_and_wait_range(mapping, pos, |
1413 | pos + iov_length(iov, nr_segs) - 1); | 1413 | pos + iov_length(iov, nr_segs) - 1); |
1414 | if (!retval) { | 1414 | if (!retval) { |
1415 | struct blk_plug plug; | ||
1416 | |||
1417 | blk_start_plug(&plug); | ||
1418 | retval = mapping->a_ops->direct_IO(READ, iocb, | 1415 | retval = mapping->a_ops->direct_IO(READ, iocb, |
1419 | iov, pos, nr_segs); | 1416 | iov, pos, nr_segs); |
1420 | blk_finish_plug(&plug); | ||
1421 | } | 1417 | } |
1422 | if (retval > 0) { | 1418 | if (retval > 0) { |
1423 | *ppos = pos + retval; | 1419 | *ppos = pos + retval; |
@@ -2527,14 +2523,12 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2527 | { | 2523 | { |
2528 | struct file *file = iocb->ki_filp; | 2524 | struct file *file = iocb->ki_filp; |
2529 | struct inode *inode = file->f_mapping->host; | 2525 | struct inode *inode = file->f_mapping->host; |
2530 | struct blk_plug plug; | ||
2531 | ssize_t ret; | 2526 | ssize_t ret; |
2532 | 2527 | ||
2533 | BUG_ON(iocb->ki_pos != pos); | 2528 | BUG_ON(iocb->ki_pos != pos); |
2534 | 2529 | ||
2535 | sb_start_write(inode->i_sb); | 2530 | sb_start_write(inode->i_sb); |
2536 | mutex_lock(&inode->i_mutex); | 2531 | mutex_lock(&inode->i_mutex); |
2537 | blk_start_plug(&plug); | ||
2538 | ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); | 2532 | ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); |
2539 | mutex_unlock(&inode->i_mutex); | 2533 | mutex_unlock(&inode->i_mutex); |
2540 | 2534 | ||
@@ -2545,7 +2539,6 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2545 | if (err < 0 && ret > 0) | 2539 | if (err < 0 && ret > 0) |
2546 | ret = err; | 2540 | ret = err; |
2547 | } | 2541 | } |
2548 | blk_finish_plug(&plug); | ||
2549 | sb_end_write(inode->i_sb); | 2542 | sb_end_write(inode->i_sb); |
2550 | return ret; | 2543 | return ret; |
2551 | } | 2544 | } |
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 57c4b9309015..141dbb695097 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -1811,7 +1811,6 @@ static void __collapse_huge_page_copy(pte_t *pte, struct page *page, | |||
1811 | src_page = pte_page(pteval); | 1811 | src_page = pte_page(pteval); |
1812 | copy_user_highpage(page, src_page, address, vma); | 1812 | copy_user_highpage(page, src_page, address, vma); |
1813 | VM_BUG_ON(page_mapcount(src_page) != 1); | 1813 | VM_BUG_ON(page_mapcount(src_page) != 1); |
1814 | VM_BUG_ON(page_count(src_page) != 2); | ||
1815 | release_pte_page(src_page); | 1814 | release_pte_page(src_page); |
1816 | /* | 1815 | /* |
1817 | * ptl mostly unnecessary, but preempt has to | 1816 | * ptl mostly unnecessary, but preempt has to |
diff --git a/mm/internal.h b/mm/internal.h index 3314f79d775a..b8c91b342e24 100644 --- a/mm/internal.h +++ b/mm/internal.h | |||
@@ -130,6 +130,7 @@ struct compact_control { | |||
130 | int order; /* order a direct compactor needs */ | 130 | int order; /* order a direct compactor needs */ |
131 | int migratetype; /* MOVABLE, RECLAIMABLE etc */ | 131 | int migratetype; /* MOVABLE, RECLAIMABLE etc */ |
132 | struct zone *zone; | 132 | struct zone *zone; |
133 | bool *contended; /* True if a lock was contended */ | ||
133 | }; | 134 | }; |
134 | 135 | ||
135 | unsigned long | 136 | unsigned long |
diff --git a/mm/memblock.c b/mm/memblock.c index 4d9393c7edc9..82aa349d2f7a 100644 --- a/mm/memblock.c +++ b/mm/memblock.c | |||
@@ -246,7 +246,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type, | |||
246 | min(new_area_start, memblock.current_limit), | 246 | min(new_area_start, memblock.current_limit), |
247 | new_alloc_size, PAGE_SIZE); | 247 | new_alloc_size, PAGE_SIZE); |
248 | 248 | ||
249 | new_array = addr ? __va(addr) : 0; | 249 | new_array = addr ? __va(addr) : NULL; |
250 | } | 250 | } |
251 | if (!addr) { | 251 | if (!addr) { |
252 | pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n", | 252 | pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n", |
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 3ad25f9d1fc1..6a5b90d0cfd7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -126,9 +126,6 @@ static void register_page_bootmem_info_section(unsigned long start_pfn) | |||
126 | struct mem_section *ms; | 126 | struct mem_section *ms; |
127 | struct page *page, *memmap; | 127 | struct page *page, *memmap; |
128 | 128 | ||
129 | if (!pfn_valid(start_pfn)) | ||
130 | return; | ||
131 | |||
132 | section_nr = pfn_to_section_nr(start_pfn); | 129 | section_nr = pfn_to_section_nr(start_pfn); |
133 | ms = __nr_to_section(section_nr); | 130 | ms = __nr_to_section(section_nr); |
134 | 131 | ||
@@ -187,9 +184,16 @@ void register_page_bootmem_info_node(struct pglist_data *pgdat) | |||
187 | end_pfn = pfn + pgdat->node_spanned_pages; | 184 | end_pfn = pfn + pgdat->node_spanned_pages; |
188 | 185 | ||
189 | /* register_section info */ | 186 | /* register_section info */ |
190 | for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) | 187 | for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { |
191 | register_page_bootmem_info_section(pfn); | 188 | /* |
192 | 189 | * Some platforms can assign the same pfn to multiple nodes - on | |
190 | * node0 as well as nodeN. To avoid registering a pfn against | ||
191 | * multiple nodes we check that this pfn does not already | ||
192 | * reside in some other node. | ||
193 | */ | ||
194 | if (pfn_valid(pfn) && (pfn_to_nid(pfn) == node)) | ||
195 | register_page_bootmem_info_section(pfn); | ||
196 | } | ||
193 | } | 197 | } |
194 | #endif /* !CONFIG_SPARSEMEM_VMEMMAP */ | 198 | #endif /* !CONFIG_SPARSEMEM_VMEMMAP */ |
195 | 199 | ||
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index bd92431d4c49..4ada3be6e252 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -2562,7 +2562,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context) | |||
2562 | break; | 2562 | break; |
2563 | 2563 | ||
2564 | default: | 2564 | default: |
2565 | BUG(); | 2565 | return -EINVAL; |
2566 | } | 2566 | } |
2567 | 2567 | ||
2568 | l = strlen(policy_modes[mode]); | 2568 | l = strlen(policy_modes[mode]); |
@@ -1356,9 +1356,8 @@ out: | |||
1356 | } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK)) | 1356 | } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK)) |
1357 | make_pages_present(addr, addr + len); | 1357 | make_pages_present(addr, addr + len); |
1358 | 1358 | ||
1359 | if (file && uprobe_mmap(vma)) | 1359 | if (file) |
1360 | /* matching probes but cannot insert */ | 1360 | uprobe_mmap(vma); |
1361 | goto unmap_and_free_vma; | ||
1362 | 1361 | ||
1363 | return addr; | 1362 | return addr; |
1364 | 1363 | ||
@@ -2309,7 +2308,7 @@ void exit_mmap(struct mm_struct *mm) | |||
2309 | } | 2308 | } |
2310 | vm_unacct_memory(nr_accounted); | 2309 | vm_unacct_memory(nr_accounted); |
2311 | 2310 | ||
2312 | BUG_ON(mm->nr_ptes > (FIRST_USER_ADDRESS+PMD_SIZE-1)>>PMD_SHIFT); | 2311 | WARN_ON(mm->nr_ptes > (FIRST_USER_ADDRESS+PMD_SIZE-1)>>PMD_SHIFT); |
2313 | } | 2312 | } |
2314 | 2313 | ||
2315 | /* Insert vm structure into process list sorted by address | 2314 | /* Insert vm structure into process list sorted by address |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e5363f34e025..5ad5ce23c1e0 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -1532,7 +1532,6 @@ int dirty_writeback_centisecs_handler(ctl_table *table, int write, | |||
1532 | void __user *buffer, size_t *length, loff_t *ppos) | 1532 | void __user *buffer, size_t *length, loff_t *ppos) |
1533 | { | 1533 | { |
1534 | proc_dointvec(table, write, buffer, length, ppos); | 1534 | proc_dointvec(table, write, buffer, length, ppos); |
1535 | bdi_arm_supers_timer(); | ||
1536 | return 0; | 1535 | return 0; |
1537 | } | 1536 | } |
1538 | 1537 | ||
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 009ac285fea7..c13ea7538891 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -584,7 +584,7 @@ static inline void __free_one_page(struct page *page, | |||
584 | combined_idx = buddy_idx & page_idx; | 584 | combined_idx = buddy_idx & page_idx; |
585 | higher_page = page + (combined_idx - page_idx); | 585 | higher_page = page + (combined_idx - page_idx); |
586 | buddy_idx = __find_buddy_index(combined_idx, order + 1); | 586 | buddy_idx = __find_buddy_index(combined_idx, order + 1); |
587 | higher_buddy = page + (buddy_idx - combined_idx); | 587 | higher_buddy = higher_page + (buddy_idx - combined_idx); |
588 | if (page_is_buddy(higher_page, higher_buddy, order + 1)) { | 588 | if (page_is_buddy(higher_page, higher_buddy, order + 1)) { |
589 | list_add_tail(&page->lru, | 589 | list_add_tail(&page->lru, |
590 | &zone->free_area[order].free_list[migratetype]); | 590 | &zone->free_area[order].free_list[migratetype]); |
@@ -1928,6 +1928,17 @@ this_zone_full: | |||
1928 | zlc_active = 0; | 1928 | zlc_active = 0; |
1929 | goto zonelist_scan; | 1929 | goto zonelist_scan; |
1930 | } | 1930 | } |
1931 | |||
1932 | if (page) | ||
1933 | /* | ||
1934 | * page->pfmemalloc is set when ALLOC_NO_WATERMARKS was | ||
1935 | * necessary to allocate the page. The expectation is | ||
1936 | * that the caller is taking steps that will free more | ||
1937 | * memory. The caller should avoid the page being used | ||
1938 | * for !PFMEMALLOC purposes. | ||
1939 | */ | ||
1940 | page->pfmemalloc = !!(alloc_flags & ALLOC_NO_WATERMARKS); | ||
1941 | |||
1931 | return page; | 1942 | return page; |
1932 | } | 1943 | } |
1933 | 1944 | ||
@@ -2091,7 +2102,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, | |||
2091 | struct zonelist *zonelist, enum zone_type high_zoneidx, | 2102 | struct zonelist *zonelist, enum zone_type high_zoneidx, |
2092 | nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, | 2103 | nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, |
2093 | int migratetype, bool sync_migration, | 2104 | int migratetype, bool sync_migration, |
2094 | bool *deferred_compaction, | 2105 | bool *contended_compaction, bool *deferred_compaction, |
2095 | unsigned long *did_some_progress) | 2106 | unsigned long *did_some_progress) |
2096 | { | 2107 | { |
2097 | struct page *page; | 2108 | struct page *page; |
@@ -2106,7 +2117,8 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, | |||
2106 | 2117 | ||
2107 | current->flags |= PF_MEMALLOC; | 2118 | current->flags |= PF_MEMALLOC; |
2108 | *did_some_progress = try_to_compact_pages(zonelist, order, gfp_mask, | 2119 | *did_some_progress = try_to_compact_pages(zonelist, order, gfp_mask, |
2109 | nodemask, sync_migration); | 2120 | nodemask, sync_migration, |
2121 | contended_compaction); | ||
2110 | current->flags &= ~PF_MEMALLOC; | 2122 | current->flags &= ~PF_MEMALLOC; |
2111 | if (*did_some_progress != COMPACT_SKIPPED) { | 2123 | if (*did_some_progress != COMPACT_SKIPPED) { |
2112 | 2124 | ||
@@ -2152,7 +2164,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, | |||
2152 | struct zonelist *zonelist, enum zone_type high_zoneidx, | 2164 | struct zonelist *zonelist, enum zone_type high_zoneidx, |
2153 | nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, | 2165 | nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, |
2154 | int migratetype, bool sync_migration, | 2166 | int migratetype, bool sync_migration, |
2155 | bool *deferred_compaction, | 2167 | bool *contended_compaction, bool *deferred_compaction, |
2156 | unsigned long *did_some_progress) | 2168 | unsigned long *did_some_progress) |
2157 | { | 2169 | { |
2158 | return NULL; | 2170 | return NULL; |
@@ -2325,6 +2337,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, | |||
2325 | unsigned long did_some_progress; | 2337 | unsigned long did_some_progress; |
2326 | bool sync_migration = false; | 2338 | bool sync_migration = false; |
2327 | bool deferred_compaction = false; | 2339 | bool deferred_compaction = false; |
2340 | bool contended_compaction = false; | ||
2328 | 2341 | ||
2329 | /* | 2342 | /* |
2330 | * In the slowpath, we sanity check order to avoid ever trying to | 2343 | * In the slowpath, we sanity check order to avoid ever trying to |
@@ -2389,14 +2402,6 @@ rebalance: | |||
2389 | zonelist, high_zoneidx, nodemask, | 2402 | zonelist, high_zoneidx, nodemask, |
2390 | preferred_zone, migratetype); | 2403 | preferred_zone, migratetype); |
2391 | if (page) { | 2404 | if (page) { |
2392 | /* | ||
2393 | * page->pfmemalloc is set when ALLOC_NO_WATERMARKS was | ||
2394 | * necessary to allocate the page. The expectation is | ||
2395 | * that the caller is taking steps that will free more | ||
2396 | * memory. The caller should avoid the page being used | ||
2397 | * for !PFMEMALLOC purposes. | ||
2398 | */ | ||
2399 | page->pfmemalloc = true; | ||
2400 | goto got_pg; | 2405 | goto got_pg; |
2401 | } | 2406 | } |
2402 | } | 2407 | } |
@@ -2422,6 +2427,7 @@ rebalance: | |||
2422 | nodemask, | 2427 | nodemask, |
2423 | alloc_flags, preferred_zone, | 2428 | alloc_flags, preferred_zone, |
2424 | migratetype, sync_migration, | 2429 | migratetype, sync_migration, |
2430 | &contended_compaction, | ||
2425 | &deferred_compaction, | 2431 | &deferred_compaction, |
2426 | &did_some_progress); | 2432 | &did_some_progress); |
2427 | if (page) | 2433 | if (page) |
@@ -2431,10 +2437,11 @@ rebalance: | |||
2431 | /* | 2437 | /* |
2432 | * If compaction is deferred for high-order allocations, it is because | 2438 | * If compaction is deferred for high-order allocations, it is because |
2433 | * sync compaction recently failed. In this is the case and the caller | 2439 | * sync compaction recently failed. In this is the case and the caller |
2434 | * has requested the system not be heavily disrupted, fail the | 2440 | * requested a movable allocation that does not heavily disrupt the |
2435 | * allocation now instead of entering direct reclaim | 2441 | * system then fail the allocation instead of entering direct reclaim. |
2436 | */ | 2442 | */ |
2437 | if (deferred_compaction && (gfp_mask & __GFP_NO_KSWAPD)) | 2443 | if ((deferred_compaction || contended_compaction) && |
2444 | (gfp_mask & __GFP_NO_KSWAPD)) | ||
2438 | goto nopage; | 2445 | goto nopage; |
2439 | 2446 | ||
2440 | /* Try direct reclaim and then allocating */ | 2447 | /* Try direct reclaim and then allocating */ |
@@ -2505,6 +2512,7 @@ rebalance: | |||
2505 | nodemask, | 2512 | nodemask, |
2506 | alloc_flags, preferred_zone, | 2513 | alloc_flags, preferred_zone, |
2507 | migratetype, sync_migration, | 2514 | migratetype, sync_migration, |
2515 | &contended_compaction, | ||
2508 | &deferred_compaction, | 2516 | &deferred_compaction, |
2509 | &did_some_progress); | 2517 | &did_some_progress); |
2510 | if (page) | 2518 | if (page) |
@@ -2569,8 +2577,6 @@ retry_cpuset: | |||
2569 | page = __alloc_pages_slowpath(gfp_mask, order, | 2577 | page = __alloc_pages_slowpath(gfp_mask, order, |
2570 | zonelist, high_zoneidx, nodemask, | 2578 | zonelist, high_zoneidx, nodemask, |
2571 | preferred_zone, migratetype); | 2579 | preferred_zone, migratetype); |
2572 | else | ||
2573 | page->pfmemalloc = false; | ||
2574 | 2580 | ||
2575 | trace_mm_page_alloc(page, order, gfp_mask, migratetype); | 2581 | trace_mm_page_alloc(page, order, gfp_mask, migratetype); |
2576 | 2582 | ||
@@ -498,14 +498,6 @@ static void **dbg_userword(struct kmem_cache *cachep, void *objp) | |||
498 | 498 | ||
499 | #endif | 499 | #endif |
500 | 500 | ||
501 | #ifdef CONFIG_TRACING | ||
502 | size_t slab_buffer_size(struct kmem_cache *cachep) | ||
503 | { | ||
504 | return cachep->size; | ||
505 | } | ||
506 | EXPORT_SYMBOL(slab_buffer_size); | ||
507 | #endif | ||
508 | |||
509 | /* | 501 | /* |
510 | * Do not go above this order unless 0 objects fit into the slab or | 502 | * Do not go above this order unless 0 objects fit into the slab or |
511 | * overridden on the command line. | 503 | * overridden on the command line. |
@@ -812,6 +804,7 @@ static void __slab_error(const char *function, struct kmem_cache *cachep, | |||
812 | printk(KERN_ERR "slab error in %s(): cache `%s': %s\n", | 804 | printk(KERN_ERR "slab error in %s(): cache `%s': %s\n", |
813 | function, cachep->name, msg); | 805 | function, cachep->name, msg); |
814 | dump_stack(); | 806 | dump_stack(); |
807 | add_taint(TAINT_BAD_PAGE); | ||
815 | } | 808 | } |
816 | #endif | 809 | #endif |
817 | 810 | ||
@@ -978,7 +971,7 @@ static void *__ac_get_obj(struct kmem_cache *cachep, struct array_cache *ac, | |||
978 | } | 971 | } |
979 | 972 | ||
980 | /* The caller cannot use PFMEMALLOC objects, find another one */ | 973 | /* The caller cannot use PFMEMALLOC objects, find another one */ |
981 | for (i = 1; i < ac->avail; i++) { | 974 | for (i = 0; i < ac->avail; i++) { |
982 | /* If a !PFMEMALLOC object is found, swap them */ | 975 | /* If a !PFMEMALLOC object is found, swap them */ |
983 | if (!is_obj_pfmemalloc(ac->entry[i])) { | 976 | if (!is_obj_pfmemalloc(ac->entry[i])) { |
984 | objp = ac->entry[i]; | 977 | objp = ac->entry[i]; |
@@ -995,7 +988,7 @@ static void *__ac_get_obj(struct kmem_cache *cachep, struct array_cache *ac, | |||
995 | l3 = cachep->nodelists[numa_mem_id()]; | 988 | l3 = cachep->nodelists[numa_mem_id()]; |
996 | if (!list_empty(&l3->slabs_free) && force_refill) { | 989 | if (!list_empty(&l3->slabs_free) && force_refill) { |
997 | struct slab *slabp = virt_to_slab(objp); | 990 | struct slab *slabp = virt_to_slab(objp); |
998 | ClearPageSlabPfmemalloc(virt_to_page(slabp->s_mem)); | 991 | ClearPageSlabPfmemalloc(virt_to_head_page(slabp->s_mem)); |
999 | clear_obj_pfmemalloc(&objp); | 992 | clear_obj_pfmemalloc(&objp); |
1000 | recheck_pfmemalloc_active(cachep, ac); | 993 | recheck_pfmemalloc_active(cachep, ac); |
1001 | return objp; | 994 | return objp; |
@@ -1027,7 +1020,7 @@ static void *__ac_put_obj(struct kmem_cache *cachep, struct array_cache *ac, | |||
1027 | { | 1020 | { |
1028 | if (unlikely(pfmemalloc_active)) { | 1021 | if (unlikely(pfmemalloc_active)) { |
1029 | /* Some pfmemalloc slabs exist, check if this is one */ | 1022 | /* Some pfmemalloc slabs exist, check if this is one */ |
1030 | struct page *page = virt_to_page(objp); | 1023 | struct page *page = virt_to_head_page(objp); |
1031 | if (PageSlabPfmemalloc(page)) | 1024 | if (PageSlabPfmemalloc(page)) |
1032 | set_obj_pfmemalloc(&objp); | 1025 | set_obj_pfmemalloc(&objp); |
1033 | } | 1026 | } |
@@ -1784,9 +1777,6 @@ void __init kmem_cache_init_late(void) | |||
1784 | 1777 | ||
1785 | slab_state = UP; | 1778 | slab_state = UP; |
1786 | 1779 | ||
1787 | /* Annotate slab for lockdep -- annotate the malloc caches */ | ||
1788 | init_lock_keys(); | ||
1789 | |||
1790 | /* 6) resize the head arrays to their final sizes */ | 1780 | /* 6) resize the head arrays to their final sizes */ |
1791 | mutex_lock(&slab_mutex); | 1781 | mutex_lock(&slab_mutex); |
1792 | list_for_each_entry(cachep, &slab_caches, list) | 1782 | list_for_each_entry(cachep, &slab_caches, list) |
@@ -1794,6 +1784,9 @@ void __init kmem_cache_init_late(void) | |||
1794 | BUG(); | 1784 | BUG(); |
1795 | mutex_unlock(&slab_mutex); | 1785 | mutex_unlock(&slab_mutex); |
1796 | 1786 | ||
1787 | /* Annotate slab for lockdep -- annotate the malloc caches */ | ||
1788 | init_lock_keys(); | ||
1789 | |||
1797 | /* Done! */ | 1790 | /* Done! */ |
1798 | slab_state = FULL; | 1791 | slab_state = FULL; |
1799 | 1792 | ||
@@ -2478,8 +2471,9 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags) | |||
2478 | } | 2471 | } |
2479 | #if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC) | 2472 | #if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC) |
2480 | if (size >= malloc_sizes[INDEX_L3 + 1].cs_size | 2473 | if (size >= malloc_sizes[INDEX_L3 + 1].cs_size |
2481 | && cachep->object_size > cache_line_size() && ALIGN(size, align) < PAGE_SIZE) { | 2474 | && cachep->object_size > cache_line_size() |
2482 | cachep->obj_offset += PAGE_SIZE - ALIGN(size, align); | 2475 | && ALIGN(size, cachep->align) < PAGE_SIZE) { |
2476 | cachep->obj_offset += PAGE_SIZE - ALIGN(size, cachep->align); | ||
2483 | size = PAGE_SIZE; | 2477 | size = PAGE_SIZE; |
2484 | } | 2478 | } |
2485 | #endif | 2479 | #endif |
@@ -3044,7 +3038,7 @@ static inline void verify_redzone_free(struct kmem_cache *cache, void *obj) | |||
3044 | } | 3038 | } |
3045 | 3039 | ||
3046 | static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp, | 3040 | static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp, |
3047 | void *caller) | 3041 | unsigned long caller) |
3048 | { | 3042 | { |
3049 | struct page *page; | 3043 | struct page *page; |
3050 | unsigned int objnr; | 3044 | unsigned int objnr; |
@@ -3064,7 +3058,7 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp, | |||
3064 | *dbg_redzone2(cachep, objp) = RED_INACTIVE; | 3058 | *dbg_redzone2(cachep, objp) = RED_INACTIVE; |
3065 | } | 3059 | } |
3066 | if (cachep->flags & SLAB_STORE_USER) | 3060 | if (cachep->flags & SLAB_STORE_USER) |
3067 | *dbg_userword(cachep, objp) = caller; | 3061 | *dbg_userword(cachep, objp) = (void *)caller; |
3068 | 3062 | ||
3069 | objnr = obj_to_index(cachep, slabp, objp); | 3063 | objnr = obj_to_index(cachep, slabp, objp); |
3070 | 3064 | ||
@@ -3077,7 +3071,7 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp, | |||
3077 | if (cachep->flags & SLAB_POISON) { | 3071 | if (cachep->flags & SLAB_POISON) { |
3078 | #ifdef CONFIG_DEBUG_PAGEALLOC | 3072 | #ifdef CONFIG_DEBUG_PAGEALLOC |
3079 | if ((cachep->size % PAGE_SIZE)==0 && OFF_SLAB(cachep)) { | 3073 | if ((cachep->size % PAGE_SIZE)==0 && OFF_SLAB(cachep)) { |
3080 | store_stackinfo(cachep, objp, (unsigned long)caller); | 3074 | store_stackinfo(cachep, objp, caller); |
3081 | kernel_map_pages(virt_to_page(objp), | 3075 | kernel_map_pages(virt_to_page(objp), |
3082 | cachep->size / PAGE_SIZE, 0); | 3076 | cachep->size / PAGE_SIZE, 0); |
3083 | } else { | 3077 | } else { |
@@ -3206,6 +3200,7 @@ force_grow: | |||
3206 | 3200 | ||
3207 | /* cache_grow can reenable interrupts, then ac could change. */ | 3201 | /* cache_grow can reenable interrupts, then ac could change. */ |
3208 | ac = cpu_cache_get(cachep); | 3202 | ac = cpu_cache_get(cachep); |
3203 | node = numa_mem_id(); | ||
3209 | 3204 | ||
3210 | /* no objects in sight? abort */ | 3205 | /* no objects in sight? abort */ |
3211 | if (!x && (ac->avail == 0 || force_refill)) | 3206 | if (!x && (ac->avail == 0 || force_refill)) |
@@ -3230,7 +3225,7 @@ static inline void cache_alloc_debugcheck_before(struct kmem_cache *cachep, | |||
3230 | 3225 | ||
3231 | #if DEBUG | 3226 | #if DEBUG |
3232 | static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, | 3227 | static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, |
3233 | gfp_t flags, void *objp, void *caller) | 3228 | gfp_t flags, void *objp, unsigned long caller) |
3234 | { | 3229 | { |
3235 | if (!objp) | 3230 | if (!objp) |
3236 | return objp; | 3231 | return objp; |
@@ -3247,7 +3242,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, | |||
3247 | poison_obj(cachep, objp, POISON_INUSE); | 3242 | poison_obj(cachep, objp, POISON_INUSE); |
3248 | } | 3243 | } |
3249 | if (cachep->flags & SLAB_STORE_USER) | 3244 | if (cachep->flags & SLAB_STORE_USER) |
3250 | *dbg_userword(cachep, objp) = caller; | 3245 | *dbg_userword(cachep, objp) = (void *)caller; |
3251 | 3246 | ||
3252 | if (cachep->flags & SLAB_RED_ZONE) { | 3247 | if (cachep->flags & SLAB_RED_ZONE) { |
3253 | if (*dbg_redzone1(cachep, objp) != RED_INACTIVE || | 3248 | if (*dbg_redzone1(cachep, objp) != RED_INACTIVE || |
@@ -3521,8 +3516,8 @@ done: | |||
3521 | * Fallback to other node is possible if __GFP_THISNODE is not set. | 3516 | * Fallback to other node is possible if __GFP_THISNODE is not set. |
3522 | */ | 3517 | */ |
3523 | static __always_inline void * | 3518 | static __always_inline void * |
3524 | __cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid, | 3519 | slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid, |
3525 | void *caller) | 3520 | unsigned long caller) |
3526 | { | 3521 | { |
3527 | unsigned long save_flags; | 3522 | unsigned long save_flags; |
3528 | void *ptr; | 3523 | void *ptr; |
@@ -3608,7 +3603,7 @@ __do_cache_alloc(struct kmem_cache *cachep, gfp_t flags) | |||
3608 | #endif /* CONFIG_NUMA */ | 3603 | #endif /* CONFIG_NUMA */ |
3609 | 3604 | ||
3610 | static __always_inline void * | 3605 | static __always_inline void * |
3611 | __cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller) | 3606 | slab_alloc(struct kmem_cache *cachep, gfp_t flags, unsigned long caller) |
3612 | { | 3607 | { |
3613 | unsigned long save_flags; | 3608 | unsigned long save_flags; |
3614 | void *objp; | 3609 | void *objp; |
@@ -3744,7 +3739,7 @@ free_done: | |||
3744 | * be in this state _before_ it is released. Called with disabled ints. | 3739 | * be in this state _before_ it is released. Called with disabled ints. |
3745 | */ | 3740 | */ |
3746 | static inline void __cache_free(struct kmem_cache *cachep, void *objp, | 3741 | static inline void __cache_free(struct kmem_cache *cachep, void *objp, |
3747 | void *caller) | 3742 | unsigned long caller) |
3748 | { | 3743 | { |
3749 | struct array_cache *ac = cpu_cache_get(cachep); | 3744 | struct array_cache *ac = cpu_cache_get(cachep); |
3750 | 3745 | ||
@@ -3784,7 +3779,7 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp, | |||
3784 | */ | 3779 | */ |
3785 | void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) | 3780 | void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) |
3786 | { | 3781 | { |
3787 | void *ret = __cache_alloc(cachep, flags, __builtin_return_address(0)); | 3782 | void *ret = slab_alloc(cachep, flags, _RET_IP_); |
3788 | 3783 | ||
3789 | trace_kmem_cache_alloc(_RET_IP_, ret, | 3784 | trace_kmem_cache_alloc(_RET_IP_, ret, |
3790 | cachep->object_size, cachep->size, flags); | 3785 | cachep->object_size, cachep->size, flags); |
@@ -3795,14 +3790,14 @@ EXPORT_SYMBOL(kmem_cache_alloc); | |||
3795 | 3790 | ||
3796 | #ifdef CONFIG_TRACING | 3791 | #ifdef CONFIG_TRACING |
3797 | void * | 3792 | void * |
3798 | kmem_cache_alloc_trace(size_t size, struct kmem_cache *cachep, gfp_t flags) | 3793 | kmem_cache_alloc_trace(struct kmem_cache *cachep, gfp_t flags, size_t size) |
3799 | { | 3794 | { |
3800 | void *ret; | 3795 | void *ret; |
3801 | 3796 | ||
3802 | ret = __cache_alloc(cachep, flags, __builtin_return_address(0)); | 3797 | ret = slab_alloc(cachep, flags, _RET_IP_); |
3803 | 3798 | ||
3804 | trace_kmalloc(_RET_IP_, ret, | 3799 | trace_kmalloc(_RET_IP_, ret, |
3805 | size, slab_buffer_size(cachep), flags); | 3800 | size, cachep->size, flags); |
3806 | return ret; | 3801 | return ret; |
3807 | } | 3802 | } |
3808 | EXPORT_SYMBOL(kmem_cache_alloc_trace); | 3803 | EXPORT_SYMBOL(kmem_cache_alloc_trace); |
@@ -3811,8 +3806,7 @@ EXPORT_SYMBOL(kmem_cache_alloc_trace); | |||
3811 | #ifdef CONFIG_NUMA | 3806 | #ifdef CONFIG_NUMA |
3812 | void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) | 3807 | void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) |
3813 | { | 3808 | { |
3814 | void *ret = __cache_alloc_node(cachep, flags, nodeid, | 3809 | void *ret = slab_alloc_node(cachep, flags, nodeid, _RET_IP_); |
3815 | __builtin_return_address(0)); | ||
3816 | 3810 | ||
3817 | trace_kmem_cache_alloc_node(_RET_IP_, ret, | 3811 | trace_kmem_cache_alloc_node(_RET_IP_, ret, |
3818 | cachep->object_size, cachep->size, | 3812 | cachep->object_size, cachep->size, |
@@ -3823,17 +3817,17 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) | |||
3823 | EXPORT_SYMBOL(kmem_cache_alloc_node); | 3817 | EXPORT_SYMBOL(kmem_cache_alloc_node); |
3824 | 3818 | ||
3825 | #ifdef CONFIG_TRACING | 3819 | #ifdef CONFIG_TRACING |
3826 | void *kmem_cache_alloc_node_trace(size_t size, | 3820 | void *kmem_cache_alloc_node_trace(struct kmem_cache *cachep, |
3827 | struct kmem_cache *cachep, | ||
3828 | gfp_t flags, | 3821 | gfp_t flags, |
3829 | int nodeid) | 3822 | int nodeid, |
3823 | size_t size) | ||
3830 | { | 3824 | { |
3831 | void *ret; | 3825 | void *ret; |
3832 | 3826 | ||
3833 | ret = __cache_alloc_node(cachep, flags, nodeid, | 3827 | ret = slab_alloc_node(cachep, flags, nodeid, _RET_IP); |
3834 | __builtin_return_address(0)); | 3828 | |
3835 | trace_kmalloc_node(_RET_IP_, ret, | 3829 | trace_kmalloc_node(_RET_IP_, ret, |
3836 | size, slab_buffer_size(cachep), | 3830 | size, cachep->size, |
3837 | flags, nodeid); | 3831 | flags, nodeid); |
3838 | return ret; | 3832 | return ret; |
3839 | } | 3833 | } |
@@ -3841,34 +3835,33 @@ EXPORT_SYMBOL(kmem_cache_alloc_node_trace); | |||
3841 | #endif | 3835 | #endif |
3842 | 3836 | ||
3843 | static __always_inline void * | 3837 | static __always_inline void * |
3844 | __do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller) | 3838 | __do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller) |
3845 | { | 3839 | { |
3846 | struct kmem_cache *cachep; | 3840 | struct kmem_cache *cachep; |
3847 | 3841 | ||
3848 | cachep = kmem_find_general_cachep(size, flags); | 3842 | cachep = kmem_find_general_cachep(size, flags); |
3849 | if (unlikely(ZERO_OR_NULL_PTR(cachep))) | 3843 | if (unlikely(ZERO_OR_NULL_PTR(cachep))) |
3850 | return cachep; | 3844 | return cachep; |
3851 | return kmem_cache_alloc_node_trace(size, cachep, flags, node); | 3845 | return kmem_cache_alloc_node_trace(cachep, flags, node, size); |
3852 | } | 3846 | } |
3853 | 3847 | ||
3854 | #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING) | 3848 | #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING) |
3855 | void *__kmalloc_node(size_t size, gfp_t flags, int node) | 3849 | void *__kmalloc_node(size_t size, gfp_t flags, int node) |
3856 | { | 3850 | { |
3857 | return __do_kmalloc_node(size, flags, node, | 3851 | return __do_kmalloc_node(size, flags, node, _RET_IP_); |
3858 | __builtin_return_address(0)); | ||
3859 | } | 3852 | } |
3860 | EXPORT_SYMBOL(__kmalloc_node); | 3853 | EXPORT_SYMBOL(__kmalloc_node); |
3861 | 3854 | ||
3862 | void *__kmalloc_node_track_caller(size_t size, gfp_t flags, | 3855 | void *__kmalloc_node_track_caller(size_t size, gfp_t flags, |
3863 | int node, unsigned long caller) | 3856 | int node, unsigned long caller) |
3864 | { | 3857 | { |
3865 | return __do_kmalloc_node(size, flags, node, (void *)caller); | 3858 | return __do_kmalloc_node(size, flags, node, caller); |
3866 | } | 3859 | } |
3867 | EXPORT_SYMBOL(__kmalloc_node_track_caller); | 3860 | EXPORT_SYMBOL(__kmalloc_node_track_caller); |
3868 | #else | 3861 | #else |
3869 | void *__kmalloc_node(size_t size, gfp_t flags, int node) | 3862 | void *__kmalloc_node(size_t size, gfp_t flags, int node) |
3870 | { | 3863 | { |
3871 | return __do_kmalloc_node(size, flags, node, NULL); | 3864 | return __do_kmalloc_node(size, flags, node, 0); |
3872 | } | 3865 | } |
3873 | EXPORT_SYMBOL(__kmalloc_node); | 3866 | EXPORT_SYMBOL(__kmalloc_node); |
3874 | #endif /* CONFIG_DEBUG_SLAB || CONFIG_TRACING */ | 3867 | #endif /* CONFIG_DEBUG_SLAB || CONFIG_TRACING */ |
@@ -3881,7 +3874,7 @@ EXPORT_SYMBOL(__kmalloc_node); | |||
3881 | * @caller: function caller for debug tracking of the caller | 3874 | * @caller: function caller for debug tracking of the caller |
3882 | */ | 3875 | */ |
3883 | static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, | 3876 | static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, |
3884 | void *caller) | 3877 | unsigned long caller) |
3885 | { | 3878 | { |
3886 | struct kmem_cache *cachep; | 3879 | struct kmem_cache *cachep; |
3887 | void *ret; | 3880 | void *ret; |
@@ -3894,9 +3887,9 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, | |||
3894 | cachep = __find_general_cachep(size, flags); | 3887 | cachep = __find_general_cachep(size, flags); |
3895 | if (unlikely(ZERO_OR_NULL_PTR(cachep))) | 3888 | if (unlikely(ZERO_OR_NULL_PTR(cachep))) |
3896 | return cachep; | 3889 | return cachep; |
3897 | ret = __cache_alloc(cachep, flags, caller); | 3890 | ret = slab_alloc(cachep, flags, caller); |
3898 | 3891 | ||
3899 | trace_kmalloc((unsigned long) caller, ret, | 3892 | trace_kmalloc(caller, ret, |
3900 | size, cachep->size, flags); | 3893 | size, cachep->size, flags); |
3901 | 3894 | ||
3902 | return ret; | 3895 | return ret; |
@@ -3906,20 +3899,20 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, | |||
3906 | #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING) | 3899 | #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING) |
3907 | void *__kmalloc(size_t size, gfp_t flags) | 3900 | void *__kmalloc(size_t size, gfp_t flags) |
3908 | { | 3901 | { |
3909 | return __do_kmalloc(size, flags, __builtin_return_address(0)); | 3902 | return __do_kmalloc(size, flags, _RET_IP_); |
3910 | } | 3903 | } |
3911 | EXPORT_SYMBOL(__kmalloc); | 3904 | EXPORT_SYMBOL(__kmalloc); |
3912 | 3905 | ||
3913 | void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller) | 3906 | void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller) |
3914 | { | 3907 | { |
3915 | return __do_kmalloc(size, flags, (void *)caller); | 3908 | return __do_kmalloc(size, flags, caller); |
3916 | } | 3909 | } |
3917 | EXPORT_SYMBOL(__kmalloc_track_caller); | 3910 | EXPORT_SYMBOL(__kmalloc_track_caller); |
3918 | 3911 | ||
3919 | #else | 3912 | #else |
3920 | void *__kmalloc(size_t size, gfp_t flags) | 3913 | void *__kmalloc(size_t size, gfp_t flags) |
3921 | { | 3914 | { |
3922 | return __do_kmalloc(size, flags, NULL); | 3915 | return __do_kmalloc(size, flags, 0); |
3923 | } | 3916 | } |
3924 | EXPORT_SYMBOL(__kmalloc); | 3917 | EXPORT_SYMBOL(__kmalloc); |
3925 | #endif | 3918 | #endif |
@@ -3940,7 +3933,7 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp) | |||
3940 | debug_check_no_locks_freed(objp, cachep->object_size); | 3933 | debug_check_no_locks_freed(objp, cachep->object_size); |
3941 | if (!(cachep->flags & SLAB_DEBUG_OBJECTS)) | 3934 | if (!(cachep->flags & SLAB_DEBUG_OBJECTS)) |
3942 | debug_check_no_obj_freed(objp, cachep->object_size); | 3935 | debug_check_no_obj_freed(objp, cachep->object_size); |
3943 | __cache_free(cachep, objp, __builtin_return_address(0)); | 3936 | __cache_free(cachep, objp, _RET_IP_); |
3944 | local_irq_restore(flags); | 3937 | local_irq_restore(flags); |
3945 | 3938 | ||
3946 | trace_kmem_cache_free(_RET_IP_, objp); | 3939 | trace_kmem_cache_free(_RET_IP_, objp); |
@@ -3971,7 +3964,7 @@ void kfree(const void *objp) | |||
3971 | debug_check_no_locks_freed(objp, c->object_size); | 3964 | debug_check_no_locks_freed(objp, c->object_size); |
3972 | 3965 | ||
3973 | debug_check_no_obj_freed(objp, c->object_size); | 3966 | debug_check_no_obj_freed(objp, c->object_size); |
3974 | __cache_free(c, (void *)objp, __builtin_return_address(0)); | 3967 | __cache_free(c, (void *)objp, _RET_IP_); |
3975 | local_irq_restore(flags); | 3968 | local_irq_restore(flags); |
3976 | } | 3969 | } |
3977 | EXPORT_SYMBOL(kfree); | 3970 | EXPORT_SYMBOL(kfree); |
@@ -194,7 +194,7 @@ static void *slob_new_pages(gfp_t gfp, int order, int node) | |||
194 | void *page; | 194 | void *page; |
195 | 195 | ||
196 | #ifdef CONFIG_NUMA | 196 | #ifdef CONFIG_NUMA |
197 | if (node != -1) | 197 | if (node != NUMA_NO_NODE) |
198 | page = alloc_pages_exact_node(node, gfp, order); | 198 | page = alloc_pages_exact_node(node, gfp, order); |
199 | else | 199 | else |
200 | #endif | 200 | #endif |
@@ -290,7 +290,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) | |||
290 | * If there's a node specification, search for a partial | 290 | * If there's a node specification, search for a partial |
291 | * page with a matching node id in the freelist. | 291 | * page with a matching node id in the freelist. |
292 | */ | 292 | */ |
293 | if (node != -1 && page_to_nid(sp) != node) | 293 | if (node != NUMA_NO_NODE && page_to_nid(sp) != node) |
294 | continue; | 294 | continue; |
295 | #endif | 295 | #endif |
296 | /* Enough room on this page? */ | 296 | /* Enough room on this page? */ |
@@ -425,7 +425,8 @@ out: | |||
425 | * End of slob allocator proper. Begin kmem_cache_alloc and kmalloc frontend. | 425 | * End of slob allocator proper. Begin kmem_cache_alloc and kmalloc frontend. |
426 | */ | 426 | */ |
427 | 427 | ||
428 | void *__kmalloc_node(size_t size, gfp_t gfp, int node) | 428 | static __always_inline void * |
429 | __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller) | ||
429 | { | 430 | { |
430 | unsigned int *m; | 431 | unsigned int *m; |
431 | int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); | 432 | int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); |
@@ -446,7 +447,7 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node) | |||
446 | *m = size; | 447 | *m = size; |
447 | ret = (void *)m + align; | 448 | ret = (void *)m + align; |
448 | 449 | ||
449 | trace_kmalloc_node(_RET_IP_, ret, | 450 | trace_kmalloc_node(caller, ret, |
450 | size, size + align, gfp, node); | 451 | size, size + align, gfp, node); |
451 | } else { | 452 | } else { |
452 | unsigned int order = get_order(size); | 453 | unsigned int order = get_order(size); |
@@ -460,15 +461,35 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node) | |||
460 | page->private = size; | 461 | page->private = size; |
461 | } | 462 | } |
462 | 463 | ||
463 | trace_kmalloc_node(_RET_IP_, ret, | 464 | trace_kmalloc_node(caller, ret, |
464 | size, PAGE_SIZE << order, gfp, node); | 465 | size, PAGE_SIZE << order, gfp, node); |
465 | } | 466 | } |
466 | 467 | ||
467 | kmemleak_alloc(ret, size, 1, gfp); | 468 | kmemleak_alloc(ret, size, 1, gfp); |
468 | return ret; | 469 | return ret; |
469 | } | 470 | } |
471 | |||
472 | void *__kmalloc_node(size_t size, gfp_t gfp, int node) | ||
473 | { | ||
474 | return __do_kmalloc_node(size, gfp, node, _RET_IP_); | ||
475 | } | ||
470 | EXPORT_SYMBOL(__kmalloc_node); | 476 | EXPORT_SYMBOL(__kmalloc_node); |
471 | 477 | ||
478 | #ifdef CONFIG_TRACING | ||
479 | void *__kmalloc_track_caller(size_t size, gfp_t gfp, unsigned long caller) | ||
480 | { | ||
481 | return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, caller); | ||
482 | } | ||
483 | |||
484 | #ifdef CONFIG_NUMA | ||
485 | void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, | ||
486 | int node, unsigned long caller) | ||
487 | { | ||
488 | return __do_kmalloc_node(size, gfp, node, caller); | ||
489 | } | ||
490 | #endif | ||
491 | #endif | ||
492 | |||
472 | void kfree(const void *block) | 493 | void kfree(const void *block) |
473 | { | 494 | { |
474 | struct page *sp; | 495 | struct page *sp; |
@@ -564,6 +564,8 @@ static void slab_bug(struct kmem_cache *s, char *fmt, ...) | |||
564 | printk(KERN_ERR "BUG %s (%s): %s\n", s->name, print_tainted(), buf); | 564 | printk(KERN_ERR "BUG %s (%s): %s\n", s->name, print_tainted(), buf); |
565 | printk(KERN_ERR "----------------------------------------" | 565 | printk(KERN_ERR "----------------------------------------" |
566 | "-------------------------------------\n\n"); | 566 | "-------------------------------------\n\n"); |
567 | |||
568 | add_taint(TAINT_BAD_PAGE); | ||
567 | } | 569 | } |
568 | 570 | ||
569 | static void slab_fix(struct kmem_cache *s, char *fmt, ...) | 571 | static void slab_fix(struct kmem_cache *s, char *fmt, ...) |
@@ -1525,12 +1527,13 @@ static inline void *acquire_slab(struct kmem_cache *s, | |||
1525 | } | 1527 | } |
1526 | 1528 | ||
1527 | static int put_cpu_partial(struct kmem_cache *s, struct page *page, int drain); | 1529 | static int put_cpu_partial(struct kmem_cache *s, struct page *page, int drain); |
1530 | static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags); | ||
1528 | 1531 | ||
1529 | /* | 1532 | /* |
1530 | * Try to allocate a partial slab from a specific node. | 1533 | * Try to allocate a partial slab from a specific node. |
1531 | */ | 1534 | */ |
1532 | static void *get_partial_node(struct kmem_cache *s, | 1535 | static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, |
1533 | struct kmem_cache_node *n, struct kmem_cache_cpu *c) | 1536 | struct kmem_cache_cpu *c, gfp_t flags) |
1534 | { | 1537 | { |
1535 | struct page *page, *page2; | 1538 | struct page *page, *page2; |
1536 | void *object = NULL; | 1539 | void *object = NULL; |
@@ -1546,9 +1549,13 @@ static void *get_partial_node(struct kmem_cache *s, | |||
1546 | 1549 | ||
1547 | spin_lock(&n->list_lock); | 1550 | spin_lock(&n->list_lock); |
1548 | list_for_each_entry_safe(page, page2, &n->partial, lru) { | 1551 | list_for_each_entry_safe(page, page2, &n->partial, lru) { |
1549 | void *t = acquire_slab(s, n, page, object == NULL); | 1552 | void *t; |
1550 | int available; | 1553 | int available; |
1551 | 1554 | ||
1555 | if (!pfmemalloc_match(page, flags)) | ||
1556 | continue; | ||
1557 | |||
1558 | t = acquire_slab(s, n, page, object == NULL); | ||
1552 | if (!t) | 1559 | if (!t) |
1553 | break; | 1560 | break; |
1554 | 1561 | ||
@@ -1615,7 +1622,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags, | |||
1615 | 1622 | ||
1616 | if (n && cpuset_zone_allowed_hardwall(zone, flags) && | 1623 | if (n && cpuset_zone_allowed_hardwall(zone, flags) && |
1617 | n->nr_partial > s->min_partial) { | 1624 | n->nr_partial > s->min_partial) { |
1618 | object = get_partial_node(s, n, c); | 1625 | object = get_partial_node(s, n, c, flags); |
1619 | if (object) { | 1626 | if (object) { |
1620 | /* | 1627 | /* |
1621 | * Return the object even if | 1628 | * Return the object even if |
@@ -1644,7 +1651,7 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node, | |||
1644 | void *object; | 1651 | void *object; |
1645 | int searchnode = (node == NUMA_NO_NODE) ? numa_node_id() : node; | 1652 | int searchnode = (node == NUMA_NO_NODE) ? numa_node_id() : node; |
1646 | 1653 | ||
1647 | object = get_partial_node(s, get_node(s, searchnode), c); | 1654 | object = get_partial_node(s, get_node(s, searchnode), c, flags); |
1648 | if (object || node != NUMA_NO_NODE) | 1655 | if (object || node != NUMA_NO_NODE) |
1649 | return object; | 1656 | return object; |
1650 | 1657 | ||
@@ -1710,7 +1717,7 @@ static inline void note_cmpxchg_failure(const char *n, | |||
1710 | stat(s, CMPXCHG_DOUBLE_CPU_FAIL); | 1717 | stat(s, CMPXCHG_DOUBLE_CPU_FAIL); |
1711 | } | 1718 | } |
1712 | 1719 | ||
1713 | void init_kmem_cache_cpus(struct kmem_cache *s) | 1720 | static void init_kmem_cache_cpus(struct kmem_cache *s) |
1714 | { | 1721 | { |
1715 | int cpu; | 1722 | int cpu; |
1716 | 1723 | ||
@@ -1935,7 +1942,7 @@ static void unfreeze_partials(struct kmem_cache *s) | |||
1935 | * If we did not find a slot then simply move all the partials to the | 1942 | * If we did not find a slot then simply move all the partials to the |
1936 | * per node partial list. | 1943 | * per node partial list. |
1937 | */ | 1944 | */ |
1938 | int put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) | 1945 | static int put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) |
1939 | { | 1946 | { |
1940 | struct page *oldpage; | 1947 | struct page *oldpage; |
1941 | int pages; | 1948 | int pages; |
@@ -2307,7 +2314,7 @@ new_slab: | |||
2307 | * | 2314 | * |
2308 | * Otherwise we can simply pick the next object from the lockless free list. | 2315 | * Otherwise we can simply pick the next object from the lockless free list. |
2309 | */ | 2316 | */ |
2310 | static __always_inline void *slab_alloc(struct kmem_cache *s, | 2317 | static __always_inline void *slab_alloc_node(struct kmem_cache *s, |
2311 | gfp_t gfpflags, int node, unsigned long addr) | 2318 | gfp_t gfpflags, int node, unsigned long addr) |
2312 | { | 2319 | { |
2313 | void **object; | 2320 | void **object; |
@@ -2377,9 +2384,15 @@ redo: | |||
2377 | return object; | 2384 | return object; |
2378 | } | 2385 | } |
2379 | 2386 | ||
2387 | static __always_inline void *slab_alloc(struct kmem_cache *s, | ||
2388 | gfp_t gfpflags, unsigned long addr) | ||
2389 | { | ||
2390 | return slab_alloc_node(s, gfpflags, NUMA_NO_NODE, addr); | ||
2391 | } | ||
2392 | |||
2380 | void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) | 2393 | void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) |
2381 | { | 2394 | { |
2382 | void *ret = slab_alloc(s, gfpflags, NUMA_NO_NODE, _RET_IP_); | 2395 | void *ret = slab_alloc(s, gfpflags, _RET_IP_); |
2383 | 2396 | ||
2384 | trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size, s->size, gfpflags); | 2397 | trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size, s->size, gfpflags); |
2385 | 2398 | ||
@@ -2390,7 +2403,7 @@ EXPORT_SYMBOL(kmem_cache_alloc); | |||
2390 | #ifdef CONFIG_TRACING | 2403 | #ifdef CONFIG_TRACING |
2391 | void *kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size) | 2404 | void *kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size) |
2392 | { | 2405 | { |
2393 | void *ret = slab_alloc(s, gfpflags, NUMA_NO_NODE, _RET_IP_); | 2406 | void *ret = slab_alloc(s, gfpflags, _RET_IP_); |
2394 | trace_kmalloc(_RET_IP_, ret, size, s->size, gfpflags); | 2407 | trace_kmalloc(_RET_IP_, ret, size, s->size, gfpflags); |
2395 | return ret; | 2408 | return ret; |
2396 | } | 2409 | } |
@@ -2408,7 +2421,7 @@ EXPORT_SYMBOL(kmalloc_order_trace); | |||
2408 | #ifdef CONFIG_NUMA | 2421 | #ifdef CONFIG_NUMA |
2409 | void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node) | 2422 | void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node) |
2410 | { | 2423 | { |
2411 | void *ret = slab_alloc(s, gfpflags, node, _RET_IP_); | 2424 | void *ret = slab_alloc_node(s, gfpflags, node, _RET_IP_); |
2412 | 2425 | ||
2413 | trace_kmem_cache_alloc_node(_RET_IP_, ret, | 2426 | trace_kmem_cache_alloc_node(_RET_IP_, ret, |
2414 | s->object_size, s->size, gfpflags, node); | 2427 | s->object_size, s->size, gfpflags, node); |
@@ -2422,7 +2435,7 @@ void *kmem_cache_alloc_node_trace(struct kmem_cache *s, | |||
2422 | gfp_t gfpflags, | 2435 | gfp_t gfpflags, |
2423 | int node, size_t size) | 2436 | int node, size_t size) |
2424 | { | 2437 | { |
2425 | void *ret = slab_alloc(s, gfpflags, node, _RET_IP_); | 2438 | void *ret = slab_alloc_node(s, gfpflags, node, _RET_IP_); |
2426 | 2439 | ||
2427 | trace_kmalloc_node(_RET_IP_, ret, | 2440 | trace_kmalloc_node(_RET_IP_, ret, |
2428 | size, s->size, gfpflags, node); | 2441 | size, s->size, gfpflags, node); |
@@ -3345,7 +3358,7 @@ void *__kmalloc(size_t size, gfp_t flags) | |||
3345 | if (unlikely(ZERO_OR_NULL_PTR(s))) | 3358 | if (unlikely(ZERO_OR_NULL_PTR(s))) |
3346 | return s; | 3359 | return s; |
3347 | 3360 | ||
3348 | ret = slab_alloc(s, flags, NUMA_NO_NODE, _RET_IP_); | 3361 | ret = slab_alloc(s, flags, _RET_IP_); |
3349 | 3362 | ||
3350 | trace_kmalloc(_RET_IP_, ret, size, s->size, flags); | 3363 | trace_kmalloc(_RET_IP_, ret, size, s->size, flags); |
3351 | 3364 | ||
@@ -3388,7 +3401,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node) | |||
3388 | if (unlikely(ZERO_OR_NULL_PTR(s))) | 3401 | if (unlikely(ZERO_OR_NULL_PTR(s))) |
3389 | return s; | 3402 | return s; |
3390 | 3403 | ||
3391 | ret = slab_alloc(s, flags, node, _RET_IP_); | 3404 | ret = slab_alloc_node(s, flags, node, _RET_IP_); |
3392 | 3405 | ||
3393 | trace_kmalloc_node(_RET_IP_, ret, size, s->size, flags, node); | 3406 | trace_kmalloc_node(_RET_IP_, ret, size, s->size, flags, node); |
3394 | 3407 | ||
@@ -4011,7 +4024,7 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller) | |||
4011 | if (unlikely(ZERO_OR_NULL_PTR(s))) | 4024 | if (unlikely(ZERO_OR_NULL_PTR(s))) |
4012 | return s; | 4025 | return s; |
4013 | 4026 | ||
4014 | ret = slab_alloc(s, gfpflags, NUMA_NO_NODE, caller); | 4027 | ret = slab_alloc(s, gfpflags, caller); |
4015 | 4028 | ||
4016 | /* Honor the call site pointer we received. */ | 4029 | /* Honor the call site pointer we received. */ |
4017 | trace_kmalloc(caller, ret, size, s->size, gfpflags); | 4030 | trace_kmalloc(caller, ret, size, s->size, gfpflags); |
@@ -4041,7 +4054,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, | |||
4041 | if (unlikely(ZERO_OR_NULL_PTR(s))) | 4054 | if (unlikely(ZERO_OR_NULL_PTR(s))) |
4042 | return s; | 4055 | return s; |
4043 | 4056 | ||
4044 | ret = slab_alloc(s, gfpflags, node, caller); | 4057 | ret = slab_alloc_node(s, gfpflags, node, caller); |
4045 | 4058 | ||
4046 | /* Honor the call site pointer we received. */ | 4059 | /* Honor the call site pointer we received. */ |
4047 | trace_kmalloc_node(caller, ret, size, s->size, gfpflags, node); | 4060 | trace_kmalloc_node(caller, ret, size, s->size, gfpflags, node); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 8d01243d9560..99b434b674c0 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -3102,6 +3102,7 @@ int kswapd_run(int nid) | |||
3102 | /* failure at boot is fatal */ | 3102 | /* failure at boot is fatal */ |
3103 | BUG_ON(system_state == SYSTEM_BOOTING); | 3103 | BUG_ON(system_state == SYSTEM_BOOTING); |
3104 | printk("Failed to start kswapd on node %d\n",nid); | 3104 | printk("Failed to start kswapd on node %d\n",nid); |
3105 | pgdat->kswapd = NULL; | ||
3105 | ret = -1; | 3106 | ret = -1; |
3106 | } | 3107 | } |
3107 | return ret; | 3108 | return ret; |