From patchwork Mon May 22 14:39:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9740705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A49DF601C2 for ; Mon, 22 May 2017 14:48:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94F7428705 for ; Mon, 22 May 2017 14:48:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87FE028708; Mon, 22 May 2017 14:48:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7AE828705 for ; Mon, 22 May 2017 14:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+xXvSS2sF0iPF+jXNUD/IXXHql9XSBdT3Rv9MLNrECQ=; b=BQ7XCTIdHXc/EcHQleq0Vpj06m BSDibErLY922PU+i+viOV3XCDz9hugNGSDSmqVC3TgISZ55gIW7VhaPQcqiF0fnpu2hzPLPjle9DL syhCL/drQZHvCOSk9wM/Uldyo7NSwhUBi6e21DoIAY/93ITnZr0NqyY1wA+PiMQRDtI8YbtFCjSZS MWM9eMZXWTd8B1z/EwarSvKs4t5P2cxaMwd98jWqVT5deObrGT7cFIAwgSPcTg1qpBpeV1qXR6Fi6 BsogTo+imqAURGFBBSqua1fmJ6VF4BUfM5k8HJSfo0vuGtvgz9JGjijQcvaU9BylpFTIB/b9Lcyhe NCEyC/DA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dCodc-00083W-LZ; Mon, 22 May 2017 14:48:48 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dCoda-00080N-Hs for linux-arm-kernel@bombadil.infradead.org; Mon, 22 May 2017 14:48:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OyypbJSt7BizRuLKRrJ1OHpZXSi6ycvjrlEqlJ5Nckc=; b=StWRlBvJYuIVsH5Vu9yzLkgZ7 UuLXzKbubw/Zv7T2Lb37I4IdLzZcA/tfzOZFwGCSAQZhmsHLi5ASqMkE32nCKxoX99swutjPLfpzP OyC68T/INiT4N/JiFsE9RMR0CsG1zBCxC/sK3D/6rHE5+7CaAka7j7f5tOu5FHEpGQKc45gJAsj+7 lVXcjwnPAkuYoXbBSxXiCoMzSTn3uS36EVndW1QXHGoGiwsXTZPsAoy/o3Ri8ke1iEIe1q/GCdoPa TwfeRq1X/duPYPx7fKy+HJPFyon1+strxHs/spJLYmdwIOlMpKdEEL4QjcfK+ulqXHMCg08n/XAxs 7zb2NaDsQ==; Received: from foss.arm.com ([217.140.101.70]) by casper.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dCoWG-0003FV-BU for linux-arm-kernel@lists.infradead.org; Mon, 22 May 2017 14:41:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 201762B; Mon, 22 May 2017 07:41:12 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.207.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E324B3F53D; Mon, 22 May 2017 07:41:11 -0700 (PDT) From: Punit Agrawal To: will.deacon@arm.com, catalin.marinas@arm.com Subject: [PATCH v3 07/11] arm64: hugetlbpages: Handle swap entries in huge_pte_offset() for contiguous hugepages Date: Mon, 22 May 2017 15:39:54 +0100 Message-Id: <20170522143958.12867-9-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170522143958.12867-1-punit.agrawal@arm.com> References: <20170522143958.12867-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170522_154112_528440_C05D6B89 X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, David Woods , Punit Agrawal , linux-arm-kernel@lists.infradead.org, steve.capper@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP huge_pte_offset() was updated to correctly handle swap entries for hugepages. With the addition of the size parameter, it is now possible to disambiguate whether the request is for a regular hugepage or a contiguous hugepage. Fix huge_pte_offset() for contiguous hugepages by using the size to find the correct page table entry. Signed-off-by: Punit Agrawal Cc: David Woods --- arch/arm64/mm/hugetlbpage.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index f2c976464f39..e9061704aec3 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -195,6 +195,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, pgd_t *pgd; pud_t *pud; pmd_t *pmd; + pte_t *pte; pgd = pgd_offset(mm, addr); pr_debug("%s: addr:0x%lx pgd:%p\n", __func__, addr, pgd); @@ -202,19 +203,29 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return NULL; pud = pud_offset(pgd, addr); - if (pud_none(*pud)) + if (pud_none(*pud) && sz != PUD_SIZE) return NULL; /* swap or huge page */ if (!pud_present(*pud) || pud_huge(*pud)) return (pte_t *)pud; /* table; check the next level */ + if (sz == CONT_PMD_SIZE) + addr &= CONT_PMD_MASK; + pmd = pmd_offset(pud, addr); - if (pmd_none(*pmd)) + if (pmd_none(*pmd) && + !(sz == PMD_SIZE || sz == CONT_PMD_SIZE)) return NULL; if (!pmd_present(*pmd) || pmd_huge(*pmd)) return (pte_t *)pmd; + if (sz == CONT_PTE_SIZE) { + pte = pte_offset_kernel( + pmd, (addr & CONT_PTE_MASK)); + return pte; + } + return NULL; }