Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14073850pxu; Mon, 4 Jan 2021 12:10:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhUGTf7WzsgtRyI4jBfosUTm/qy07uX5RmjdrJSI9nQwo2m/INekA84gTPNcMrWrCvOcEl X-Received: by 2002:aa7:cd44:: with SMTP id v4mr72430768edw.156.1609791026513; Mon, 04 Jan 2021 12:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609791026; cv=none; d=google.com; s=arc-20160816; b=RBaJhZE3Rz7TgN01XAokfXv6WNPyZyMpQZoOksPVILUpCMH9PjB008xCIZRxmqMdSf r1/e0UENQXesoimp1SGGHfOJjeffkilK553h1Xdldydu5Vp7W2SHzfbHHxzIgl9dT6Qc 4sHtAuZzgeFKRVJ/zXfJwbFp6vhFhLxizIZYY38rp0KI/xU6bd1yTpge23u5bUfnCCcb FIuTqVYIkCNubkbJsC8uUfHyP2KZYQv0c+abxwks+43XJveXxYBwg11LZp4Cb2qRH7KN B8+t7pD2n01P7DKQ3I3GRVllqlXy6zVJOGQrBKwkp22NZ3ygp5XXvgI2L0T2xDa5u0Op 28Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/jz5QJlg1TmKqG/vuXGtHxW/zIB2+jBi1Y5ZNhCCafI=; b=NYRgHLNbpCFCRVX9PKL29z3K9sZRTFPxl9aUCjc+5cQYqietaZL0b9gz1KJ/lxnxVV /5b4bj1n3pyRKf/zJGwreGwU2Yg7xSXTkcUkeoZ79oPHokMeMlAPcsUYLtqNM9n8qFzV eW7adU7Nde3w90XaRUMKArlm3SJ9JO2qjnV241ZxOhqolHrKnk7c0YcqQ2eZgl96Vr+h Oz5lO5oxffqbxJe5oh22KjzskOVGc1vUZlYHbobvV5kikicJ6qWfU7hUxjYbI3RPrrdk 6I27TxY4i5UVQbAIJcnCKEi6x5ug+JMn52aaIBgHJ4Ji+3iLirK8W32G+OW98D87OlRd 9qqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb8si23953103edb.511.2021.01.04.12.10.02; Mon, 04 Jan 2021 12:10:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727672AbhADUG7 (ORCPT + 99 others); Mon, 4 Jan 2021 15:06:59 -0500 Received: from relay11.mail.gandi.net ([217.70.178.231]:58531 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbhADUG7 (ORCPT ); Mon, 4 Jan 2021 15:06:59 -0500 Received: from debian.home (lfbn-gre-1-231-212.w90-112.abo.wanadoo.fr [90.112.190.212]) (Authenticated sender: alex@ghiti.fr) by relay11.mail.gandi.net (Postfix) with ESMTPSA id BC5A9100002; Mon, 4 Jan 2021 20:06:13 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Zong Li , Anup Patel , Christoph Hellwig , Ard Biesheuvel , Arnd Bergmann , linux-efi@vger.kernel.org, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [RFC PATCH 07/12] asm-generic: Prepare for riscv use of pud_alloc_one and pud_free Date: Mon, 4 Jan 2021 14:58:35 -0500 Message-Id: <20210104195840.1593-8-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210104195840.1593-1-alex@ghiti.fr> References: <20210104195840.1593-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the following commits, riscv will almost use the generic versions of pud_alloc_one and pud_free but an additional check is required since those functions are only relevant when using at least a 4-level page table, which will be determined at runtime on riscv. So move the content of those functions into other functions that riscv can use without duplicating code. Signed-off-by: Alexandre Ghiti --- include/asm-generic/pgalloc.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/include/asm-generic/pgalloc.h b/include/asm-generic/pgalloc.h index 02932efad3ab..977bea16cf1b 100644 --- a/include/asm-generic/pgalloc.h +++ b/include/asm-generic/pgalloc.h @@ -147,6 +147,15 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) #if CONFIG_PGTABLE_LEVELS > 3 +static inline pud_t *__pud_alloc_one(struct mm_struct *mm, unsigned long addr) +{ + gfp_t gfp = GFP_PGTABLE_USER; + + if (mm == &init_mm) + gfp = GFP_PGTABLE_KERNEL; + return (pud_t *)get_zeroed_page(gfp); +} + #ifndef __HAVE_ARCH_PUD_ALLOC_ONE /** * pud_alloc_one - allocate a page for PUD-level page table @@ -159,20 +168,23 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) */ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) { - gfp_t gfp = GFP_PGTABLE_USER; - - if (mm == &init_mm) - gfp = GFP_PGTABLE_KERNEL; - return (pud_t *)get_zeroed_page(gfp); + return __pud_alloc_one(mm, addr); } #endif -static inline void pud_free(struct mm_struct *mm, pud_t *pud) +static inline void __pud_free(struct mm_struct *mm, pud_t *pud) { BUG_ON((unsigned long)pud & (PAGE_SIZE-1)); free_page((unsigned long)pud); } +#ifndef __HAVE_ARCH_PUD_FREE +static inline void pud_free(struct mm_struct *mm, pud_t *pud) +{ + __pud_free(mm, pud); +} +#endif + #endif /* CONFIG_PGTABLE_LEVELS > 3 */ #ifndef __HAVE_ARCH_PGD_FREE -- 2.20.1