Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230775
b: refs/heads/master
c: 0af4e98
h: refs/heads/master
i:
  230773: 1b2f829
  230771: bb35a58
  230767: 7c049a7
v: v3
  • Loading branch information
Andrea Arcangeli authored and Linus Torvalds committed Jan 14, 2011
1 parent 7e40332 commit 381dbeb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f66055ab6fb9731dbfce320c5202ef4441b5d77f
refs/heads/master: 0af4e98b6b095c74588af04872f83d333c958c32
6 changes: 6 additions & 0 deletions trunk/include/linux/huge_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ extern void __split_huge_page_pmd(struct mm_struct *mm, pmd_t *pmd);
#if HPAGE_PMD_ORDER > MAX_ORDER
#error "hugepages can't be allocated by the buddy allocator"
#endif
extern int hugepage_madvise(unsigned long *vm_flags);
#else /* CONFIG_TRANSPARENT_HUGEPAGE */
#define HPAGE_PMD_SHIFT ({ BUG(); 0; })
#define HPAGE_PMD_MASK ({ BUG(); 0; })
Expand All @@ -113,6 +114,11 @@ static inline int split_huge_page(struct page *page)
do { } while (0)
#define wait_split_huge_page(__anon_vma, __pmd) \
do { } while (0)
static inline int hugepage_madvise(unsigned long *vm_flags)
{
BUG();
return 0;
}
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */

#endif /* _LINUX_HUGE_MM_H */
16 changes: 16 additions & 0 deletions trunk/mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,22 @@ int split_huge_page(struct page *page)
return ret;
}

int hugepage_madvise(unsigned long *vm_flags)
{
/*
* Be somewhat over-protective like KSM for now!
*/
if (*vm_flags & (VM_HUGEPAGE | VM_SHARED | VM_MAYSHARE |
VM_PFNMAP | VM_IO | VM_DONTEXPAND |
VM_RESERVED | VM_HUGETLB | VM_INSERTPAGE |
VM_MIXEDMAP | VM_SAO))
return -EINVAL;

*vm_flags |= VM_HUGEPAGE;

return 0;
}

void __split_huge_page_pmd(struct mm_struct *mm, pmd_t *pmd)
{
struct page *page;
Expand Down
8 changes: 8 additions & 0 deletions trunk/mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ static long madvise_behavior(struct vm_area_struct * vma,
if (error)
goto out;
break;
case MADV_HUGEPAGE:
error = hugepage_madvise(&new_flags);
if (error)
goto out;
break;
}

if (new_flags == vma->vm_flags) {
Expand Down Expand Up @@ -282,6 +287,9 @@ madvise_behavior_valid(int behavior)
#ifdef CONFIG_KSM
case MADV_MERGEABLE:
case MADV_UNMERGEABLE:
#endif
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
case MADV_HUGEPAGE:
#endif
return 1;

Expand Down

0 comments on commit 381dbeb

Please sign in to comment.