Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2800826imu; Thu, 29 Nov 2018 10:24:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/VDQK1uB5KISQFaox5HZ6JBvXsK79k5//ZaKiZUUEfckFcnZXSM7TMVI5p06jpRF3wnC5jU X-Received: by 2002:a17:902:bd46:: with SMTP id b6mr2481713plx.231.1543515878837; Thu, 29 Nov 2018 10:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543515878; cv=none; d=google.com; s=arc-20160816; b=MqnXoRRZJ6Vmnzx6AaEq7WaVjosb7ToskO4+Tv1h20A5T/sCvSBecal2q3HCOQ3wRe qfKli6X60a6Jpm06ForxM8Ldar2zB4/ZTCcFHjKVc3u31nYyxQ6EJtgo05RnJ71fjHVP 74o43WXxIY17lF3ta8XJulHjfJlIU91HUQfA5HJtJPxuFXWMmSM6bnokPXYsCtUJDYYf P+dCLMstVLUlbzXfrFA0sNdo78AurHxyBptfat++0RQx3OGaN1XfNfEIVaqRLypO/OiB pOOtiN/qThuGvwq8nK75j620/qGyxImX3159u0zL1PgVGwFw52HqwxqaRUK3BlZRtbys J9Kw== 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=3Mkx6Gwm6mvRuqZWhsjsZWoTZT+cUnRopC9aeDpfvck=; b=zC/EwHGDRfZ5nK8G2HsDEhb+WjS0TgCwHnYgmLamyvm8yXhE5VJXbX3NbsQgg3zaK1 PM40uiYtEeQLRGbq7gUrNhv7SWs5Y1u/k3kCvuo/xzGHzgHEk4HVuhNyFtsGKNYK8wSP oHqrb8s4S6GkI+vOPeOcpTtCqR6Tt84Z3twN1XwUhbF65xIhykt3D9OZ6U0nXNBeh0zs v9h++9nM/5HNAaQYxfxd9UF2l48wHfX0JuCYsr2zYOII2CinDDzSIULJ94Vi+xP5Mt00 jvr3yBdI9tTwajUWApIIcQmqLCWY6SOmWzabOydHIz2ntGqxM8M4go6z+rXTbpw18cqI Pk0g== 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 a34-v6si2898475pld.249.2018.11.29.10.24.22; Thu, 29 Nov 2018 10:24:38 -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 S1728805AbeK3BMi (ORCPT + 99 others); Thu, 29 Nov 2018 20:12:38 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:51240 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728466AbeK3BMi (ORCPT ); Thu, 29 Nov 2018 20:12:38 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 435K8X0vX5z9vGF3; Thu, 29 Nov 2018 15:07:08 +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 SPdzAjVuIv87; Thu, 29 Nov 2018 15:07:07 +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 435K8W6w0Jz9vGDm; Thu, 29 Nov 2018 15:07:07 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3C79F8B89E; Thu, 29 Nov 2018 15:07:09 +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 MEz3m4pADQxH; Thu, 29 Nov 2018 15:07:09 +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 083ED8B899; Thu, 29 Nov 2018 15:07:09 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id BEE7A69AE8; Thu, 29 Nov 2018 14:07:05 +0000 (UTC) Message-Id: <894f5c95319a078b9be1568487d6509f1bef44a2.1543499864.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v9 10/20] powerpc/mm: replace hugetlb_cache by PGT_CACHE(PTE_T_ORDER) To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 29 Nov 2018 14:07:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of opencoding cache handling for the special case of hugepage tables having a single pte_t element, this patch makes use of the common pgtable_cache helpers Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/hugetlb.h | 2 -- arch/powerpc/mm/hugetlbpage.c | 26 +++++++------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h index 98004262bc87..dfb8bf236586 100644 --- a/arch/powerpc/include/asm/hugetlb.h +++ b/arch/powerpc/include/asm/hugetlb.h @@ -5,8 +5,6 @@ #ifdef CONFIG_HUGETLB_PAGE #include -extern struct kmem_cache *hugepte_cache; - #ifdef CONFIG_PPC_BOOK3S_64 #include diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 8cf035e68378..c4f1263228b8 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -42,6 +42,8 @@ EXPORT_SYMBOL(HPAGE_SHIFT); #define hugepd_none(hpd) (hpd_val(hpd) == 0) +#define PTE_T_ORDER (__builtin_ffs(sizeof(pte_t)) - __builtin_ffs(sizeof(void *))) + pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, unsigned long sz) { /* @@ -61,7 +63,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, int num_hugepd; if (pshift >= pdshift) { - cachep = hugepte_cache; + cachep = PGT_CACHE(PTE_T_ORDER); num_hugepd = 1 << (pshift - pdshift); } else { cachep = PGT_CACHE(pdshift - pshift); @@ -264,7 +266,7 @@ static void hugepd_free_rcu_callback(struct rcu_head *head) unsigned int i; for (i = 0; i < batch->index; i++) - kmem_cache_free(hugepte_cache, batch->ptes[i]); + kmem_cache_free(PGT_CACHE(PTE_T_ORDER), batch->ptes[i]); free_page((unsigned long)batch); } @@ -277,7 +279,7 @@ static void hugepd_free(struct mmu_gather *tlb, void *hugepte) if (atomic_read(&tlb->mm->mm_users) < 2 || mm_is_thread_local(tlb->mm)) { - kmem_cache_free(hugepte_cache, hugepte); + kmem_cache_free(PGT_CACHE(PTE_T_ORDER), hugepte); put_cpu_var(hugepd_freelist_cur); return; } @@ -652,7 +654,6 @@ static int __init hugepage_setup_sz(char *str) } __setup("hugepagesz=", hugepage_setup_sz); -struct kmem_cache *hugepte_cache; static int __init hugetlbpage_init(void) { int psize; @@ -702,21 +703,8 @@ static int __init hugetlbpage_init(void) if (pdshift > shift) pgtable_cache_add(pdshift - shift, NULL); #if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_8xx) - else if (!hugepte_cache) { - /* - * Create a kmem cache for hugeptes. The bottom bits in - * the pte have size information encoded in them, so - * align them to allow this - */ - hugepte_cache = kmem_cache_create("hugepte-cache", - sizeof(pte_t), - HUGEPD_SHIFT_MASK + 1, - 0, NULL); - if (hugepte_cache == NULL) - panic("%s: Unable to create kmem cache " - "for hugeptes\n", __func__); - - } + else + pgtable_cache_add(PTE_T_ORDER, NULL); #endif } -- 2.13.3