From patchwork Wed May 24 11:54:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9745859 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 DA8E860209 for ; Wed, 24 May 2017 11:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7C2728963 for ; Wed, 24 May 2017 11:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC8E228965; Wed, 24 May 2017 11:57:18 +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=unavailable 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 3300F28942 for ; Wed, 24 May 2017 11:57:18 +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=L6dR0U2QBAztUSH1UzWWprvtSbl5YTpotUrKkP7RtaY=; b=e+xqd0zg8cjalXyeDobRFizItJ fGKpiSCVhrZDCNln7JqJ7av6aWlXOTsik4s9Xh3rcy3sl1NwuE3lKjAQolBL/fMiOA8bw5rYy/anF FrTxSE20zCUwp7ARrCN7WRnTbMhkClFNRVvhCQXfKhj/68YCY2HY2erpeasJZGIhvbULxHQGXf33J DsscJlOH1ya1qgKTxQXmAmKzqU/JFTxcPDej+xZ03CHhqsLhcjz1Fqw7j/EhUNs9iQV3JNi1Q0CuX wLgkScVKllfUlQfDrb/os7mfABaGzxzMQhPYzH/npMEzL9+L5UpCgaBhAOpCGg53a/Ak2jlPU70Y+ MW6SLMhw==; 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 1dDUuh-0003C2-H0; Wed, 24 May 2017 11:57:15 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dDUtz-0002Pj-Fm for linux-arm-kernel@bombadil.infradead.org; Wed, 24 May 2017 11:56:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=8A4ofHzRgkX1Rr6Jc4ts5kPLB8wJjY0WXfHidVFbHn4=; b=0Fgn75gvOSRYxB+TJjLKh8TQ3 cmdLEjtj9tqNLtDOTuy6ahEgqWM8DlX9viXVaLZcZ6poqetyI3MZnmzFRtbvgrPmos+TKF0fDHSxm HfrFTk77NdNAPRBOAaHxMx1Aw1yOhMcaUFQmpNyTavMshEoCtqghhq0MiD47zBauth0rZIuXFnDL+ FJRveTKmmRoMrWZYf6qDYuMe7KvY7RH9b2ux7D/qU1YeXBD/MmNNQtm+dPTndvPCzTrRF3rP4mnp4 BQ5z4WSL8Go7UgGiw8AmkjJONvQH3NfCNdiwyDjlKUFj3BwswmNoJyDxsiL3LMa7gNb63ItPmRwTp E0gd4UULQ==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dDUty-0008CI-1k for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2017 11:56:30 +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 90BF215BF; Wed, 24 May 2017 04:56:09 -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 5F6213F578; Wed, 24 May 2017 04:56:09 -0700 (PDT) From: Punit Agrawal To: akpm@linux-foundation.org Subject: [PATCH v4 6/8] mm/hugetlb: Allow architectures to override huge_pte_clear() Date: Wed, 24 May 2017 12:54:07 +0100 Message-Id: <20170524115409.31309-7-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170524115409.31309-1-punit.agrawal@arm.com> References: <20170524115409.31309-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-20170524_075630_199062_993F0927 X-CRM114-Status: GOOD ( 11.38 ) 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, linux-arch@vger.kernel.org, Heiko Carstens , steve.capper@arm.com, aneesh.kumar@linux.vnet.ibm.com, catalin.marinas@arm.com, Punit Agrawal , will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kirill.shutemov@linux.intel.com, n-horiguchi@ah.jp.nec.com, linux-arm-kernel@lists.infradead.org, mike.kravetz@oracle.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 When unmapping a hugepage range, huge_pte_clear() is used to clear the page table entries that are marked as not present. huge_pte_clear() internally just ends up calling pte_clear() which does not correctly deal with hugepages consisting of contiguous page table entries. Add a size argument to address this issue and allow architectures to override huge_pte_clear() by wrapping it in a #ifndef block. Update s390 implementation with the size parameter as well. Note that the change only affects huge_pte_clear() - the other generic hugetlb functions don't need any change. Signed-off-by: Punit Agrawal Acked-by: Arnd Bergmann Acked-by: Martin Schwidefsky Cc: Heiko Carstens Cc: "Aneesh Kumar K.V" Cc: Mike Kravetz --- arch/s390/include/asm/hugetlb.h | 2 +- include/asm-generic/hugetlb.h | 4 +++- mm/hugetlb.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h index cd546a245c68..c0443500baec 100644 --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -39,7 +39,7 @@ static inline int prepare_hugepage_range(struct file *file, #define arch_clear_hugepage_flags(page) do { } while (0) static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, - pte_t *ptep) + pte_t *ptep, unsigned long sz) { if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3) pte_val(*ptep) = _REGION3_ENTRY_EMPTY; diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index 99b490b4d05a..540354f94f83 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -31,10 +31,12 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) return pte_modify(pte, newprot); } +#ifndef huge_pte_clear static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, - pte_t *ptep) + pte_t *ptep, unsigned long sz) { pte_clear(mm, addr, ptep); } +#endif #endif /* _ASM_GENERIC_HUGETLB_H */ diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 0e4d1fb3122f..ddfed20cd637 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3338,7 +3338,7 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma, * unmapped and its refcount is dropped, so just clear pte here. */ if (unlikely(!pte_present(pte))) { - huge_pte_clear(mm, address, ptep); + huge_pte_clear(mm, address, ptep, sz); spin_unlock(ptl); continue; }