Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1042350imu; Wed, 28 Nov 2018 03:48:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/VmHEX9+2I75gUA/Zt/WjpMlyJZwVVYu1oQjXvMzPHQl4NHzCHbdvdyd3u6P9hcXL3MXooW X-Received: by 2002:a17:902:15c5:: with SMTP id a5-v6mr36168203plh.136.1543405680412; Wed, 28 Nov 2018 03:48:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543405680; cv=none; d=google.com; s=arc-20160816; b=iwuJe3Q4G4ufZE8A3Yzfon03LcKOnD8JK+qbjPew83Ps1Fk04/Ev3GpR51RI11rHbs mfP1i2q4uV+OON6W3eoCJXeIqXkA9k8+0hVaYkeS2nUbSjkKJgN2K3cuhyzSy2bgF/K6 2AtCTKA2R1044gYLapHM834dUlZA5TIqNfiuEQWU3QV9ezeoRthCSH8c8jiKcHrIzYH2 g6w8w3VfbeiXEJPCAiYQKuPCDfcuIikmQoXZ1z9KH1jH7EJIYrAIDL/k06dKsoqzw5pD Ku8K6UqpgQ+JOgMTbLxj/UUyoPOVOb+/d+qlZk7KPMl4hfjxT2X8vpxdUaDqfNx5Srr5 5DNA== 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=igN10bRZ3lKC00pIfTHWHb33a3Z5Jg+Tr13ISB3PbHg=; b=LIg14uskGB3MQs24HY9bzIKdJ4/p5as60Ghq6avK83SSPUqLSoWNHgz/RiF3BQCJGM 0hgikqKBArNoMh93sebsdLEnHg/f21Ra40u4jvQcCiIFJjL2B+fEICm9OPGWBh4P84C3 8ODqdNwhJAwLvvcEkd0JFkL/bmSR4eiNTG/ClhWzgkmdWxTjD2iHQJfdbuG97wlfx3R0 OAr42JZf5CmX1mFD67cq644DI+jB9EOdew+/71psfNKUg7E7l23gvGgJxf6qYa6GLuEY PdQ59hURMGXh1Ph59kSdq/r/kjwavAtDULpy0s3KSEo2iWA3EclwOq0du5mCc5/UGYmI LWWA== 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 3si7514961plx.33.2018.11.28.03.47.45; Wed, 28 Nov 2018 03:48:00 -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 S1728821AbeK1WsC (ORCPT + 99 others); Wed, 28 Nov 2018 17:48:02 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:9679 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728152AbeK1WsA (ORCPT ); Wed, 28 Nov 2018 17:48:00 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 434f4q0Gzyz9v0B1; Wed, 28 Nov 2018 12:46:35 +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 RUKxz_ISEySv; Wed, 28 Nov 2018 12:46:34 +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 434f4p6vNqz9v09s; Wed, 28 Nov 2018 12:46:34 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0C0CB8B867; Wed, 28 Nov 2018 12:46:36 +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 yQ1O-Qh54ehg; Wed, 28 Nov 2018 12:46:35 +0100 (CET) Received: from po14163vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id EA3C38B853; Wed, 28 Nov 2018 12:46:35 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id CE5D969B1B; Wed, 28 Nov 2018 11:46:35 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v7 07/16] 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: Wed, 28 Nov 2018 11:46:35 +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 1c49ca31dcfe..74810bba45d2 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