From patchwork Mon Mar 17 18:51:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 3845981 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 84F349F370 for ; Mon, 17 Mar 2014 18:52:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71A9820218 for ; Mon, 17 Mar 2014 18:52:46 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 603D120166 for ; Mon, 17 Mar 2014 18:52:45 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPceN-00061b-Sq; Mon, 17 Mar 2014 18:52:40 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPceL-0003jt-LF; Mon, 17 Mar 2014 18:52:37 +0000 Received: from mail-wg0-f52.google.com ([74.125.82.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPceH-0003iP-Js for linux-arm-kernel@lists.infradead.org; Mon, 17 Mar 2014 18:52:34 +0000 Received: by mail-wg0-f52.google.com with SMTP id k14so4936364wgh.23 for ; Mon, 17 Mar 2014 11:52:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xJX4jv+Hqn50F+0PlI+3Ejz2d0+nJGzdd5yq+LuTG04=; b=MkU02Mo4jqJ8+RvgVzexf4G1o7LU6oPKHu4ViBQ5i2Spw8pgTjPwHYaaJ+iX4jWhnK hHHPxKXpM0Sls8ysVdJvBUOx3FEyQIZ1Es6COek/R6qt7kDUBCn45gx5JkfMQRRvR2n0 Fa1dudNCAod1DxgmWg4B2FL2g3bD2bos+jBz4rHMdYAlpCeo9DG3pOBlwMGRd2SaBTGo lG+8vWQO3E5c5mYg19xG3ERo7OvukCMlp/Ao5xi0+g9vhruiz1dbfB1pZWsrKM59wh9+ wlhmCvyPYXJ1pSapVp7SoKfzY4xX1jIDB1eq1nng813Azy1QfFWPJpJiKhwc1p724SrT ZaBw== X-Gm-Message-State: ALoCoQm9ziAIKGCGSKjNzCatDTfZ5GDINJNF4v8D9I+HvnV8XfbsocL1pTtfM6qeDHhjXX0ObBfz X-Received: by 10.180.165.238 with SMTP id zb14mr10999796wib.51.1395082330779; Mon, 17 Mar 2014 11:52:10 -0700 (PDT) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id t5sm40585608wjw.15.2014.03.17.11.52.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Mar 2014 11:52:10 -0700 (PDT) From: Steve Capper To: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [RESEND PATCH] mm: hugetlb: Introduce huge_pte_{page, present, young} Date: Mon, 17 Mar 2014 18:51:58 +0000 Message-Id: <1395082318-7703-1-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140317_145233_750069_974026AF X-CRM114-Status: GOOD ( 14.11 ) X-Spam-Score: -2.6 (--) Cc: catalin.marinas@arm.com, akpm@linux-foundation.org, Steve Capper X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce huge pte versions of pte_page, pte_present and pte_young. This allows ARM (without LPAE) to use alternative pte processing logic for huge ptes. Where these functions are not defined by architectural code they fallback to the standard functions. Signed-off-by: Steve Capper --- Hi, I'm resending this patch to provoke some discussion. We already have some huge_pte_ style functions, and this patch adds a few more (that simplify to the pte_ equivalents where unspecified). Having separate hugetlb versions of pte_page, present and mkyoung allows for a greatly simplified huge page implementation for ARM with the classical MMU (which has a different bit layout for huge ptes). Cheers, diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 8c43cc4..4992487 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -353,6 +353,18 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma, } #endif +#ifndef huge_pte_page +#define huge_pte_page(pte) pte_page(pte) +#endif + +#ifndef huge_pte_present +#define huge_pte_present(pte) pte_present(pte) +#endif + +#ifndef huge_pte_mkyoung +#define huge_pte_mkyoung(pte) pte_mkyoung(pte) +#endif + static inline struct hstate *page_hstate(struct page *page) { VM_BUG_ON_PAGE(!PageHuge(page), page); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index c01cb9f..d1a38c9 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2319,7 +2319,7 @@ static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, entry = huge_pte_wrprotect(mk_huge_pte(page, vma->vm_page_prot)); } - entry = pte_mkyoung(entry); + entry = huge_pte_mkyoung(entry); entry = pte_mkhuge(entry); entry = arch_make_huge_pte(entry, vma, page, writable); @@ -2379,7 +2379,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, if (cow) huge_ptep_set_wrprotect(src, addr, src_pte); entry = huge_ptep_get(src_pte); - ptepage = pte_page(entry); + ptepage = huge_pte_page(entry); get_page(ptepage); page_dup_rmap(ptepage); set_huge_pte_at(dst, addr, dst_pte, entry); @@ -2398,7 +2398,7 @@ static int is_hugetlb_entry_migration(pte_t pte) { swp_entry_t swp; - if (huge_pte_none(pte) || pte_present(pte)) + if (huge_pte_none(pte) || huge_pte_present(pte)) return 0; swp = pte_to_swp_entry(pte); if (non_swap_entry(swp) && is_migration_entry(swp)) @@ -2411,7 +2411,7 @@ static int is_hugetlb_entry_hwpoisoned(pte_t pte) { swp_entry_t swp; - if (huge_pte_none(pte) || pte_present(pte)) + if (huge_pte_none(pte) || huge_pte_present(pte)) return 0; swp = pte_to_swp_entry(pte); if (non_swap_entry(swp) && is_hwpoison_entry(swp)) @@ -2464,7 +2464,7 @@ again: goto unlock; } - page = pte_page(pte); + page = huge_pte_page(pte); /* * If a reference page is supplied, it is because a specific * page is being unmapped, not a range. Ensure the page we @@ -2614,7 +2614,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long mmun_start; /* For mmu_notifiers */ unsigned long mmun_end; /* For mmu_notifiers */ - old_page = pte_page(pte); + old_page = huge_pte_page(pte); retry_avoidcopy: /* If no-one else is actually using this page, avoid the copy @@ -2965,7 +2965,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, * Note that locking order is always pagecache_page -> page, * so no worry about deadlock. */ - page = pte_page(entry); + page = huge_pte_page(entry); get_page(page); if (page != pagecache_page) lock_page(page); @@ -2985,7 +2985,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, } entry = huge_pte_mkdirty(entry); } - entry = pte_mkyoung(entry); + entry = huge_pte_mkyoung(entry); if (huge_ptep_set_access_flags(vma, address, ptep, entry, flags & FAULT_FLAG_WRITE)) update_mmu_cache(vma, address, ptep); @@ -3077,7 +3077,7 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, } pfn_offset = (vaddr & ~huge_page_mask(h)) >> PAGE_SHIFT; - page = pte_page(huge_ptep_get(pte)); + page = huge_pte_page(huge_ptep_get(pte)); same_page: if (pages) { pages[i] = mem_map_offset(page, pfn_offset); @@ -3425,7 +3425,7 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address, { struct page *page; - page = pte_page(*(pte_t *)pmd); + page = huge_pte_page(*(pte_t *)pmd); if (page) page += ((address & ~PMD_MASK) >> PAGE_SHIFT); return page; @@ -3437,7 +3437,7 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address, { struct page *page; - page = pte_page(*(pte_t *)pud); + page = huge_pte_page(*(pte_t *)pud); if (page) page += ((address & ~PUD_MASK) >> PAGE_SHIFT); return page;