diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/Kconfig | 2 | ||||
-rw-r--r-- | mm/hugetlb.c | 4 | ||||
-rw-r--r-- | mm/memory.c | 89 | ||||
-rw-r--r-- | mm/mmap.c | 4 | ||||
-rw-r--r-- | mm/nommu.c | 4 | ||||
-rw-r--r-- | mm/page-writeback.c | 1 | ||||
-rw-r--r-- | mm/page_alloc.c | 228 | ||||
-rw-r--r-- | mm/readahead.c | 31 | ||||
-rw-r--r-- | mm/slab.c | 131 | ||||
-rw-r--r-- | mm/swap.c | 1 | ||||
-rw-r--r-- | mm/swap_state.c | 1 | ||||
-rw-r--r-- | mm/swapfile.c | 2 | ||||
-rw-r--r-- | mm/vmalloc.c | 4 | ||||
-rw-r--r-- | mm/vmscan.c | 6 |
14 files changed, 263 insertions, 245 deletions
diff --git a/mm/Kconfig b/mm/Kconfig index 1a4473fcb2ca..ae9ce6b73e8a 100644 --- a/mm/Kconfig +++ b/mm/Kconfig | |||
@@ -126,9 +126,11 @@ comment "Memory hotplug is currently incompatible with Software Suspend" | |||
126 | # Default to 4 for wider testing, though 8 might be more appropriate. | 126 | # Default to 4 for wider testing, though 8 might be more appropriate. |
127 | # ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock. | 127 | # ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock. |
128 | # PA-RISC's debug spinlock_t is too large for the 32-bit struct page. | 128 | # PA-RISC's debug spinlock_t is too large for the 32-bit struct page. |
129 | # ARM26 and SPARC32 and PPC64 may use one page for multiple page tables. | ||
129 | # | 130 | # |
130 | config SPLIT_PTLOCK_CPUS | 131 | config SPLIT_PTLOCK_CPUS |
131 | int | 132 | int |
132 | default "4096" if ARM && !CPU_CACHE_VIPT | 133 | default "4096" if ARM && !CPU_CACHE_VIPT |
133 | default "4096" if PARISC && DEBUG_SPINLOCK && !64BIT | 134 | default "4096" if PARISC && DEBUG_SPINLOCK && !64BIT |
135 | default "4096" if ARM26 || SPARC32 || PPC64 | ||
134 | default "4" | 136 | default "4" |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index c9b43360fd33..728e9bda12ea 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -103,6 +103,9 @@ static int __init hugetlb_init(void) | |||
103 | unsigned long i; | 103 | unsigned long i; |
104 | struct page *page; | 104 | struct page *page; |
105 | 105 | ||
106 | if (HPAGE_SHIFT == 0) | ||
107 | return 0; | ||
108 | |||
106 | for (i = 0; i < MAX_NUMNODES; ++i) | 109 | for (i = 0; i < MAX_NUMNODES; ++i) |
107 | INIT_LIST_HEAD(&hugepage_freelists[i]); | 110 | INIT_LIST_HEAD(&hugepage_freelists[i]); |
108 | 111 | ||
@@ -234,7 +237,6 @@ unsigned long hugetlb_total_pages(void) | |||
234 | { | 237 | { |
235 | return nr_huge_pages * (HPAGE_SIZE / PAGE_SIZE); | 238 | return nr_huge_pages * (HPAGE_SIZE / PAGE_SIZE); |
236 | } | 239 | } |
237 | EXPORT_SYMBOL(hugetlb_total_pages); | ||
238 | 240 | ||
239 | /* | 241 | /* |
240 | * We cannot handle pagefaults against hugetlb pages at all. They cause | 242 | * We cannot handle pagefaults against hugetlb pages at all. They cause |
diff --git a/mm/memory.c b/mm/memory.c index 0f60baf6f69b..2998cfc12f5b 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -549,10 +549,10 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, | |||
549 | return 0; | 549 | return 0; |
550 | } | 550 | } |
551 | 551 | ||
552 | static void zap_pte_range(struct mmu_gather *tlb, | 552 | static unsigned long zap_pte_range(struct mmu_gather *tlb, |
553 | struct vm_area_struct *vma, pmd_t *pmd, | 553 | struct vm_area_struct *vma, pmd_t *pmd, |
554 | unsigned long addr, unsigned long end, | 554 | unsigned long addr, unsigned long end, |
555 | struct zap_details *details) | 555 | long *zap_work, struct zap_details *details) |
556 | { | 556 | { |
557 | struct mm_struct *mm = tlb->mm; | 557 | struct mm_struct *mm = tlb->mm; |
558 | pte_t *pte; | 558 | pte_t *pte; |
@@ -563,10 +563,15 @@ static void zap_pte_range(struct mmu_gather *tlb, | |||
563 | pte = pte_offset_map_lock(mm, pmd, addr, &ptl); | 563 | pte = pte_offset_map_lock(mm, pmd, addr, &ptl); |
564 | do { | 564 | do { |
565 | pte_t ptent = *pte; | 565 | pte_t ptent = *pte; |
566 | if (pte_none(ptent)) | 566 | if (pte_none(ptent)) { |
567 | (*zap_work)--; | ||
567 | continue; | 568 | continue; |
569 | } | ||
568 | if (pte_present(ptent)) { | 570 | if (pte_present(ptent)) { |
569 | struct page *page = NULL; | 571 | struct page *page = NULL; |
572 | |||
573 | (*zap_work) -= PAGE_SIZE; | ||
574 | |||
570 | if (!(vma->vm_flags & VM_RESERVED)) { | 575 | if (!(vma->vm_flags & VM_RESERVED)) { |
571 | unsigned long pfn = pte_pfn(ptent); | 576 | unsigned long pfn = pte_pfn(ptent); |
572 | if (unlikely(!pfn_valid(pfn))) | 577 | if (unlikely(!pfn_valid(pfn))) |
@@ -624,16 +629,18 @@ static void zap_pte_range(struct mmu_gather *tlb, | |||
624 | if (!pte_file(ptent)) | 629 | if (!pte_file(ptent)) |
625 | free_swap_and_cache(pte_to_swp_entry(ptent)); | 630 | free_swap_and_cache(pte_to_swp_entry(ptent)); |
626 | pte_clear_full(mm, addr, pte, tlb->fullmm); | 631 | pte_clear_full(mm, addr, pte, tlb->fullmm); |
627 | } while (pte++, addr += PAGE_SIZE, addr != end); | 632 | } while (pte++, addr += PAGE_SIZE, (addr != end && *zap_work > 0)); |
628 | 633 | ||
629 | add_mm_rss(mm, file_rss, anon_rss); | 634 | add_mm_rss(mm, file_rss, anon_rss); |
630 | pte_unmap_unlock(pte - 1, ptl); | 635 | pte_unmap_unlock(pte - 1, ptl); |
636 | |||
637 | return addr; | ||
631 | } | 638 | } |
632 | 639 | ||
633 | static inline void zap_pmd_range(struct mmu_gather *tlb, | 640 | static inline unsigned long zap_pmd_range(struct mmu_gather *tlb, |
634 | struct vm_area_struct *vma, pud_t *pud, | 641 | struct vm_area_struct *vma, pud_t *pud, |
635 | unsigned long addr, unsigned long end, | 642 | unsigned long addr, unsigned long end, |
636 | struct zap_details *details) | 643 | long *zap_work, struct zap_details *details) |
637 | { | 644 | { |
638 | pmd_t *pmd; | 645 | pmd_t *pmd; |
639 | unsigned long next; | 646 | unsigned long next; |
@@ -641,16 +648,21 @@ static inline void zap_pmd_range(struct mmu_gather *tlb, | |||
641 | pmd = pmd_offset(pud, addr); | 648 | pmd = pmd_offset(pud, addr); |
642 | do { | 649 | do { |
643 | next = pmd_addr_end(addr, end); | 650 | next = pmd_addr_end(addr, end); |
644 | if (pmd_none_or_clear_bad(pmd)) | 651 | if (pmd_none_or_clear_bad(pmd)) { |
652 | (*zap_work)--; | ||
645 | continue; | 653 | continue; |
646 | zap_pte_range(tlb, vma, pmd, addr, next, details); | 654 | } |
647 | } while (pmd++, addr = next, addr != end); | 655 | next = zap_pte_range(tlb, vma, pmd, addr, next, |
656 | zap_work, details); | ||
657 | } while (pmd++, addr = next, (addr != end && *zap_work > 0)); | ||
658 | |||
659 | return addr; | ||
648 | } | 660 | } |
649 | 661 | ||
650 | static inline void zap_pud_range(struct mmu_gather *tlb, | 662 | static inline unsigned long zap_pud_range(struct mmu_gather *tlb, |
651 | struct vm_area_struct *vma, pgd_t *pgd, | 663 | struct vm_area_struct *vma, pgd_t *pgd, |
652 | unsigned long addr, unsigned long end, | 664 | unsigned long addr, unsigned long end, |
653 | struct zap_details *details) | 665 | long *zap_work, struct zap_details *details) |
654 | { | 666 | { |
655 | pud_t *pud; | 667 | pud_t *pud; |
656 | unsigned long next; | 668 | unsigned long next; |
@@ -658,15 +670,21 @@ static inline void zap_pud_range(struct mmu_gather *tlb, | |||
658 | pud = pud_offset(pgd, addr); | 670 | pud = pud_offset(pgd, addr); |
659 | do { | 671 | do { |
660 | next = pud_addr_end(addr, end); | 672 | next = pud_addr_end(addr, end); |
661 | if (pud_none_or_clear_bad(pud)) | 673 | if (pud_none_or_clear_bad(pud)) { |
674 | (*zap_work)--; | ||
662 | continue; | 675 | continue; |
663 | zap_pmd_range(tlb, vma, pud, addr, next, details); | 676 | } |
664 | } while (pud++, addr = next, addr != end); | 677 | next = zap_pmd_range(tlb, vma, pud, addr, next, |
678 | zap_work, details); | ||
679 | } while (pud++, addr = next, (addr != end && *zap_work > 0)); | ||
680 | |||
681 | return addr; | ||
665 | } | 682 | } |
666 | 683 | ||
667 | static void unmap_page_range(struct mmu_gather *tlb, struct vm_area_struct *vma, | 684 | static unsigned long unmap_page_range(struct mmu_gather *tlb, |
685 | struct vm_area_struct *vma, | ||
668 | unsigned long addr, unsigned long end, | 686 | unsigned long addr, unsigned long end, |
669 | struct zap_details *details) | 687 | long *zap_work, struct zap_details *details) |
670 | { | 688 | { |
671 | pgd_t *pgd; | 689 | pgd_t *pgd; |
672 | unsigned long next; | 690 | unsigned long next; |
@@ -679,11 +697,16 @@ static void unmap_page_range(struct mmu_gather *tlb, struct vm_area_struct *vma, | |||
679 | pgd = pgd_offset(vma->vm_mm, addr); | 697 | pgd = pgd_offset(vma->vm_mm, addr); |
680 | do { | 698 | do { |
681 | next = pgd_addr_end(addr, end); | 699 | next = pgd_addr_end(addr, end); |
682 | if (pgd_none_or_clear_bad(pgd)) | 700 | if (pgd_none_or_clear_bad(pgd)) { |
701 | (*zap_work)--; | ||
683 | continue; | 702 | continue; |
684 | zap_pud_range(tlb, vma, pgd, addr, next, details); | 703 | } |
685 | } while (pgd++, addr = next, addr != end); | 704 | next = zap_pud_range(tlb, vma, pgd, addr, next, |
705 | zap_work, details); | ||
706 | } while (pgd++, addr = next, (addr != end && *zap_work > 0)); | ||
686 | tlb_end_vma(tlb, vma); | 707 | tlb_end_vma(tlb, vma); |
708 | |||
709 | return addr; | ||
687 | } | 710 | } |
688 | 711 | ||
689 | #ifdef CONFIG_PREEMPT | 712 | #ifdef CONFIG_PREEMPT |
@@ -724,7 +747,7 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp, | |||
724 | unsigned long end_addr, unsigned long *nr_accounted, | 747 | unsigned long end_addr, unsigned long *nr_accounted, |
725 | struct zap_details *details) | 748 | struct zap_details *details) |
726 | { | 749 | { |
727 | unsigned long zap_bytes = ZAP_BLOCK_SIZE; | 750 | long zap_work = ZAP_BLOCK_SIZE; |
728 | unsigned long tlb_start = 0; /* For tlb_finish_mmu */ | 751 | unsigned long tlb_start = 0; /* For tlb_finish_mmu */ |
729 | int tlb_start_valid = 0; | 752 | int tlb_start_valid = 0; |
730 | unsigned long start = start_addr; | 753 | unsigned long start = start_addr; |
@@ -745,27 +768,25 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp, | |||
745 | *nr_accounted += (end - start) >> PAGE_SHIFT; | 768 | *nr_accounted += (end - start) >> PAGE_SHIFT; |
746 | 769 | ||
747 | while (start != end) { | 770 | while (start != end) { |
748 | unsigned long block; | ||
749 | |||
750 | if (!tlb_start_valid) { | 771 | if (!tlb_start_valid) { |
751 | tlb_start = start; | 772 | tlb_start = start; |
752 | tlb_start_valid = 1; | 773 | tlb_start_valid = 1; |
753 | } | 774 | } |
754 | 775 | ||
755 | if (is_vm_hugetlb_page(vma)) { | 776 | if (unlikely(is_vm_hugetlb_page(vma))) { |
756 | block = end - start; | ||
757 | unmap_hugepage_range(vma, start, end); | 777 | unmap_hugepage_range(vma, start, end); |
758 | } else { | 778 | zap_work -= (end - start) / |
759 | block = min(zap_bytes, end - start); | 779 | (HPAGE_SIZE / PAGE_SIZE); |
760 | unmap_page_range(*tlbp, vma, start, | 780 | start = end; |
761 | start + block, details); | 781 | } else |
782 | start = unmap_page_range(*tlbp, vma, | ||
783 | start, end, &zap_work, details); | ||
784 | |||
785 | if (zap_work > 0) { | ||
786 | BUG_ON(start != end); | ||
787 | break; | ||
762 | } | 788 | } |
763 | 789 | ||
764 | start += block; | ||
765 | zap_bytes -= block; | ||
766 | if ((long)zap_bytes > 0) | ||
767 | continue; | ||
768 | |||
769 | tlb_finish_mmu(*tlbp, tlb_start, start); | 790 | tlb_finish_mmu(*tlbp, tlb_start, start); |
770 | 791 | ||
771 | if (need_resched() || | 792 | if (need_resched() || |
@@ -779,7 +800,7 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp, | |||
779 | 800 | ||
780 | *tlbp = tlb_gather_mmu(vma->vm_mm, fullmm); | 801 | *tlbp = tlb_gather_mmu(vma->vm_mm, fullmm); |
781 | tlb_start_valid = 0; | 802 | tlb_start_valid = 0; |
782 | zap_bytes = ZAP_BLOCK_SIZE; | 803 | zap_work = ZAP_BLOCK_SIZE; |
783 | } | 804 | } |
784 | } | 805 | } |
785 | out: | 806 | out: |
@@ -155,10 +155,6 @@ int __vm_enough_memory(long pages, int cap_sys_admin) | |||
155 | return -ENOMEM; | 155 | return -ENOMEM; |
156 | } | 156 | } |
157 | 157 | ||
158 | EXPORT_SYMBOL(sysctl_overcommit_memory); | ||
159 | EXPORT_SYMBOL(sysctl_overcommit_ratio); | ||
160 | EXPORT_SYMBOL(sysctl_max_map_count); | ||
161 | EXPORT_SYMBOL(vm_committed_space); | ||
162 | EXPORT_SYMBOL(__vm_enough_memory); | 158 | EXPORT_SYMBOL(__vm_enough_memory); |
163 | 159 | ||
164 | /* | 160 | /* |
diff --git a/mm/nommu.c b/mm/nommu.c index d1e076a487cb..6deb6ab3d6ad 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -44,10 +44,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT; | |||
44 | int heap_stack_gap = 0; | 44 | int heap_stack_gap = 0; |
45 | 45 | ||
46 | EXPORT_SYMBOL(mem_map); | 46 | EXPORT_SYMBOL(mem_map); |
47 | EXPORT_SYMBOL(sysctl_max_map_count); | ||
48 | EXPORT_SYMBOL(sysctl_overcommit_memory); | ||
49 | EXPORT_SYMBOL(sysctl_overcommit_ratio); | ||
50 | EXPORT_SYMBOL(vm_committed_space); | ||
51 | EXPORT_SYMBOL(__vm_enough_memory); | 47 | EXPORT_SYMBOL(__vm_enough_memory); |
52 | 48 | ||
53 | /* list of shareable VMAs */ | 49 | /* list of shareable VMAs */ |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 0166ea15c9ee..74138c9a22b9 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -750,7 +750,6 @@ int clear_page_dirty_for_io(struct page *page) | |||
750 | } | 750 | } |
751 | return TestClearPageDirty(page); | 751 | return TestClearPageDirty(page); |
752 | } | 752 | } |
753 | EXPORT_SYMBOL(clear_page_dirty_for_io); | ||
754 | 753 | ||
755 | int test_clear_page_writeback(struct page *page) | 754 | int test_clear_page_writeback(struct page *page) |
756 | { | 755 | { |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 259a71bacca4..104e69ca55e0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -67,7 +67,6 @@ long nr_swap_pages; | |||
67 | int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { 256, 256, 32 }; | 67 | int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { 256, 256, 32 }; |
68 | 68 | ||
69 | EXPORT_SYMBOL(totalram_pages); | 69 | EXPORT_SYMBOL(totalram_pages); |
70 | EXPORT_SYMBOL(nr_swap_pages); | ||
71 | 70 | ||
72 | /* | 71 | /* |
73 | * Used by page_zone() to look up the address of the struct zone whose | 72 | * Used by page_zone() to look up the address of the struct zone whose |
@@ -736,9 +735,7 @@ buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags) | |||
736 | } | 735 | } |
737 | local_irq_restore(flags); | 736 | local_irq_restore(flags); |
738 | put_cpu(); | 737 | put_cpu(); |
739 | } | 738 | } else { |
740 | |||
741 | if (page == NULL) { | ||
742 | spin_lock_irqsave(&zone->lock, flags); | 739 | spin_lock_irqsave(&zone->lock, flags); |
743 | page = __rmqueue(zone, order); | 740 | page = __rmqueue(zone, order); |
744 | spin_unlock_irqrestore(&zone->lock, flags); | 741 | spin_unlock_irqrestore(&zone->lock, flags); |
@@ -758,20 +755,25 @@ buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags) | |||
758 | return page; | 755 | return page; |
759 | } | 756 | } |
760 | 757 | ||
758 | #define ALLOC_NO_WATERMARKS 0x01 /* don't check watermarks at all */ | ||
759 | #define ALLOC_HARDER 0x02 /* try to alloc harder */ | ||
760 | #define ALLOC_HIGH 0x04 /* __GFP_HIGH set */ | ||
761 | #define ALLOC_CPUSET 0x08 /* check for correct cpuset */ | ||
762 | |||
761 | /* | 763 | /* |
762 | * Return 1 if free pages are above 'mark'. This takes into account the order | 764 | * Return 1 if free pages are above 'mark'. This takes into account the order |
763 | * of the allocation. | 765 | * of the allocation. |
764 | */ | 766 | */ |
765 | int zone_watermark_ok(struct zone *z, int order, unsigned long mark, | 767 | int zone_watermark_ok(struct zone *z, int order, unsigned long mark, |
766 | int classzone_idx, int can_try_harder, gfp_t gfp_high) | 768 | int classzone_idx, int alloc_flags) |
767 | { | 769 | { |
768 | /* free_pages my go negative - that's OK */ | 770 | /* free_pages my go negative - that's OK */ |
769 | long min = mark, free_pages = z->free_pages - (1 << order) + 1; | 771 | long min = mark, free_pages = z->free_pages - (1 << order) + 1; |
770 | int o; | 772 | int o; |
771 | 773 | ||
772 | if (gfp_high) | 774 | if (alloc_flags & ALLOC_HIGH) |
773 | min -= min / 2; | 775 | min -= min / 2; |
774 | if (can_try_harder) | 776 | if (alloc_flags & ALLOC_HARDER) |
775 | min -= min / 4; | 777 | min -= min / 4; |
776 | 778 | ||
777 | if (free_pages <= min + z->lowmem_reserve[classzone_idx]) | 779 | if (free_pages <= min + z->lowmem_reserve[classzone_idx]) |
@@ -789,14 +791,40 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark, | |||
789 | return 1; | 791 | return 1; |
790 | } | 792 | } |
791 | 793 | ||
792 | static inline int | 794 | /* |
793 | should_reclaim_zone(struct zone *z, gfp_t gfp_mask) | 795 | * get_page_from_freeliest goes through the zonelist trying to allocate |
796 | * a page. | ||
797 | */ | ||
798 | static struct page * | ||
799 | get_page_from_freelist(gfp_t gfp_mask, unsigned int order, | ||
800 | struct zonelist *zonelist, int alloc_flags) | ||
794 | { | 801 | { |
795 | if (!z->reclaim_pages) | 802 | struct zone **z = zonelist->zones; |
796 | return 0; | 803 | struct page *page = NULL; |
797 | if (gfp_mask & __GFP_NORECLAIM) | 804 | int classzone_idx = zone_idx(*z); |
798 | return 0; | 805 | |
799 | return 1; | 806 | /* |
807 | * Go through the zonelist once, looking for a zone with enough free. | ||
808 | * See also cpuset_zone_allowed() comment in kernel/cpuset.c. | ||
809 | */ | ||
810 | do { | ||
811 | if ((alloc_flags & ALLOC_CPUSET) && | ||
812 | !cpuset_zone_allowed(*z, gfp_mask)) | ||
813 | continue; | ||
814 | |||
815 | if (!(alloc_flags & ALLOC_NO_WATERMARKS)) { | ||
816 | if (!zone_watermark_ok(*z, order, (*z)->pages_low, | ||
817 | classzone_idx, alloc_flags)) | ||
818 | continue; | ||
819 | } | ||
820 | |||
821 | page = buffered_rmqueue(*z, order, gfp_mask); | ||
822 | if (page) { | ||
823 | zone_statistics(zonelist, *z); | ||
824 | break; | ||
825 | } | ||
826 | } while (*(++z) != NULL); | ||
827 | return page; | ||
800 | } | 828 | } |
801 | 829 | ||
802 | /* | 830 | /* |
@@ -807,105 +835,75 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, | |||
807 | struct zonelist *zonelist) | 835 | struct zonelist *zonelist) |
808 | { | 836 | { |
809 | const gfp_t wait = gfp_mask & __GFP_WAIT; | 837 | const gfp_t wait = gfp_mask & __GFP_WAIT; |
810 | struct zone **zones, *z; | 838 | struct zone **z; |
811 | struct page *page; | 839 | struct page *page; |
812 | struct reclaim_state reclaim_state; | 840 | struct reclaim_state reclaim_state; |
813 | struct task_struct *p = current; | 841 | struct task_struct *p = current; |
814 | int i; | ||
815 | int classzone_idx; | ||
816 | int do_retry; | 842 | int do_retry; |
817 | int can_try_harder; | 843 | int alloc_flags; |
818 | int did_some_progress; | 844 | int did_some_progress; |
819 | 845 | ||
820 | might_sleep_if(wait); | 846 | might_sleep_if(wait); |
821 | 847 | ||
822 | /* | 848 | z = zonelist->zones; /* the list of zones suitable for gfp_mask */ |
823 | * The caller may dip into page reserves a bit more if the caller | ||
824 | * cannot run direct reclaim, or is the caller has realtime scheduling | ||
825 | * policy | ||
826 | */ | ||
827 | can_try_harder = (unlikely(rt_task(p)) && !in_interrupt()) || !wait; | ||
828 | 849 | ||
829 | zones = zonelist->zones; /* the list of zones suitable for gfp_mask */ | 850 | if (unlikely(*z == NULL)) { |
830 | |||
831 | if (unlikely(zones[0] == NULL)) { | ||
832 | /* Should this ever happen?? */ | 851 | /* Should this ever happen?? */ |
833 | return NULL; | 852 | return NULL; |
834 | } | 853 | } |
854 | restart: | ||
855 | page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order, | ||
856 | zonelist, ALLOC_CPUSET); | ||
857 | if (page) | ||
858 | goto got_pg; | ||
835 | 859 | ||
836 | classzone_idx = zone_idx(zones[0]); | 860 | do |
861 | wakeup_kswapd(*z, order); | ||
862 | while (*(++z)); | ||
837 | 863 | ||
838 | restart: | ||
839 | /* | 864 | /* |
840 | * Go through the zonelist once, looking for a zone with enough free. | 865 | * OK, we're below the kswapd watermark and have kicked background |
841 | * See also cpuset_zone_allowed() comment in kernel/cpuset.c. | 866 | * reclaim. Now things get more complex, so set up alloc_flags according |
867 | * to how we want to proceed. | ||
868 | * | ||
869 | * The caller may dip into page reserves a bit more if the caller | ||
870 | * cannot run direct reclaim, or if the caller has realtime scheduling | ||
871 | * policy. | ||
842 | */ | 872 | */ |
843 | for (i = 0; (z = zones[i]) != NULL; i++) { | 873 | alloc_flags = 0; |
844 | int do_reclaim = should_reclaim_zone(z, gfp_mask); | 874 | if ((unlikely(rt_task(p)) && !in_interrupt()) || !wait) |
845 | 875 | alloc_flags |= ALLOC_HARDER; | |
846 | if (!cpuset_zone_allowed(z, __GFP_HARDWALL)) | 876 | if (gfp_mask & __GFP_HIGH) |
847 | continue; | 877 | alloc_flags |= ALLOC_HIGH; |
848 | 878 | if (wait) | |
849 | /* | 879 | alloc_flags |= ALLOC_CPUSET; |
850 | * If the zone is to attempt early page reclaim then this loop | ||
851 | * will try to reclaim pages and check the watermark a second | ||
852 | * time before giving up and falling back to the next zone. | ||
853 | */ | ||
854 | zone_reclaim_retry: | ||
855 | if (!zone_watermark_ok(z, order, z->pages_low, | ||
856 | classzone_idx, 0, 0)) { | ||
857 | if (!do_reclaim) | ||
858 | continue; | ||
859 | else { | ||
860 | zone_reclaim(z, gfp_mask, order); | ||
861 | /* Only try reclaim once */ | ||
862 | do_reclaim = 0; | ||
863 | goto zone_reclaim_retry; | ||
864 | } | ||
865 | } | ||
866 | |||
867 | page = buffered_rmqueue(z, order, gfp_mask); | ||
868 | if (page) | ||
869 | goto got_pg; | ||
870 | } | ||
871 | |||
872 | for (i = 0; (z = zones[i]) != NULL; i++) | ||
873 | wakeup_kswapd(z, order); | ||
874 | 880 | ||
875 | /* | 881 | /* |
876 | * Go through the zonelist again. Let __GFP_HIGH and allocations | 882 | * Go through the zonelist again. Let __GFP_HIGH and allocations |
877 | * coming from realtime tasks to go deeper into reserves | 883 | * coming from realtime tasks go deeper into reserves. |
878 | * | 884 | * |
879 | * This is the last chance, in general, before the goto nopage. | 885 | * This is the last chance, in general, before the goto nopage. |
880 | * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc. | 886 | * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc. |
881 | * See also cpuset_zone_allowed() comment in kernel/cpuset.c. | 887 | * See also cpuset_zone_allowed() comment in kernel/cpuset.c. |
882 | */ | 888 | */ |
883 | for (i = 0; (z = zones[i]) != NULL; i++) { | 889 | page = get_page_from_freelist(gfp_mask, order, zonelist, alloc_flags); |
884 | if (!zone_watermark_ok(z, order, z->pages_min, | 890 | if (page) |
885 | classzone_idx, can_try_harder, | 891 | goto got_pg; |
886 | gfp_mask & __GFP_HIGH)) | ||
887 | continue; | ||
888 | |||
889 | if (wait && !cpuset_zone_allowed(z, gfp_mask)) | ||
890 | continue; | ||
891 | |||
892 | page = buffered_rmqueue(z, order, gfp_mask); | ||
893 | if (page) | ||
894 | goto got_pg; | ||
895 | } | ||
896 | 892 | ||
897 | /* This allocation should allow future memory freeing. */ | 893 | /* This allocation should allow future memory freeing. */ |
898 | 894 | ||
899 | if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) | 895 | if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) |
900 | && !in_interrupt()) { | 896 | && !in_interrupt()) { |
901 | if (!(gfp_mask & __GFP_NOMEMALLOC)) { | 897 | if (!(gfp_mask & __GFP_NOMEMALLOC)) { |
898 | nofail_alloc: | ||
902 | /* go through the zonelist yet again, ignoring mins */ | 899 | /* go through the zonelist yet again, ignoring mins */ |
903 | for (i = 0; (z = zones[i]) != NULL; i++) { | 900 | page = get_page_from_freelist(gfp_mask, order, |
904 | if (!cpuset_zone_allowed(z, gfp_mask)) | 901 | zonelist, ALLOC_NO_WATERMARKS|ALLOC_CPUSET); |
905 | continue; | 902 | if (page) |
906 | page = buffered_rmqueue(z, order, gfp_mask); | 903 | goto got_pg; |
907 | if (page) | 904 | if (gfp_mask & __GFP_NOFAIL) { |
908 | goto got_pg; | 905 | blk_congestion_wait(WRITE, HZ/50); |
906 | goto nofail_alloc; | ||
909 | } | 907 | } |
910 | } | 908 | } |
911 | goto nopage; | 909 | goto nopage; |
@@ -923,7 +921,7 @@ rebalance: | |||
923 | reclaim_state.reclaimed_slab = 0; | 921 | reclaim_state.reclaimed_slab = 0; |
924 | p->reclaim_state = &reclaim_state; | 922 | p->reclaim_state = &reclaim_state; |
925 | 923 | ||
926 | did_some_progress = try_to_free_pages(zones, gfp_mask); | 924 | did_some_progress = try_to_free_pages(zonelist->zones, gfp_mask); |
927 | 925 | ||
928 | p->reclaim_state = NULL; | 926 | p->reclaim_state = NULL; |
929 | p->flags &= ~PF_MEMALLOC; | 927 | p->flags &= ~PF_MEMALLOC; |
@@ -931,19 +929,10 @@ rebalance: | |||
931 | cond_resched(); | 929 | cond_resched(); |
932 | 930 | ||
933 | if (likely(did_some_progress)) { | 931 | if (likely(did_some_progress)) { |
934 | for (i = 0; (z = zones[i]) != NULL; i++) { | 932 | page = get_page_from_freelist(gfp_mask, order, |
935 | if (!zone_watermark_ok(z, order, z->pages_min, | 933 | zonelist, alloc_flags); |
936 | classzone_idx, can_try_harder, | 934 | if (page) |
937 | gfp_mask & __GFP_HIGH)) | 935 | goto got_pg; |
938 | continue; | ||
939 | |||
940 | if (!cpuset_zone_allowed(z, gfp_mask)) | ||
941 | continue; | ||
942 | |||
943 | page = buffered_rmqueue(z, order, gfp_mask); | ||
944 | if (page) | ||
945 | goto got_pg; | ||
946 | } | ||
947 | } else if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY)) { | 936 | } else if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY)) { |
948 | /* | 937 | /* |
949 | * Go through the zonelist yet one more time, keep | 938 | * Go through the zonelist yet one more time, keep |
@@ -951,18 +940,10 @@ rebalance: | |||
951 | * a parallel oom killing, we must fail if we're still | 940 | * a parallel oom killing, we must fail if we're still |
952 | * under heavy pressure. | 941 | * under heavy pressure. |
953 | */ | 942 | */ |
954 | for (i = 0; (z = zones[i]) != NULL; i++) { | 943 | page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order, |
955 | if (!zone_watermark_ok(z, order, z->pages_high, | 944 | zonelist, ALLOC_CPUSET); |
956 | classzone_idx, 0, 0)) | 945 | if (page) |
957 | continue; | 946 | goto got_pg; |
958 | |||
959 | if (!cpuset_zone_allowed(z, __GFP_HARDWALL)) | ||
960 | continue; | ||
961 | |||
962 | page = buffered_rmqueue(z, order, gfp_mask); | ||
963 | if (page) | ||
964 | goto got_pg; | ||
965 | } | ||
966 | 947 | ||
967 | out_of_memory(gfp_mask, order); | 948 | out_of_memory(gfp_mask, order); |
968 | goto restart; | 949 | goto restart; |
@@ -995,9 +976,7 @@ nopage: | |||
995 | dump_stack(); | 976 | dump_stack(); |
996 | show_mem(); | 977 | show_mem(); |
997 | } | 978 | } |
998 | return NULL; | ||
999 | got_pg: | 979 | got_pg: |
1000 | zone_statistics(zonelist, z); | ||
1001 | return page; | 980 | return page; |
1002 | } | 981 | } |
1003 | 982 | ||
@@ -1334,7 +1313,7 @@ void show_free_areas(void) | |||
1334 | } else | 1313 | } else |
1335 | printk("\n"); | 1314 | printk("\n"); |
1336 | 1315 | ||
1337 | for_each_cpu(cpu) { | 1316 | for_each_online_cpu(cpu) { |
1338 | struct per_cpu_pageset *pageset; | 1317 | struct per_cpu_pageset *pageset; |
1339 | 1318 | ||
1340 | pageset = zone_pcp(zone, cpu); | 1319 | pageset = zone_pcp(zone, cpu); |
@@ -2426,13 +2405,18 @@ void setup_per_zone_pages_min(void) | |||
2426 | } | 2405 | } |
2427 | 2406 | ||
2428 | for_each_zone(zone) { | 2407 | for_each_zone(zone) { |
2408 | unsigned long tmp; | ||
2429 | spin_lock_irqsave(&zone->lru_lock, flags); | 2409 | spin_lock_irqsave(&zone->lru_lock, flags); |
2410 | tmp = (pages_min * zone->present_pages) / lowmem_pages; | ||
2430 | if (is_highmem(zone)) { | 2411 | if (is_highmem(zone)) { |
2431 | /* | 2412 | /* |
2432 | * Often, highmem doesn't need to reserve any pages. | 2413 | * __GFP_HIGH and PF_MEMALLOC allocations usually don't |
2433 | * But the pages_min/low/high values are also used for | 2414 | * need highmem pages, so cap pages_min to a small |
2434 | * batching up page reclaim activity so we need a | 2415 | * value here. |
2435 | * decent value here. | 2416 | * |
2417 | * The (pages_high-pages_low) and (pages_low-pages_min) | ||
2418 | * deltas controls asynch page reclaim, and so should | ||
2419 | * not be capped for highmem. | ||
2436 | */ | 2420 | */ |
2437 | int min_pages; | 2421 | int min_pages; |
2438 | 2422 | ||
@@ -2443,19 +2427,15 @@ void setup_per_zone_pages_min(void) | |||
2443 | min_pages = 128; | 2427 | min_pages = 128; |
2444 | zone->pages_min = min_pages; | 2428 | zone->pages_min = min_pages; |
2445 | } else { | 2429 | } else { |
2446 | /* if it's a lowmem zone, reserve a number of pages | 2430 | /* |
2431 | * If it's a lowmem zone, reserve a number of pages | ||
2447 | * proportionate to the zone's size. | 2432 | * proportionate to the zone's size. |
2448 | */ | 2433 | */ |
2449 | zone->pages_min = (pages_min * zone->present_pages) / | 2434 | zone->pages_min = tmp; |
2450 | lowmem_pages; | ||
2451 | } | 2435 | } |
2452 | 2436 | ||
2453 | /* | 2437 | zone->pages_low = zone->pages_min + tmp / 4; |
2454 | * When interpreting these watermarks, just keep in mind that: | 2438 | zone->pages_high = zone->pages_min + tmp / 2; |
2455 | * zone->pages_min == (zone->pages_min * 4) / 4; | ||
2456 | */ | ||
2457 | zone->pages_low = (zone->pages_min * 5) / 4; | ||
2458 | zone->pages_high = (zone->pages_min * 6) / 4; | ||
2459 | spin_unlock_irqrestore(&zone->lru_lock, flags); | 2439 | spin_unlock_irqrestore(&zone->lru_lock, flags); |
2460 | } | 2440 | } |
2461 | } | 2441 | } |
diff --git a/mm/readahead.c b/mm/readahead.c index d0b50034e245..72e7adbb87c7 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
@@ -254,7 +254,7 @@ out: | |||
254 | */ | 254 | */ |
255 | static int | 255 | static int |
256 | __do_page_cache_readahead(struct address_space *mapping, struct file *filp, | 256 | __do_page_cache_readahead(struct address_space *mapping, struct file *filp, |
257 | unsigned long offset, unsigned long nr_to_read) | 257 | pgoff_t offset, unsigned long nr_to_read) |
258 | { | 258 | { |
259 | struct inode *inode = mapping->host; | 259 | struct inode *inode = mapping->host; |
260 | struct page *page; | 260 | struct page *page; |
@@ -274,7 +274,7 @@ __do_page_cache_readahead(struct address_space *mapping, struct file *filp, | |||
274 | */ | 274 | */ |
275 | read_lock_irq(&mapping->tree_lock); | 275 | read_lock_irq(&mapping->tree_lock); |
276 | for (page_idx = 0; page_idx < nr_to_read; page_idx++) { | 276 | for (page_idx = 0; page_idx < nr_to_read; page_idx++) { |
277 | unsigned long page_offset = offset + page_idx; | 277 | pgoff_t page_offset = offset + page_idx; |
278 | 278 | ||
279 | if (page_offset > end_index) | 279 | if (page_offset > end_index) |
280 | break; | 280 | break; |
@@ -311,7 +311,7 @@ out: | |||
311 | * memory at once. | 311 | * memory at once. |
312 | */ | 312 | */ |
313 | int force_page_cache_readahead(struct address_space *mapping, struct file *filp, | 313 | int force_page_cache_readahead(struct address_space *mapping, struct file *filp, |
314 | unsigned long offset, unsigned long nr_to_read) | 314 | pgoff_t offset, unsigned long nr_to_read) |
315 | { | 315 | { |
316 | int ret = 0; | 316 | int ret = 0; |
317 | 317 | ||
@@ -368,7 +368,7 @@ static inline int check_ra_success(struct file_ra_state *ra, | |||
368 | * request queues. | 368 | * request queues. |
369 | */ | 369 | */ |
370 | int do_page_cache_readahead(struct address_space *mapping, struct file *filp, | 370 | int do_page_cache_readahead(struct address_space *mapping, struct file *filp, |
371 | unsigned long offset, unsigned long nr_to_read) | 371 | pgoff_t offset, unsigned long nr_to_read) |
372 | { | 372 | { |
373 | if (bdi_read_congested(mapping->backing_dev_info)) | 373 | if (bdi_read_congested(mapping->backing_dev_info)) |
374 | return -1; | 374 | return -1; |
@@ -385,7 +385,7 @@ int do_page_cache_readahead(struct address_space *mapping, struct file *filp, | |||
385 | */ | 385 | */ |
386 | static int | 386 | static int |
387 | blockable_page_cache_readahead(struct address_space *mapping, struct file *filp, | 387 | blockable_page_cache_readahead(struct address_space *mapping, struct file *filp, |
388 | unsigned long offset, unsigned long nr_to_read, | 388 | pgoff_t offset, unsigned long nr_to_read, |
389 | struct file_ra_state *ra, int block) | 389 | struct file_ra_state *ra, int block) |
390 | { | 390 | { |
391 | int actual; | 391 | int actual; |
@@ -430,14 +430,27 @@ static int make_ahead_window(struct address_space *mapping, struct file *filp, | |||
430 | return ret; | 430 | return ret; |
431 | } | 431 | } |
432 | 432 | ||
433 | /* | 433 | /** |
434 | * page_cache_readahead is the main function. If performs the adaptive | 434 | * page_cache_readahead - generic adaptive readahead |
435 | * @mapping: address_space which holds the pagecache and I/O vectors | ||
436 | * @ra: file_ra_state which holds the readahead state | ||
437 | * @filp: passed on to ->readpage() and ->readpages() | ||
438 | * @offset: start offset into @mapping, in PAGE_CACHE_SIZE units | ||
439 | * @req_size: hint: total size of the read which the caller is performing in | ||
440 | * PAGE_CACHE_SIZE units | ||
441 | * | ||
442 | * page_cache_readahead() is the main function. If performs the adaptive | ||
435 | * readahead window size management and submits the readahead I/O. | 443 | * readahead window size management and submits the readahead I/O. |
444 | * | ||
445 | * Note that @filp is purely used for passing on to the ->readpage[s]() | ||
446 | * handler: it may refer to a different file from @mapping (so we may not use | ||
447 | * @filp->f_mapping or @filp->f_dentry->d_inode here). | ||
448 | * Also, @ra may not be equal to &@filp->f_ra. | ||
449 | * | ||
436 | */ | 450 | */ |
437 | unsigned long | 451 | unsigned long |
438 | page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, | 452 | page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, |
439 | struct file *filp, unsigned long offset, | 453 | struct file *filp, pgoff_t offset, unsigned long req_size) |
440 | unsigned long req_size) | ||
441 | { | 454 | { |
442 | unsigned long max, newsize; | 455 | unsigned long max, newsize; |
443 | int sequential; | 456 | int sequential; |
@@ -368,7 +368,7 @@ static inline void kmem_list3_init(struct kmem_list3 *parent) | |||
368 | * manages a cache. | 368 | * manages a cache. |
369 | */ | 369 | */ |
370 | 370 | ||
371 | struct kmem_cache_s { | 371 | struct kmem_cache { |
372 | /* 1) per-cpu data, touched during every alloc/free */ | 372 | /* 1) per-cpu data, touched during every alloc/free */ |
373 | struct array_cache *array[NR_CPUS]; | 373 | struct array_cache *array[NR_CPUS]; |
374 | unsigned int batchcount; | 374 | unsigned int batchcount; |
@@ -434,7 +434,7 @@ struct kmem_cache_s { | |||
434 | /* Optimization question: fewer reaps means less | 434 | /* Optimization question: fewer reaps means less |
435 | * probability for unnessary cpucache drain/refill cycles. | 435 | * probability for unnessary cpucache drain/refill cycles. |
436 | * | 436 | * |
437 | * OTHO the cpuarrays can contain lots of objects, | 437 | * OTOH the cpuarrays can contain lots of objects, |
438 | * which could lock up otherwise freeable slabs. | 438 | * which could lock up otherwise freeable slabs. |
439 | */ | 439 | */ |
440 | #define REAPTIMEOUT_CPUC (2*HZ) | 440 | #define REAPTIMEOUT_CPUC (2*HZ) |
@@ -565,14 +565,29 @@ static void **dbg_userword(kmem_cache_t *cachep, void *objp) | |||
565 | #define BREAK_GFP_ORDER_LO 0 | 565 | #define BREAK_GFP_ORDER_LO 0 |
566 | static int slab_break_gfp_order = BREAK_GFP_ORDER_LO; | 566 | static int slab_break_gfp_order = BREAK_GFP_ORDER_LO; |
567 | 567 | ||
568 | /* Macros for storing/retrieving the cachep and or slab from the | 568 | /* Functions for storing/retrieving the cachep and or slab from the |
569 | * global 'mem_map'. These are used to find the slab an obj belongs to. | 569 | * global 'mem_map'. These are used to find the slab an obj belongs to. |
570 | * With kfree(), these are used to find the cache which an obj belongs to. | 570 | * With kfree(), these are used to find the cache which an obj belongs to. |
571 | */ | 571 | */ |
572 | #define SET_PAGE_CACHE(pg,x) ((pg)->lru.next = (struct list_head *)(x)) | 572 | static inline void page_set_cache(struct page *page, struct kmem_cache *cache) |
573 | #define GET_PAGE_CACHE(pg) ((kmem_cache_t *)(pg)->lru.next) | 573 | { |
574 | #define SET_PAGE_SLAB(pg,x) ((pg)->lru.prev = (struct list_head *)(x)) | 574 | page->lru.next = (struct list_head *)cache; |
575 | #define GET_PAGE_SLAB(pg) ((struct slab *)(pg)->lru.prev) | 575 | } |
576 | |||
577 | static inline struct kmem_cache *page_get_cache(struct page *page) | ||
578 | { | ||
579 | return (struct kmem_cache *)page->lru.next; | ||
580 | } | ||
581 | |||
582 | static inline void page_set_slab(struct page *page, struct slab *slab) | ||
583 | { | ||
584 | page->lru.prev = (struct list_head *)slab; | ||
585 | } | ||
586 | |||
587 | static inline struct slab *page_get_slab(struct page *page) | ||
588 | { | ||
589 | return (struct slab *)page->lru.prev; | ||
590 | } | ||
576 | 591 | ||
577 | /* These are the default caches for kmalloc. Custom caches can have other sizes. */ | 592 | /* These are the default caches for kmalloc. Custom caches can have other sizes. */ |
578 | struct cache_sizes malloc_sizes[] = { | 593 | struct cache_sizes malloc_sizes[] = { |
@@ -1190,11 +1205,7 @@ static void *kmem_getpages(kmem_cache_t *cachep, gfp_t flags, int nodeid) | |||
1190 | int i; | 1205 | int i; |
1191 | 1206 | ||
1192 | flags |= cachep->gfpflags; | 1207 | flags |= cachep->gfpflags; |
1193 | if (likely(nodeid == -1)) { | 1208 | page = alloc_pages_node(nodeid, flags, cachep->gfporder); |
1194 | page = alloc_pages(flags, cachep->gfporder); | ||
1195 | } else { | ||
1196 | page = alloc_pages_node(nodeid, flags, cachep->gfporder); | ||
1197 | } | ||
1198 | if (!page) | 1209 | if (!page) |
1199 | return NULL; | 1210 | return NULL; |
1200 | addr = page_address(page); | 1211 | addr = page_address(page); |
@@ -1368,7 +1379,7 @@ static void check_poison_obj(kmem_cache_t *cachep, void *objp) | |||
1368 | /* Print some data about the neighboring objects, if they | 1379 | /* Print some data about the neighboring objects, if they |
1369 | * exist: | 1380 | * exist: |
1370 | */ | 1381 | */ |
1371 | struct slab *slabp = GET_PAGE_SLAB(virt_to_page(objp)); | 1382 | struct slab *slabp = page_get_slab(virt_to_page(objp)); |
1372 | int objnr; | 1383 | int objnr; |
1373 | 1384 | ||
1374 | objnr = (objp-slabp->s_mem)/cachep->objsize; | 1385 | objnr = (objp-slabp->s_mem)/cachep->objsize; |
@@ -1502,6 +1513,7 @@ kmem_cache_create (const char *name, size_t size, size_t align, | |||
1502 | { | 1513 | { |
1503 | size_t left_over, slab_size, ralign; | 1514 | size_t left_over, slab_size, ralign; |
1504 | kmem_cache_t *cachep = NULL; | 1515 | kmem_cache_t *cachep = NULL; |
1516 | struct list_head *p; | ||
1505 | 1517 | ||
1506 | /* | 1518 | /* |
1507 | * Sanity checks... these are all serious usage bugs. | 1519 | * Sanity checks... these are all serious usage bugs. |
@@ -1516,6 +1528,35 @@ kmem_cache_create (const char *name, size_t size, size_t align, | |||
1516 | BUG(); | 1528 | BUG(); |
1517 | } | 1529 | } |
1518 | 1530 | ||
1531 | down(&cache_chain_sem); | ||
1532 | |||
1533 | list_for_each(p, &cache_chain) { | ||
1534 | kmem_cache_t *pc = list_entry(p, kmem_cache_t, next); | ||
1535 | mm_segment_t old_fs = get_fs(); | ||
1536 | char tmp; | ||
1537 | int res; | ||
1538 | |||
1539 | /* | ||
1540 | * This happens when the module gets unloaded and doesn't | ||
1541 | * destroy its slab cache and no-one else reuses the vmalloc | ||
1542 | * area of the module. Print a warning. | ||
1543 | */ | ||
1544 | set_fs(KERNEL_DS); | ||
1545 | res = __get_user(tmp, pc->name); | ||
1546 | set_fs(old_fs); | ||
1547 | if (res) { | ||
1548 | printk("SLAB: cache with size %d has lost its name\n", | ||
1549 | pc->objsize); | ||
1550 | continue; | ||
1551 | } | ||
1552 | |||
1553 | if (!strcmp(pc->name,name)) { | ||
1554 | printk("kmem_cache_create: duplicate cache %s\n", name); | ||
1555 | dump_stack(); | ||
1556 | goto oops; | ||
1557 | } | ||
1558 | } | ||
1559 | |||
1519 | #if DEBUG | 1560 | #if DEBUG |
1520 | WARN_ON(strchr(name, ' ')); /* It confuses parsers */ | 1561 | WARN_ON(strchr(name, ' ')); /* It confuses parsers */ |
1521 | if ((flags & SLAB_DEBUG_INITIAL) && !ctor) { | 1562 | if ((flags & SLAB_DEBUG_INITIAL) && !ctor) { |
@@ -1592,7 +1633,7 @@ kmem_cache_create (const char *name, size_t size, size_t align, | |||
1592 | /* Get cache's description obj. */ | 1633 | /* Get cache's description obj. */ |
1593 | cachep = (kmem_cache_t *) kmem_cache_alloc(&cache_cache, SLAB_KERNEL); | 1634 | cachep = (kmem_cache_t *) kmem_cache_alloc(&cache_cache, SLAB_KERNEL); |
1594 | if (!cachep) | 1635 | if (!cachep) |
1595 | goto opps; | 1636 | goto oops; |
1596 | memset(cachep, 0, sizeof(kmem_cache_t)); | 1637 | memset(cachep, 0, sizeof(kmem_cache_t)); |
1597 | 1638 | ||
1598 | #if DEBUG | 1639 | #if DEBUG |
@@ -1686,7 +1727,7 @@ next: | |||
1686 | printk("kmem_cache_create: couldn't create cache %s.\n", name); | 1727 | printk("kmem_cache_create: couldn't create cache %s.\n", name); |
1687 | kmem_cache_free(&cache_cache, cachep); | 1728 | kmem_cache_free(&cache_cache, cachep); |
1688 | cachep = NULL; | 1729 | cachep = NULL; |
1689 | goto opps; | 1730 | goto oops; |
1690 | } | 1731 | } |
1691 | slab_size = ALIGN(cachep->num*sizeof(kmem_bufctl_t) | 1732 | slab_size = ALIGN(cachep->num*sizeof(kmem_bufctl_t) |
1692 | + sizeof(struct slab), align); | 1733 | + sizeof(struct slab), align); |
@@ -1781,43 +1822,14 @@ next: | |||
1781 | cachep->limit = BOOT_CPUCACHE_ENTRIES; | 1822 | cachep->limit = BOOT_CPUCACHE_ENTRIES; |
1782 | } | 1823 | } |
1783 | 1824 | ||
1784 | /* Need the semaphore to access the chain. */ | ||
1785 | down(&cache_chain_sem); | ||
1786 | { | ||
1787 | struct list_head *p; | ||
1788 | mm_segment_t old_fs; | ||
1789 | |||
1790 | old_fs = get_fs(); | ||
1791 | set_fs(KERNEL_DS); | ||
1792 | list_for_each(p, &cache_chain) { | ||
1793 | kmem_cache_t *pc = list_entry(p, kmem_cache_t, next); | ||
1794 | char tmp; | ||
1795 | /* This happens when the module gets unloaded and doesn't | ||
1796 | destroy its slab cache and noone else reuses the vmalloc | ||
1797 | area of the module. Print a warning. */ | ||
1798 | if (__get_user(tmp,pc->name)) { | ||
1799 | printk("SLAB: cache with size %d has lost its name\n", | ||
1800 | pc->objsize); | ||
1801 | continue; | ||
1802 | } | ||
1803 | if (!strcmp(pc->name,name)) { | ||
1804 | printk("kmem_cache_create: duplicate cache %s\n",name); | ||
1805 | up(&cache_chain_sem); | ||
1806 | unlock_cpu_hotplug(); | ||
1807 | BUG(); | ||
1808 | } | ||
1809 | } | ||
1810 | set_fs(old_fs); | ||
1811 | } | ||
1812 | |||
1813 | /* cache setup completed, link it into the list */ | 1825 | /* cache setup completed, link it into the list */ |
1814 | list_add(&cachep->next, &cache_chain); | 1826 | list_add(&cachep->next, &cache_chain); |
1815 | up(&cache_chain_sem); | ||
1816 | unlock_cpu_hotplug(); | 1827 | unlock_cpu_hotplug(); |
1817 | opps: | 1828 | oops: |
1818 | if (!cachep && (flags & SLAB_PANIC)) | 1829 | if (!cachep && (flags & SLAB_PANIC)) |
1819 | panic("kmem_cache_create(): failed to create slab `%s'\n", | 1830 | panic("kmem_cache_create(): failed to create slab `%s'\n", |
1820 | name); | 1831 | name); |
1832 | up(&cache_chain_sem); | ||
1821 | return cachep; | 1833 | return cachep; |
1822 | } | 1834 | } |
1823 | EXPORT_SYMBOL(kmem_cache_create); | 1835 | EXPORT_SYMBOL(kmem_cache_create); |
@@ -2137,8 +2149,8 @@ static void set_slab_attr(kmem_cache_t *cachep, struct slab *slabp, void *objp) | |||
2137 | i = 1 << cachep->gfporder; | 2149 | i = 1 << cachep->gfporder; |
2138 | page = virt_to_page(objp); | 2150 | page = virt_to_page(objp); |
2139 | do { | 2151 | do { |
2140 | SET_PAGE_CACHE(page, cachep); | 2152 | page_set_cache(page, cachep); |
2141 | SET_PAGE_SLAB(page, slabp); | 2153 | page_set_slab(page, slabp); |
2142 | page++; | 2154 | page++; |
2143 | } while (--i); | 2155 | } while (--i); |
2144 | } | 2156 | } |
@@ -2268,14 +2280,14 @@ static void *cache_free_debugcheck(kmem_cache_t *cachep, void *objp, | |||
2268 | kfree_debugcheck(objp); | 2280 | kfree_debugcheck(objp); |
2269 | page = virt_to_page(objp); | 2281 | page = virt_to_page(objp); |
2270 | 2282 | ||
2271 | if (GET_PAGE_CACHE(page) != cachep) { | 2283 | if (page_get_cache(page) != cachep) { |
2272 | printk(KERN_ERR "mismatch in kmem_cache_free: expected cache %p, got %p\n", | 2284 | printk(KERN_ERR "mismatch in kmem_cache_free: expected cache %p, got %p\n", |
2273 | GET_PAGE_CACHE(page),cachep); | 2285 | page_get_cache(page),cachep); |
2274 | printk(KERN_ERR "%p is %s.\n", cachep, cachep->name); | 2286 | printk(KERN_ERR "%p is %s.\n", cachep, cachep->name); |
2275 | printk(KERN_ERR "%p is %s.\n", GET_PAGE_CACHE(page), GET_PAGE_CACHE(page)->name); | 2287 | printk(KERN_ERR "%p is %s.\n", page_get_cache(page), page_get_cache(page)->name); |
2276 | WARN_ON(1); | 2288 | WARN_ON(1); |
2277 | } | 2289 | } |
2278 | slabp = GET_PAGE_SLAB(page); | 2290 | slabp = page_get_slab(page); |
2279 | 2291 | ||
2280 | if (cachep->flags & SLAB_RED_ZONE) { | 2292 | if (cachep->flags & SLAB_RED_ZONE) { |
2281 | if (*dbg_redzone1(cachep, objp) != RED_ACTIVE || *dbg_redzone2(cachep, objp) != RED_ACTIVE) { | 2293 | if (*dbg_redzone1(cachep, objp) != RED_ACTIVE || *dbg_redzone2(cachep, objp) != RED_ACTIVE) { |
@@ -2627,7 +2639,7 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects, int n | |||
2627 | struct slab *slabp; | 2639 | struct slab *slabp; |
2628 | unsigned int objnr; | 2640 | unsigned int objnr; |
2629 | 2641 | ||
2630 | slabp = GET_PAGE_SLAB(virt_to_page(objp)); | 2642 | slabp = page_get_slab(virt_to_page(objp)); |
2631 | l3 = cachep->nodelists[node]; | 2643 | l3 = cachep->nodelists[node]; |
2632 | list_del(&slabp->list); | 2644 | list_del(&slabp->list); |
2633 | objnr = (objp - slabp->s_mem) / cachep->objsize; | 2645 | objnr = (objp - slabp->s_mem) / cachep->objsize; |
@@ -2743,7 +2755,7 @@ static inline void __cache_free(kmem_cache_t *cachep, void *objp) | |||
2743 | #ifdef CONFIG_NUMA | 2755 | #ifdef CONFIG_NUMA |
2744 | { | 2756 | { |
2745 | struct slab *slabp; | 2757 | struct slab *slabp; |
2746 | slabp = GET_PAGE_SLAB(virt_to_page(objp)); | 2758 | slabp = page_get_slab(virt_to_page(objp)); |
2747 | if (unlikely(slabp->nodeid != numa_node_id())) { | 2759 | if (unlikely(slabp->nodeid != numa_node_id())) { |
2748 | struct array_cache *alien = NULL; | 2760 | struct array_cache *alien = NULL; |
2749 | int nodeid = slabp->nodeid; | 2761 | int nodeid = slabp->nodeid; |
@@ -2829,7 +2841,7 @@ int fastcall kmem_ptr_validate(kmem_cache_t *cachep, void *ptr) | |||
2829 | page = virt_to_page(ptr); | 2841 | page = virt_to_page(ptr); |
2830 | if (unlikely(!PageSlab(page))) | 2842 | if (unlikely(!PageSlab(page))) |
2831 | goto out; | 2843 | goto out; |
2832 | if (unlikely(GET_PAGE_CACHE(page) != cachep)) | 2844 | if (unlikely(page_get_cache(page) != cachep)) |
2833 | goto out; | 2845 | goto out; |
2834 | return 1; | 2846 | return 1; |
2835 | out: | 2847 | out: |
@@ -3025,7 +3037,7 @@ void kfree(const void *objp) | |||
3025 | return; | 3037 | return; |
3026 | local_irq_save(flags); | 3038 | local_irq_save(flags); |
3027 | kfree_debugcheck(objp); | 3039 | kfree_debugcheck(objp); |
3028 | c = GET_PAGE_CACHE(virt_to_page(objp)); | 3040 | c = page_get_cache(virt_to_page(objp)); |
3029 | __cache_free(c, (void*)objp); | 3041 | __cache_free(c, (void*)objp); |
3030 | local_irq_restore(flags); | 3042 | local_irq_restore(flags); |
3031 | } | 3043 | } |
@@ -3262,6 +3274,7 @@ static void drain_array_locked(kmem_cache_t *cachep, | |||
3262 | 3274 | ||
3263 | /** | 3275 | /** |
3264 | * cache_reap - Reclaim memory from caches. | 3276 | * cache_reap - Reclaim memory from caches. |
3277 | * @unused: unused parameter | ||
3265 | * | 3278 | * |
3266 | * Called from workqueue/eventd every few seconds. | 3279 | * Called from workqueue/eventd every few seconds. |
3267 | * Purpose: | 3280 | * Purpose: |
@@ -3278,7 +3291,7 @@ static void cache_reap(void *unused) | |||
3278 | 3291 | ||
3279 | if (down_trylock(&cache_chain_sem)) { | 3292 | if (down_trylock(&cache_chain_sem)) { |
3280 | /* Give up. Setup the next iteration. */ | 3293 | /* Give up. Setup the next iteration. */ |
3281 | schedule_delayed_work(&__get_cpu_var(reap_work), REAPTIMEOUT_CPUC + smp_processor_id()); | 3294 | schedule_delayed_work(&__get_cpu_var(reap_work), REAPTIMEOUT_CPUC); |
3282 | return; | 3295 | return; |
3283 | } | 3296 | } |
3284 | 3297 | ||
@@ -3347,7 +3360,7 @@ next: | |||
3347 | up(&cache_chain_sem); | 3360 | up(&cache_chain_sem); |
3348 | drain_remote_pages(); | 3361 | drain_remote_pages(); |
3349 | /* Setup the next iteration */ | 3362 | /* Setup the next iteration */ |
3350 | schedule_delayed_work(&__get_cpu_var(reap_work), REAPTIMEOUT_CPUC + smp_processor_id()); | 3363 | schedule_delayed_work(&__get_cpu_var(reap_work), REAPTIMEOUT_CPUC); |
3351 | } | 3364 | } |
3352 | 3365 | ||
3353 | #ifdef CONFIG_PROC_FS | 3366 | #ifdef CONFIG_PROC_FS |
@@ -3594,7 +3607,7 @@ unsigned int ksize(const void *objp) | |||
3594 | if (unlikely(objp == NULL)) | 3607 | if (unlikely(objp == NULL)) |
3595 | return 0; | 3608 | return 0; |
3596 | 3609 | ||
3597 | return obj_reallen(GET_PAGE_CACHE(virt_to_page(objp))); | 3610 | return obj_reallen(page_get_cache(virt_to_page(objp))); |
3598 | } | 3611 | } |
3599 | 3612 | ||
3600 | 3613 | ||
@@ -413,7 +413,6 @@ void vm_acct_memory(long pages) | |||
413 | } | 413 | } |
414 | preempt_enable(); | 414 | preempt_enable(); |
415 | } | 415 | } |
416 | EXPORT_SYMBOL(vm_acct_memory); | ||
417 | 416 | ||
418 | #ifdef CONFIG_HOTPLUG_CPU | 417 | #ifdef CONFIG_HOTPLUG_CPU |
419 | static void lru_drain_cache(unsigned int cpu) | 418 | static void lru_drain_cache(unsigned int cpu) |
diff --git a/mm/swap_state.c b/mm/swap_state.c index dfd9a46755b8..0df9a57b1de8 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c | |||
@@ -40,7 +40,6 @@ struct address_space swapper_space = { | |||
40 | .i_mmap_nonlinear = LIST_HEAD_INIT(swapper_space.i_mmap_nonlinear), | 40 | .i_mmap_nonlinear = LIST_HEAD_INIT(swapper_space.i_mmap_nonlinear), |
41 | .backing_dev_info = &swap_backing_dev_info, | 41 | .backing_dev_info = &swap_backing_dev_info, |
42 | }; | 42 | }; |
43 | EXPORT_SYMBOL(swapper_space); | ||
44 | 43 | ||
45 | #define INC_CACHE_INFO(x) do { swap_cache_info.x++; } while (0) | 44 | #define INC_CACHE_INFO(x) do { swap_cache_info.x++; } while (0) |
46 | 45 | ||
diff --git a/mm/swapfile.c b/mm/swapfile.c index 8970c0b74194..edafeace301f 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -36,8 +36,6 @@ unsigned int nr_swapfiles; | |||
36 | long total_swap_pages; | 36 | long total_swap_pages; |
37 | static int swap_overflow; | 37 | static int swap_overflow; |
38 | 38 | ||
39 | EXPORT_SYMBOL(total_swap_pages); | ||
40 | |||
41 | static const char Bad_file[] = "Bad swap file entry "; | 39 | static const char Bad_file[] = "Bad swap file entry "; |
42 | static const char Unused_file[] = "Unused swap file entry "; | 40 | static const char Unused_file[] = "Unused swap file entry "; |
43 | static const char Bad_offset[] = "Bad swap offset entry "; | 41 | static const char Bad_offset[] = "Bad swap offset entry "; |
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 54a90e83cb31..729eb3eec75f 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -457,7 +457,7 @@ void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot) | |||
457 | * @size: allocation size | 457 | * @size: allocation size |
458 | * @gfp_mask: flags for the page level allocator | 458 | * @gfp_mask: flags for the page level allocator |
459 | * @prot: protection mask for the allocated pages | 459 | * @prot: protection mask for the allocated pages |
460 | * @node node to use for allocation or -1 | 460 | * @node: node to use for allocation or -1 |
461 | * | 461 | * |
462 | * Allocate enough pages to cover @size from the page level | 462 | * Allocate enough pages to cover @size from the page level |
463 | * allocator with @gfp_mask flags. Map them into contiguous | 463 | * allocator with @gfp_mask flags. Map them into contiguous |
@@ -507,7 +507,7 @@ EXPORT_SYMBOL(vmalloc); | |||
507 | * vmalloc_node - allocate memory on a specific node | 507 | * vmalloc_node - allocate memory on a specific node |
508 | * | 508 | * |
509 | * @size: allocation size | 509 | * @size: allocation size |
510 | * @node; numa node | 510 | * @node: numa node |
511 | * | 511 | * |
512 | * Allocate enough pages to cover @size from the page level | 512 | * Allocate enough pages to cover @size from the page level |
513 | * allocator and map them into contiguous kernel virtual space. | 513 | * allocator and map them into contiguous kernel virtual space. |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 135bf8ca96ee..28130541270f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -1074,7 +1074,7 @@ loop_again: | |||
1074 | continue; | 1074 | continue; |
1075 | 1075 | ||
1076 | if (!zone_watermark_ok(zone, order, | 1076 | if (!zone_watermark_ok(zone, order, |
1077 | zone->pages_high, 0, 0, 0)) { | 1077 | zone->pages_high, 0, 0)) { |
1078 | end_zone = i; | 1078 | end_zone = i; |
1079 | goto scan; | 1079 | goto scan; |
1080 | } | 1080 | } |
@@ -1111,7 +1111,7 @@ scan: | |||
1111 | 1111 | ||
1112 | if (nr_pages == 0) { /* Not software suspend */ | 1112 | if (nr_pages == 0) { /* Not software suspend */ |
1113 | if (!zone_watermark_ok(zone, order, | 1113 | if (!zone_watermark_ok(zone, order, |
1114 | zone->pages_high, end_zone, 0, 0)) | 1114 | zone->pages_high, end_zone, 0)) |
1115 | all_zones_ok = 0; | 1115 | all_zones_ok = 0; |
1116 | } | 1116 | } |
1117 | zone->temp_priority = priority; | 1117 | zone->temp_priority = priority; |
@@ -1259,7 +1259,7 @@ void wakeup_kswapd(struct zone *zone, int order) | |||
1259 | return; | 1259 | return; |
1260 | 1260 | ||
1261 | pgdat = zone->zone_pgdat; | 1261 | pgdat = zone->zone_pgdat; |
1262 | if (zone_watermark_ok(zone, order, zone->pages_low, 0, 0, 0)) | 1262 | if (zone_watermark_ok(zone, order, zone->pages_low, 0, 0)) |
1263 | return; | 1263 | return; |
1264 | if (pgdat->kswapd_max_order < order) | 1264 | if (pgdat->kswapd_max_order < order) |
1265 | pgdat->kswapd_max_order = order; | 1265 | pgdat->kswapd_max_order = order; |