Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2175418imu; Thu, 29 Nov 2018 00:14:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/XwnDiXuVZ85JJnFKTQcV6Sq7qSXqrOZwX5tOwHCcWW6IOxIcs7Hmknei0DLYhblAMg9TNe X-Received: by 2002:a63:334a:: with SMTP id z71mr425816pgz.400.1543479262326; Thu, 29 Nov 2018 00:14:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543479262; cv=none; d=google.com; s=arc-20160816; b=jyqdNe9//e+8hv66G+vDxdcUuakjlzCaSeiXBdvPtxARMSOd63Uv3xS/BDUEIBKjdd zCr9OVhxcMZ+mKttxkqM4crU51tt/iPLC62CJ/pSWEQbAJnpCCF5j7pNwr11X3Tj03Mi OjRYwPskX0UgLTQJBQ7QvmFiTXFDWFAlckCUBxlkfzUzUiUKFmlCOW68rIdhvLD1NMLq D3A4xHt9LfMCRgp1nhEvkBE87j2v2bMDhZCy5VTstjyiiQe2byT6ka3ekgwWwxmy5uaO dElEjxXScKvheEEf8Hx3VdGWhzslbCuvYiHBig5rUEYXOc6lWLW5vM9+kO2LA24njptv QhWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=qudjWPvmfdvC2Ru+t72GMbwuTWMo5ak17K09kIhoSFY=; b=N3rRZEw/YuBR/zILO1Ge6WTpnidZgvTfHEJr4ejKRzppeqCuAgarx03ncH0wk7QdvC AtLXDUw+szzg8duPz9HOOHNfzWGGIMmtOx5NM1mqrr9kM3Z1JwUIIgaLxvG3uR8qHN6A x1ENOJ0JhuRZZUSwD4O56J2YPC4GH2gvU0PcXYbwAtsnFXG61UxUkv80iCnJ7E54PMd7 NkBrzWcHmhCOCTTAETlMySiz6S3EvcukhjYTtYjmFYFkG08+wjbxQiG8KGtlEs946kcz S5VFJQZnSXfwAJ12WP81NGQdfrS0dRUBbnFU1z1DhHhNKi4OAbicbRCkbKCgX3DOUbM/ oAGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si1310136pgb.319.2018.11.29.00.14.07; Thu, 29 Nov 2018 00:14:22 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbeK2TOw (ORCPT + 99 others); Thu, 29 Nov 2018 14:14:52 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:14905 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727573AbeK2TOv (ORCPT ); Thu, 29 Nov 2018 14:14:51 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4359Dn4nVZz9vGpG; Thu, 29 Nov 2018 09:10:17 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id naLc8MdWD7XE; Thu, 29 Nov 2018 09:10:17 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4359Dn4DLHz9vGnx; Thu, 29 Nov 2018 09:10:17 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4EB3B8B890; Thu, 29 Nov 2018 09:10:18 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id fx6xAQO86wUv; Thu, 29 Nov 2018 09:10:18 +0100 (CET) Received: from po14163vm.idsi0.si.c-s.fr (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 21A328B762; Thu, 29 Nov 2018 09:10:18 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id DFB1169AEA; Thu, 29 Nov 2018 08:10:17 +0000 (UTC) Message-Id: <38d940b8c582aa41f4c16975e9c1eda7baeb6a5d.1543478200.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v8 07/20] powerpc/mm: add helpers to get/set mm.context->pte_frag To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 29 Nov 2018 08:10:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to handle pte_fragment functions with single fragment without adding pte_frag in all mm_context_t, this patch creates two helpers which do nothing on platforms using a single fragment. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/pgtable.h | 31 +++++++++++++++++++++++++++++++ arch/powerpc/mm/pgtable-frag.c | 8 ++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 9679b7519a35..734df2210749 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -110,6 +110,37 @@ void mark_initmem_nx(void); static inline void mark_initmem_nx(void) { } #endif +/* + * When used, PTE_FRAG_NR is defined in subarch pgtable.h + * so we are sure it is included when arriving here. + */ +#ifndef PTE_FRAG_NR +#define PTE_FRAG_NR 1 +#define PTE_FRAG_SIZE_SHIFT PAGE_SHIFT +#define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT) +#endif + +#if PTE_FRAG_NR != 1 +static inline void *pte_frag_get(mm_context_t *ctx) +{ + return ctx->pte_frag; +} + +static inline void pte_frag_set(mm_context_t *ctx, void *p) +{ + ctx->pte_frag = p; +} +#else +static inline void *pte_frag_get(mm_context_t *ctx) +{ + return NULL; +} + +static inline void pte_frag_set(mm_context_t *ctx, void *p) +{ +} +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_H */ diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c index 7544d0d7177d..af23a587f019 100644 --- a/arch/powerpc/mm/pgtable-frag.c +++ b/arch/powerpc/mm/pgtable-frag.c @@ -38,7 +38,7 @@ static pte_t *get_pte_from_cache(struct mm_struct *mm) return NULL; spin_lock(&mm->page_table_lock); - ret = mm->context.pte_frag; + ret = pte_frag_get(&mm->context); if (ret) { pte_frag = ret + PTE_FRAG_SIZE; /* @@ -46,7 +46,7 @@ static pte_t *get_pte_from_cache(struct mm_struct *mm) */ if (((unsigned long)pte_frag & ~PAGE_MASK) == 0) pte_frag = NULL; - mm->context.pte_frag = pte_frag; + pte_frag_set(&mm->context, pte_frag); } spin_unlock(&mm->page_table_lock); return (pte_t *)ret; @@ -86,9 +86,9 @@ static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel) * the allocated page with single fragement * count. */ - if (likely(!mm->context.pte_frag)) { + if (likely(!pte_frag_get(&mm->context))) { atomic_set(&page->pt_frag_refcount, PTE_FRAG_NR); - mm->context.pte_frag = ret + PTE_FRAG_SIZE; + pte_frag_set(&mm->context, ret + PTE_FRAG_SIZE); } spin_unlock(&mm->page_table_lock); -- 2.13.3