From patchwork Wed Apr 5 13:37:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9664269 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 8F92660353 for ; Wed, 5 Apr 2017 14:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 824922074F for ; Wed, 5 Apr 2017 14:20:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7669728588; Wed, 5 Apr 2017 14:20:28 +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 00FF72074F for ; Wed, 5 Apr 2017 14:20:27 +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=VLeX2Gffe33e+ChFGeWYjLXEoOkzH6cHQjAg/EzuUGQ=; b=Tmi2LPdlWaTC7fWDLtme3Vh4XC FXdMVEb484rahiSV1qH5nfeF4iuXi0wh/rByU/B4QjYJ6qGCwOQw21zlJ89VlrAAEe0Pc0JJPPr+/ FgxP4w+veud6cZ32670Fo3WZ3SV+93SFfbLCM6+ms/24oAerwMwqaf3QGuGrz9NxEp6WEI01jQAXB T8secuVgXMX5jclSiQXtbXOnbhUnRJsUSW52KidwCGznBCp05GFH78JeUwS8w+lNTAA+ziloUjCvt S65IMDYakqFoi9HfRG/9rcyKzQNw3LL5xxbssLRLZpbFLt+2rpu8hwT2INpLSixMJDw6N45QYB4Z8 6+YNFHqw==; 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 1cvlnP-00026I-2b; Wed, 05 Apr 2017 14:20:27 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvlnM-00025S-61 for linux-arm-kernel@bombadil.infradead.org; Wed, 05 Apr 2017 14:20:24 +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=lbVPoEYf9VtYSOl5qIR/4KethU0AorEft7ATYj7nb1o=; b=Sd9QbfC47VT5UmoAMfMR5t9Y/ utRtWtvme5Zn/O1wtKBffLFOTWWfjHyT8ommgovZTqeeaaDsfXxlX/WCX5pGyLX5CCKKrzTq4m7n0 76072fN8OD6jd1RR/xOB/5uG3dbS5lxciUxTKoYo+vxn1sQD+yWPEoCiKw0VozGOdYUsZpVr6gPye x0Je1gBNlAv4gGq3uTwnH+V6pD4BcBZRz/QRbIgCRF1q0WIGoXw+VZt0Xar0Y/KdngPkOdP5ALqvf IUlQn8upP4sC5Z0iM3fkV0a+2GZElgnKvQWk2n4CrT9OTLAs8l238RdNStqpBnwlPYvidi1iWsV99 KxPGxQpAw==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cvl8u-0000UN-Vf for linux-arm-kernel@lists.infradead.org; Wed, 05 Apr 2017 13:38:38 +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 8253A165C; Wed, 5 Apr 2017 06:38:14 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.195.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 53C823F3E1; Wed, 5 Apr 2017 06:38:14 -0700 (PDT) From: Punit Agrawal To: catalin.marinas@arm.com, will.deacon@arm.com, akpm@linux-foundation.org, mark.rutland@arm.com Subject: [PATCH v2 5/9] mm/hugetlb: Introduce set_huge_swap_pte_at() helper Date: Wed, 5 Apr 2017 14:37:18 +0100 Message-Id: <20170405133722.6406-6-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170405133722.6406-1-punit.agrawal@arm.com> References: <20170405133722.6406-1-punit.agrawal@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170405_093837_163641_46738F51 X-CRM114-Status: GOOD ( 11.08 ) 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: hillf.zj@alibaba-inc.com, Punit Agrawal , steve.capper@arm.com, "Aneesh Kumar K.V" , tbaicar@codeaurora.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, kirill.shutemov@linux.intel.com, 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 set_huge_pte_at(), an architecture callback to populate hugepage ptes, does not provide the range of virtual memory that is targetted. This leads to ambiguity when dealing with swap entries on architectures that support hugepages consisting of contiguous ptes. Fix the problem by introducing an overridable helper that is called when populating the page tables with swap entries. The size of the targetted region is provided to the helper to help determine the number of entries to be updated. Provide a default implementation that maintains the current behaviour. Signed-off-by: Punit Agrawal Cc: Mike Kravetz Cc: "Aneesh Kumar K.V" --- include/linux/hugetlb.h | 2 ++ mm/hugetlb.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 23010a3b2047..fa65ad73a65f 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -127,6 +127,8 @@ int pud_huge(pud_t pud); unsigned long hugetlb_change_protection(struct vm_area_struct *vma, unsigned long address, unsigned long end, pgprot_t newprot); +void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned long sz); #else /* !CONFIG_HUGETLB_PAGE */ static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 2b0f6f96f2c1..a27e926913f4 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3211,6 +3211,12 @@ static int is_hugetlb_entry_hwpoisoned(pte_t pte) return 0; } +void __weak set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned long sz) +{ + set_huge_pte_at(mm, addr, ptep, pte); +} + int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, struct vm_area_struct *vma) { @@ -3263,9 +3269,10 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, */ make_migration_entry_read(&swp_entry); entry = swp_entry_to_pte(swp_entry); - set_huge_pte_at(src, addr, src_pte, entry); + set_huge_swap_pte_at(src, addr, src_pte, + entry, sz); } - set_huge_pte_at(dst, addr, dst_pte, entry); + set_huge_swap_pte_at(dst, addr, dst_pte, entry, sz); } else { if (cow) { huge_ptep_set_wrprotect(src, addr, src_pte); @@ -4283,7 +4290,8 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma, make_migration_entry_read(&entry); newpte = swp_entry_to_pte(entry); - set_huge_pte_at(mm, address, ptep, newpte); + set_huge_swap_pte_at(mm, address, ptep, + newpte, huge_page_size(h)); pages++; } spin_unlock(ptl);