Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2174448imu; Thu, 29 Nov 2018 00:13:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/XxOsXRLh7n4BMVXT/JVThWsdytH/plL16aOf0Dv2AJ0BdCJPd6unkZ/ct52qbKH9XwShFq X-Received: by 2002:a63:d70e:: with SMTP id d14mr414169pgg.159.1543479182906; Thu, 29 Nov 2018 00:13:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543479182; cv=none; d=google.com; s=arc-20160816; b=HigDQOkw4T3MOLUWJ5p+SYNzs5J/UvS7xT3UqHNAnzeZqyVVfUchqtJcEzxXt08EEq EKEtJFaomM13KgA/e0hwLlCXcNvUM/IBFwJflj3ghOa+SMUU37mIoJXlGZZNUuslhlff Ewh4ua2seKC1NodRwi4TDw3kY9v4BWvN9uEphARbGLNr6viS3rQ3VsV+/eWa7RraZEsC hoctMITIxBB78qtjjag2/bRJqHkvWI8he0eizndJ3PBzObj7LGyvU2NxqcNijE1wrAUB KL8sWk95RQgkn04ilUZ2BSEOQsRVAukEP2FeWHr3YpYZQNjSiYJwpvVyHU/B+u6PL0G6 ShXg== 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=IePneqPv9OcdyPp1VXicL9hXCnnvLa3HAZFc7YRAjn0=; b=xekf1G7NiTQpmlDb5vSr9PQCXHJQgITox3yfoHhIn5nDOS02A+nqHeVEnmSrZMrgoX JRpE53VE0NKFHucilg7tjgwUHaHvSAfNrPdc4VgIrh6WH4mQOXVQt2iH7tDfgPUsV1dy 2ZoHxceBLB3fWcxHlwLOpppWGbzEWG60T4vHqgJV0KGkWZwt08lh74QXRSCIn2ObpHYe 3uOGO3l/WkcxpnEgoHa7w4qIEojaqxI/JEewXp/6b5wt5DF5/3RKuISlKmuzK6opirl1 lTlE5BhaxEyNCP6Qm33NNG2QQt6ZLMEwwrLZI8SumP6jnp2EnIWTr6eZhpVS7Ek1QaYe bP0Q== 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 r197si1658928pfc.116.2018.11.29.00.12.47; Thu, 29 Nov 2018 00:13:02 -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 S1728248AbeK2TO4 (ORCPT + 99 others); Thu, 29 Nov 2018 14:14:56 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:18081 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728221AbeK2TOz (ORCPT ); Thu, 29 Nov 2018 14:14:55 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4359Dt1L3Tz9vGpR; Thu, 29 Nov 2018 09:10:22 +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 UfFX0fpWyTAm; Thu, 29 Nov 2018 09:10:22 +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 4359Dt0v68z9vGnx; Thu, 29 Nov 2018 09:10:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 7C64A8B892; Thu, 29 Nov 2018 09:10:22 +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 kDz3VkZ_sSNo; Thu, 29 Nov 2018 09:10:22 +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 3955F8B762; Thu, 29 Nov 2018 09:10:22 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id EADFB69AEA; Thu, 29 Nov 2018 08:10:21 +0000 (UTC) Message-Id: <3e20d7b05718ccd700cb1dd982e78aec75f45e39.1543478200.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v8 09/20] powerpc/mm: enable the use of page table cache of order 0 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:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hugepages uses a cache of order 0. Lets allow page tables of order 0 in the common part in order to avoid open coding in hugetlb Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/32/pgalloc.h | 5 +---- arch/powerpc/include/asm/book3s/64/pgalloc.h | 5 +---- arch/powerpc/include/asm/nohash/32/pgalloc.h | 5 +---- arch/powerpc/include/asm/nohash/64/pgalloc.h | 5 +---- arch/powerpc/mm/init-common.c | 6 +++--- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/32/pgalloc.h b/arch/powerpc/include/asm/book3s/32/pgalloc.h index 0f58e5b9dbe7..b5b955eb2fb7 100644 --- a/arch/powerpc/include/asm/book3s/32/pgalloc.h +++ b/arch/powerpc/include/asm/book3s/32/pgalloc.h @@ -25,10 +25,7 @@ extern void __bad_pte(pmd_t *pmd); extern struct kmem_cache *pgtable_cache[]; -#define PGT_CACHE(shift) ({ \ - BUG_ON(!(shift)); \ - pgtable_cache[(shift) - 1]; \ - }) +#define PGT_CACHE(shift) pgtable_cache[shift] static inline pgd_t *pgd_alloc(struct mm_struct *mm) { diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h index f949dd90af9b..4aba625389c4 100644 --- a/arch/powerpc/include/asm/book3s/64/pgalloc.h +++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h @@ -37,10 +37,7 @@ extern struct vmemmap_backing *vmemmap_list; #define MAX_PGTABLE_INDEX_SIZE 0xf extern struct kmem_cache *pgtable_cache[]; -#define PGT_CACHE(shift) ({ \ - BUG_ON(!(shift)); \ - pgtable_cache[(shift) - 1]; \ - }) +#define PGT_CACHE(shift) pgtable_cache[shift] extern pte_t *pte_fragment_alloc(struct mm_struct *, unsigned long, int); extern pmd_t *pmd_fragment_alloc(struct mm_struct *, unsigned long); diff --git a/arch/powerpc/include/asm/nohash/32/pgalloc.h b/arch/powerpc/include/asm/nohash/32/pgalloc.h index 7e234582dce5..17963951bdb0 100644 --- a/arch/powerpc/include/asm/nohash/32/pgalloc.h +++ b/arch/powerpc/include/asm/nohash/32/pgalloc.h @@ -25,10 +25,7 @@ extern void __bad_pte(pmd_t *pmd); extern struct kmem_cache *pgtable_cache[]; -#define PGT_CACHE(shift) ({ \ - BUG_ON(!(shift)); \ - pgtable_cache[(shift) - 1]; \ - }) +#define PGT_CACHE(shift) pgtable_cache[shift] static inline pgd_t *pgd_alloc(struct mm_struct *mm) { diff --git a/arch/powerpc/include/asm/nohash/64/pgalloc.h b/arch/powerpc/include/asm/nohash/64/pgalloc.h index e2d62d033708..e95eb499a174 100644 --- a/arch/powerpc/include/asm/nohash/64/pgalloc.h +++ b/arch/powerpc/include/asm/nohash/64/pgalloc.h @@ -36,10 +36,7 @@ extern struct vmemmap_backing *vmemmap_list; #define MAX_PGTABLE_INDEX_SIZE 0xf extern struct kmem_cache *pgtable_cache[]; -#define PGT_CACHE(shift) ({ \ - BUG_ON(!(shift)); \ - pgtable_cache[(shift) - 1]; \ - }) +#define PGT_CACHE(shift) pgtable_cache[shift] static inline pgd_t *pgd_alloc(struct mm_struct *mm) { diff --git a/arch/powerpc/mm/init-common.c b/arch/powerpc/mm/init-common.c index 2b656e67f2ea..41190f2b60c2 100644 --- a/arch/powerpc/mm/init-common.c +++ b/arch/powerpc/mm/init-common.c @@ -40,7 +40,7 @@ static void pmd_ctor(void *addr) memset(addr, 0, PMD_TABLE_SIZE); } -struct kmem_cache *pgtable_cache[MAX_PGTABLE_INDEX_SIZE]; +struct kmem_cache *pgtable_cache[MAX_PGTABLE_INDEX_SIZE + 1]; EXPORT_SYMBOL_GPL(pgtable_cache); /* used by kvm_hv module */ /* @@ -71,7 +71,7 @@ void pgtable_cache_add(unsigned shift, void (*ctor)(void *)) * moment, gcc doesn't seem to recognize is_power_of_2 as a * constant expression, so so much for that. */ BUG_ON(!is_power_of_2(minalign)); - BUG_ON((shift < 1) || (shift > MAX_PGTABLE_INDEX_SIZE)); + BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE); if (PGT_CACHE(shift)) return; /* Already have a cache of this size */ @@ -83,7 +83,7 @@ void pgtable_cache_add(unsigned shift, void (*ctor)(void *)) panic("Could not allocate pgtable cache for order %d", shift); kfree(name); - pgtable_cache[shift - 1] = new; + pgtable_cache[shift] = new; pr_debug("Allocated pgtable cache for order %d\n", shift); } -- 2.13.3