[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101118151935.GW8135@csn.ul.ie>
Date: Thu, 18 Nov 2010 15:19:35 +0000
From: Mel Gorman <mel@....ul.ie>
To: Andrea Arcangeli <aarcange@...hat.com>
Cc: linux-mm@...ck.org, Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
Marcelo Tosatti <mtosatti@...hat.com>,
Adam Litke <agl@...ibm.com>, Avi Kivity <avi@...hat.com>,
Hugh Dickins <hugh.dickins@...cali.co.uk>,
Rik van Riel <riel@...hat.com>,
Dave Hansen <dave@...ux.vnet.ibm.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Ingo Molnar <mingo@...e.hu>, Mike Travis <travis@....com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Christoph Lameter <cl@...ux-foundation.org>,
Chris Wright <chrisw@...s-sol.org>, bpicco@...hat.com,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
Balbir Singh <balbir@...ux.vnet.ibm.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Johannes Weiner <hannes@...xchg.org>,
Daisuke Nishimura <nishimura@....nes.nec.co.jp>,
Chris Mason <chris.mason@...cle.com>,
Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH 33 of 66] madvise(MADV_HUGEPAGE)
On Wed, Nov 03, 2010 at 04:28:08PM +0100, Andrea Arcangeli wrote:
> From: Andrea Arcangeli <aarcange@...hat.com>
>
> Add madvise MADV_HUGEPAGE to mark regions that are important to be hugepage
> backed. Return -EINVAL if the vma is not of an anonymous type, or the feature
> isn't built into the kernel. Never silently return success.
>
> Signed-off-by: Andrea Arcangeli <aarcange@...hat.com>
> Acked-by: Rik van Riel <riel@...hat.com>
> ---
>
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -99,6 +99,7 @@ extern void __split_huge_page_pmd(struct
> #endif
>
> extern unsigned long vma_address(struct page *page, struct vm_area_struct *vma);
> +extern int hugepage_madvise(unsigned long *vm_flags);
> static inline int PageTransHuge(struct page *page)
> {
> VM_BUG_ON(PageTail(page));
> @@ -121,6 +122,11 @@ static inline int split_huge_page(struct
> #define wait_split_huge_page(__anon_vma, __pmd) \
> do { } while (0)
> #define PageTransHuge(page) 0
> +static inline int hugepage_madvise(unsigned long *vm_flags)
> +{
> + BUG_ON(0);
What's BUG_ON(0) in aid of?
> + return 0;
> +}
> #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
>
> #endif /* _LINUX_HUGE_MM_H */
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -894,6 +894,22 @@ out:
> 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;
> diff --git a/mm/madvise.c b/mm/madvise.c
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -71,6 +71,11 @@ static long madvise_behavior(struct vm_a
> if (error)
> goto out;
> break;
> + case MADV_HUGEPAGE:
I should have said it at patch 4 but don't forget that Michael Kerrisk
should be made aware of MADV_HUGEPAGE so it makes it to a manual page
at some point.
> + error = hugepage_madvise(&new_flags);
> + if (error)
> + goto out;
> + break;
> }
>
> if (new_flags == vma->vm_flags) {
> @@ -283,6 +288,9 @@ madvise_behavior_valid(int behavior)
> case MADV_MERGEABLE:
> case MADV_UNMERGEABLE:
> #endif
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> + case MADV_HUGEPAGE:
> +#endif
> return 1;
>
> default:
>
--
Mel Gorman
Part-time Phd Student Linux Technology Center
University of Limerick IBM Dublin Software Lab
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists