History

thp: prevent hugepages during args/env copying into the user stack

Transparent hugepages can only be created if rmap is fully functional. So we must prevent hugepages to be created while is_vma_temporary_stack() is true. This also optmizes away some harmless but unnecessary setting of khugepaged_scan.address and it switches some BUG_ON to VM_BUG_ON.

Andrea Arcangeli committed 15 years ago

Commit a7d6e4e1 parent 09f586b2 files · +18 −20Browse files

Unified · Split

2 files
  1. include/linux/huge_mm.h +2 −1
  2. mm/huge_memory.c +16 −19
include/linux/huge_mm.h+2−1
@@ -57,7 +57,8 @@ extern pmd_t *page_check_address_pmd(struct page *page, · 56 unmodified lines
5757 (transparent_hugepage_flags & \
5858 (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG) && \
5959 ((__vma)->vm_flags & VM_HUGEPAGE))) && \
60− !((__vma)->vm_flags & VM_NOHUGEPAGE))
60+ !((__vma)->vm_flags & VM_NOHUGEPAGE) && \
61+ !is_vma_temporary_stack(__vma))
6162 #define transparent_hugepage_defrag(__vma) \
6263 ((transparent_hugepage_flags & \
6364 (1<<TRANSPARENT_HUGEPAGE_DEFRAG_FLAG)) || \
mm/huge_memory.c+16−19
@@ -1811,6 +1811,8 @@ static void collapse_huge_page(struct mm_struct *mm, · 1810 unmodified lines
18111811 /* VM_PFNMAP vmas may have vm_ops null but vm_file set */
18121812 if (!vma->anon_vma || vma->vm_ops || vma->vm_file)
18131813 goto out;
1814+ if (is_vma_temporary_stack(vma))
1815+ goto out;
18141816 VM_BUG_ON(is_linear_pfn_mapping(vma) || is_pfn_mapping(vma));
18151817
18161818 pgd = pgd_offset(mm, address);
@@ -2032,32 +2034,27 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, · 215 unmodified lines
20322034 if ((!(vma->vm_flags & VM_HUGEPAGE) &&
20332035 !khugepaged_always()) ||
20342036 (vma->vm_flags & VM_NOHUGEPAGE)) {
2037+ skip:
20352038 progress++;
20362039 continue;
20372040 }
2038−
20392041 /* VM_PFNMAP vmas may have vm_ops null but vm_file set */
2040− if (!vma->anon_vma || vma->vm_ops || vma->vm_file) {
2041− khugepaged_scan.address = vma->vm_end;
2042− progress++;
2043− continue;
2044− }
2042+ if (!vma->anon_vma || vma->vm_ops || vma->vm_file)
2043+ goto skip;
2044+ if (is_vma_temporary_stack(vma))
2045+ goto skip;
2046+
20452047 VM_BUG_ON(is_linear_pfn_mapping(vma) || is_pfn_mapping(vma));
20462048
20472049 hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
20482050 hend = vma->vm_end & HPAGE_PMD_MASK;
2049− if (hstart >= hend) {
2050− progress++;
2051− continue;
2052− }
2051+ if (hstart >= hend)
2052+ goto skip;
2053+ if (khugepaged_scan.address > hend)
2054+ goto skip;
20532055 if (khugepaged_scan.address < hstart)
20542056 khugepaged_scan.address = hstart;
2055− if (khugepaged_scan.address > hend) {
2056− khugepaged_scan.address = hend + HPAGE_PMD_SIZE;
2057− progress++;
2058− continue;
2059− }
2060− BUG_ON(khugepaged_scan.address & ~HPAGE_PMD_MASK);
2057+ VM_BUG_ON(khugepaged_scan.address & ~HPAGE_PMD_MASK);
20612058
20622059 while (khugepaged_scan.address < hend) {
20632060 int ret;
@@ -2086,7 +2083,7 @@ breakouterloop: · 22 unmodified lines
20862083 breakouterloop_mmap_sem:
20872084
20882085 spin_lock(&khugepaged_mm_lock);
2089− BUG_ON(khugepaged_scan.mm_slot != mm_slot);
2086+ VM_BUG_ON(khugepaged_scan.mm_slot != mm_slot);
20902087 /*
20912088 * Release the current mm_slot if this mm is about to die, or
20922089 * if we scanned all vmas of this mm.
@@ -2241,9 +2238,9 @@ static int khugepaged(void *none) · 148 unmodified lines
22412238
22422239 for (;;) {
22432240 mutex_unlock(&khugepaged_mutex);
2244− BUG_ON(khugepaged_thread != current);
2241+ VM_BUG_ON(khugepaged_thread != current);
22452242 khugepaged_loop();
2246− BUG_ON(khugepaged_thread != current);
2243+ VM_BUG_ON(khugepaged_thread != current);
22472244
22482245 mutex_lock(&khugepaged_mutex);
22492246 if (!khugepaged_enabled())

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t