From patchwork Wed Apr 16 11:46:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 28462 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 313132036A for ; Wed, 16 Apr 2014 11:48:26 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id va2sf27920327obc.9 for ; Wed, 16 Apr 2014 04:48:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=vmLfXYC59dXazWmawpLKKcrYpVHh5wV2mmViOtzn11I=; b=NPdQeMwUiErNqPas74qKR+KMDOhQxijxfSRmC96RP/kHFr0T2YNeC01Rb7RgItEGZO ihIRGA9CGu/gwBEAXrjZzeND6gzNpuheSBBUhiqatgmzSdpX+A4UkKiUp2g1zTA4n0f8 dniIwY/WRL03J47StsNslWxGSthMDJsu4cPZRuWGcstrqpLUoCpY54udHOhZVbHBzUKr X72M+NOyGlmNrUC5Pm9k1xmNSAFBRRrZK6gm3lQ2mPD0cHLtB0FeIYAXZwndgbpNKx2I AmV6Drf1JjmLlpv8iRUTRuQKJEPf6SbdEhiQu9cxAvJE0mrSFzyGHvoQPbWX0Ga0+ARd 5Rrw== X-Gm-Message-State: ALoCoQlD/AvTukNQseM2N2VSFS2K/JPTJr/P+d2FFjBXDDo7ajDVvIOoJlgaCyqAeAkGzwyK5YQk X-Received: by 10.182.60.37 with SMTP id e5mr3666780obr.30.1397648905693; Wed, 16 Apr 2014 04:48:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.28.137 with SMTP id 9ls551387qgz.14.gmail; Wed, 16 Apr 2014 04:48:25 -0700 (PDT) X-Received: by 10.52.95.135 with SMTP id dk7mr1032240vdb.32.1397648905504; Wed, 16 Apr 2014 04:48:25 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id u5si3828355vdo.58.2014.04.16.04.48.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Apr 2014 04:48:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so10425110veb.36 for ; Wed, 16 Apr 2014 04:48:25 -0700 (PDT) X-Received: by 10.52.166.102 with SMTP id zf6mr2214040vdb.2.1397648905280; Wed, 16 Apr 2014 04:48:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp305533vcb; Wed, 16 Apr 2014 04:48:24 -0700 (PDT) X-Received: by 10.68.133.229 with SMTP id pf5mr7903815pbb.115.1397648904292; Wed, 16 Apr 2014 04:48:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zm10si11745161pbc.103.2014.04.16.04.48.23; Wed, 16 Apr 2014 04:48:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756140AbaDPLrb (ORCPT + 26 others); Wed, 16 Apr 2014 07:47:31 -0400 Received: from mail-we0-f179.google.com ([74.125.82.179]:58249 "EHLO mail-we0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755988AbaDPLqx (ORCPT ); Wed, 16 Apr 2014 07:46:53 -0400 Received: by mail-we0-f179.google.com with SMTP id x48so10888280wes.10 for ; Wed, 16 Apr 2014 04:46:51 -0700 (PDT) X-Received: by 10.194.186.140 with SMTP id fk12mr6594912wjc.47.1397648811751; Wed, 16 Apr 2014 04:46:51 -0700 (PDT) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id mw4sm24116996wib.12.2014.04.16.04.46.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Apr 2014 04:46:51 -0700 (PDT) From: Steve Capper To: linux@arm.linux.org.uk, akpm@linux-foundation.org Cc: will.deacon@arm.com, catalin.marinas@arm.com, robherring2@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gerald.schaefer@de.ibm.com, Steve Capper Subject: [PATCH V2 1/5] mm: hugetlb: Introduce huge_pte_{page, present, young} Date: Wed, 16 Apr 2014 12:46:39 +0100 Message-Id: <1397648803-15961-2-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397648803-15961-1-git-send-email-steve.capper@linaro.org> References: <1397648803-15961-1-git-send-email-steve.capper@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: steve.capper@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. Generic implementations that call the standard pte versions are also added to asm-generic/hugetlb.h. Signed-off-by: Steve Capper Acked-by: Gerald Schaefer --- arch/s390/include/asm/hugetlb.h | 15 +++++++++++++++ include/asm-generic/hugetlb.h | 15 +++++++++++++++ mm/hugetlb.c | 22 +++++++++++----------- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h index 11eae5f..7b13ec0 100644 --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -112,4 +112,19 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) return pte_modify(pte, newprot); } +static inline struct page *huge_pte_page(pte_t pte) +{ + return pte_page(pte); +} + +static inline unsigned long huge_pte_present(pte_t pte) +{ + return pte_present(pte); +} + +static inline pte_t huge_pte_mkyoung(pte_t pte) +{ + return pte_mkyoung(pte); +} + #endif /* _ASM_S390_HUGETLB_H */ diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index 99b490b..2dc68fe 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -37,4 +37,19 @@ static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, pte_clear(mm, addr, ptep); } +static inline struct page *huge_pte_page(pte_t pte) +{ + return pte_page(pte); +} + +static inline unsigned long huge_pte_present(pte_t pte) +{ + return pte_present(pte); +} + +static inline pte_t huge_pte_mkyoung(pte_t pte) +{ + return pte_mkyoung(pte); +} + #endif /* _ASM_GENERIC_HUGETLB_H */ diff --git a/mm/hugetlb.c b/mm/hugetlb.c index dd30f22..1e77c07 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2350,7 +2350,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); @@ -2410,7 +2410,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); @@ -2429,7 +2429,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)) @@ -2442,7 +2442,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)) @@ -2495,7 +2495,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 @@ -2645,7 +2645,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 @@ -3033,7 +3033,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); @@ -3053,7 +3053,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); @@ -3144,7 +3144,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); @@ -3501,7 +3501,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; @@ -3513,7 +3513,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;