Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2503680imu; Thu, 29 Nov 2018 06:08:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/U14KMDw9VrCX+M4QmdtUNZXW05i6QvJo0HkiUyCxbjW9JrpD10HqZahhWlL4FQZaSDS5me X-Received: by 2002:a62:d148:: with SMTP id t8mr1573090pfl.52.1543500503385; Thu, 29 Nov 2018 06:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543500503; cv=none; d=google.com; s=arc-20160816; b=J7TESiIyJDKb2cR8dw1w7AWvxFFZkEWo3kZ+4tXM7Ijkw8FMM1YvBs5nFczGxul49K 2ER3+CCr2OSlV5wnoLxaNcNBkqUA1XxuUTtdnuaPiW7IJNRKzgEXM5SB5Thm2ZGLgpr1 sUq/t5+5St1UAJ6KJUp5LiJ1WZGR3D3eJG66GB/bpnrWBba6osueCsOp+46CA8L+9j4k 5OF7CejCb3QNbpKnq2/E3p5Jb8kiosCKFQ8tipRi1p0JTAY5j//F/K3RYqm3VAQ3pcDb dR8GPcaYOvlVKSgBdeyfNTYAcxNRkKE6mFDd2hIogW+q07Cc4+u7LZYcLoPld8DhAZU3 /71Q== 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=jFBa/3LFPPSIP6jgq2MNvWhEDhkkpqJHZIYRviZmNso=; b=YhmEPhEFzkWfg2A3EVIoP2NaSEP3zqK9w3S4GtWDydUZXr6joMPk4UWcyTI7S27mBP HgxrQDxOqEV5b+K3v8bEb1Zb5zgfK1LuAu1zAgPWIrTwUZe4fziVH1iaKMBeKCMHU1ra rhujw6W+szEW+TMuIpi6Pq2P4DLXlD0NPq1FKIfEGX9dEGR3ug5o0wZBDCWLtUa5b0Tt RzGwinCWrKfceJVgQDULJ02Y5GMl7AVFsgRbF9W8QWeIb6HDVIDlYUO3Y7liMUlbo7ci 8UtcpTUjBYtWjwnym5gg1zsBRzqU0EAxuLbA32i0eYKf7rcGkr6J9WafVc3tqxupmJMX mtQg== 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 i5si2234808pfo.189.2018.11.29.06.08.00; Thu, 29 Nov 2018 06:08:23 -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 S1728693AbeK3BMa (ORCPT + 99 others); Thu, 29 Nov 2018 20:12:30 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:13724 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728492AbeK3BM3 (ORCPT ); Thu, 29 Nov 2018 20:12:29 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 435K8L6vKtz9vFvn; Thu, 29 Nov 2018 15:06:58 +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 mtfUfyq8z1bz; Thu, 29 Nov 2018 15:06:58 +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 435K8L6Nklz9vFvc; Thu, 29 Nov 2018 15:06:58 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 28B1F8B89E; Thu, 29 Nov 2018 15:07:00 +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 LEhOPfuUjyG4; Thu, 29 Nov 2018 15:07:00 +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 E820C8B899; Thu, 29 Nov 2018 15:06:59 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id AC07569AE8; Thu, 29 Nov 2018 14:06:59 +0000 (UTC) Message-Id: <02136697ed7be9ca538a02e571a8f21737d3927e.1543499863.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v9 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 14:06:59 +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 | 25 +++++++++++++++++++++++++ arch/powerpc/mm/pgtable-frag.c | 8 ++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 9679b7519a35..314a2890a972 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -110,6 +110,31 @@ 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. + */ +#ifdef PTE_FRAG_NR +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