From patchwork Mon Jun 19 17:01:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9797035 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 93CAB601C8 for ; Mon, 19 Jun 2017 17:20:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F55427F92 for ; Mon, 19 Jun 2017 17:20:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6407D28435; Mon, 19 Jun 2017 17:20:30 +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 1005E283B0 for ; Mon, 19 Jun 2017 17:20:29 +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=3EgoC7KoRjp3q5faxuMLIZzhwSXclEaJ5beeKhKmbKg=; b=eQ0bAagGNUb8c/pDceqS/PIcjh 5sXQWybdnQ7pAMCrRfTWR99TUTWykuBFyL+jbFM2kROXryHtcyWHmNpbtaAvdxVrLFDE2IJqNzXJ4 gQwSPBUQMfN2FlBnRM5qeMdSpX/Ub6HWxZEY7VHbwh98NnK3ZzwcER8na/HsFEjIMVfWB9LU9/T1W xhsFTMOFEVGgCZ7kElnnIxC+fqPiznU9RO1HTincMI8PQ8Cu9R0Cef1Fop9pkNkI5QVNagsYYPw5B D5kkXbZ4k4hERtgAm/TG8SrTgekyNeO04wss4uQTaVt4GkHRBFPniIVDJHeRp2Har+QHmfFZTzdxW uH714fsw==; 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 1dN0Lh-0007uk-NX; Mon, 19 Jun 2017 17:20:25 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dN0LH-000637-9L for linux-arm-kernel@bombadil.infradead.org; Mon, 19 Jun 2017 17:19:59 +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=DViDIhKZBtDbhHa+Pz0G/oGmL2Jr08zEtubWJWQOS3Y=; b=lsALOxuiaB9iR5qNFLZ7htqoo XKeFiuqVly8XarN2rpZLblKN64L5m7TO6GXL+2Pxy2iBDk8O1g2BuAGjA9F9cy1BnfyTSM3l6EG0z 56mfnIzWHU6Q8CkanwH2UZRgsYZEljL0AxcFJdP2SoQd+Mc7oboSAxO+s1OAixbueRTBycjXgSgAL knUAJwDShDx8wsxJVrx04Qk2WG5rbQu76GXeSJwHy8c87tvwb74M3SOuqsXTuyJTOqE+vurohDI0K InLK/csrjN2GOcWuFsplvMTyfWZg8t2jkWQVibYqUHI4BD08+Ql+X5MRxSFieEzwvONopdE/hfEou rcVQGObmg==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dN05C-0002Yo-B6 for linux-arm-kernel@lists.infradead.org; Mon, 19 Jun 2017 17:03:24 +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 BE64B165C; Mon, 19 Jun 2017 10:03:02 -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 8BE3A3F41F; Mon, 19 Jun 2017 10:03:02 -0700 (PDT) From: Punit Agrawal To: akpm@linux-foundation.org Subject: [PATCH v5 7/8] mm/hugetlb: Introduce set_huge_swap_pte_at() helper Date: Mon, 19 Jun 2017 18:01:44 +0100 Message-Id: <20170619170145.25577-8-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619170145.25577-1-punit.agrawal@arm.com> References: <20170619170145.25577-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail 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, 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 set_huge_pte_at(), an architecture callback to populate hugepage ptes, does not provide the range of virtual memory that is targeted. 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 for architectures needing this support. The helper is called when populating the page tables with swap entries. The size of the targeted 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 Acked-by: Steve Capper Cc: Mike Kravetz Cc: "Aneesh Kumar K.V" --- include/linux/hugetlb.h | 13 +++++++++++++ mm/hugetlb.c | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 23010a3b2047..af859564509e 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -502,6 +502,14 @@ static inline void hugetlb_count_sub(long l, struct mm_struct *mm) { atomic_long_sub(l, &mm->hugetlb_usage); } + +#ifndef set_huge_swap_pte_at +static inline void 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); +} +#endif #else /* CONFIG_HUGETLB_PAGE */ struct hstate {}; #define alloc_huge_page(v, a, r) NULL @@ -546,6 +554,11 @@ static inline void hugetlb_report_usage(struct seq_file *f, struct mm_struct *m) static inline void hugetlb_count_sub(long l, struct mm_struct *mm) { } + +static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned long sz) +{ +} #endif /* CONFIG_HUGETLB_PAGE */ static inline spinlock_t *huge_pte_lock(struct hstate *h, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b20620ff3751..2017f3f89ab7 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3263,9 +3263,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); @@ -4282,7 +4283,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);