From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andi Kleen References: <20080317258.659191058@firstfloor.org> In-Reply-To: <20080317258.659191058@firstfloor.org> Subject: [PATCH] [15/18] Add support to x86-64 to allocate and lookup GB pages in hugetlb Message-Id: <20080317015829.1FA4F1B41E0@basil.firstfloor.org> Date: Mon, 17 Mar 2008 02:58:29 +0100 (CET) Sender: owner-linux-mm@kvack.org Return-Path: To: linux-kernel@vger.kernel.org, pj@sgi.com, linux-mm@kvack.org, nickpiggin@yahoo.com.au List-ID: Signed-off-by: Andi Kleen --- arch/x86/mm/hugetlbpage.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) Index: linux/arch/x86/mm/hugetlbpage.c =================================================================== --- linux.orig/arch/x86/mm/hugetlbpage.c +++ linux/arch/x86/mm/hugetlbpage.c @@ -133,9 +133,14 @@ pte_t *huge_pte_alloc(struct mm_struct * pgd = pgd_offset(mm, addr); pud = pud_alloc(mm, pgd, addr); if (pud) { - if (pud_none(*pud)) - huge_pmd_share(mm, addr, pud); - pte = (pte_t *) pmd_alloc(mm, pud, addr); + if (sz == PUD_SIZE) { + pte = (pte_t *)pud; + } else { + BUG_ON(sz != PMD_SIZE); + if (pud_none(*pud)) + huge_pmd_share(mm, addr, pud); + pte = (pte_t *) pmd_alloc(mm, pud, addr); + } } BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte)); @@ -151,8 +156,11 @@ pte_t *huge_pte_offset(struct mm_struct pgd = pgd_offset(mm, addr); if (pgd_present(*pgd)) { pud = pud_offset(pgd, addr); - if (pud_present(*pud)) + if (pud_present(*pud)) { + if (pud_large(*pud)) + return (pte_t *)pud; pmd = pmd_offset(pud, addr); + } } return (pte_t *) pmd; } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org