Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2173097imu; Thu, 29 Nov 2018 00:11:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uu5TXr3kcuHrEpi36AIqbcZG7f54xmYNZwmHsAdsj3lYFiQqP4E8qzDE06e70wyM9Th0hm X-Received: by 2002:a63:e545:: with SMTP id z5mr404470pgj.195.1543479076739; Thu, 29 Nov 2018 00:11:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543479076; cv=none; d=google.com; s=arc-20160816; b=dX6AA2iPxAcCFENqnwqa/JXqWnurNKwS2ev9ST01JDxbm8uN/rP3lzoK3sQszUI0Cf +8PwrheaxCzLXPh9BJOkMinfl4yjV0mTXMgc3y4L+9phKU4q1oxJ9S23T5/PUAfm1Tj5 uzZiWSJq+H4t0PcXQ3UuEfGuOdJoBr7wpQFM1Kx/l90/SHOAJCktXFXV0ZPtk2jyOT7m Rdw2YNr8Zq9kSLSgNR/V4UB4RvvACOe7yKPZiUwImsjzbB2FeQjkuJuHQ9rxHEwkdhVT lwCX34oHQ9QEH/04rbOWdqFFeKZmYTLnWC7dUiG9/11Yc9qfjx3t5+yt3M52g3k1RJb0 YzQw== 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=DHJtg1cOsdvx+ES7LvZpit5odcaxsYYeM1J44i4T5xrojxLeFUGGwyxnXH5tJiOoc/ +5h/pb0cSKDSnVaG416Ag7EKGFmBNuFWg6zaxQ7YYsnyhd/JRTjeEpk61hg6oinsrQeA 2D7aVeGbqECYKUURnjedzFj8AZ6hnH5DIYWWrnhzc69exVLqTj9z3eIZ0jF5xBiSMyH/ JFpBu5xOykRzHugrQgHMZfk/rupwxCcAYAD6QmjAyn24I2MShuXWShTlGyzkBgtdaS1d R2C7vnD698m+9ij1sWnw/cDVB1e0q168TRgbrPhcqYpdpW8qcq7Ik00XvIwFuGben/q5 TVrA== 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 u3si1513034plb.99.2018.11.29.00.11.02; Thu, 29 Nov 2018 00:11:16 -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 S1728269AbeK2TO5 (ORCPT + 99 others); Thu, 29 Nov 2018 14:14:57 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:1045 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727573AbeK2TO5 (ORCPT ); Thu, 29 Nov 2018 14:14:57 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4359Dv4RTMz9vGpM; Thu, 29 Nov 2018 09:10:23 +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 nlqr_9EF-5s8; Thu, 29 Nov 2018 09:10:23 +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 4359Dv3zbpz9vGnx; Thu, 29 Nov 2018 09:10:23 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 68F628B891; Thu, 29 Nov 2018 09:10:24 +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 BAiVABMCs8g1; Thu, 29 Nov 2018 09:10:24 +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 3BCAB8B762; Thu, 29 Nov 2018 09:10:24 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id F002A69AEA; Thu, 29 Nov 2018 08:10:23 +0000 (UTC) Message-Id: <253ef37295b5c7eecdac4224d2defff54c889a4e.1543478200.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v8 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 08:10:23 +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