From patchwork Mon Oct 24 07:01:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 13016758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9812CC38A2D for ; Mon, 24 Oct 2022 07:03:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DC3F8E0002; Mon, 24 Oct 2022 03:03:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48BD48E0001; Mon, 24 Oct 2022 03:03:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37A878E0002; Mon, 24 Oct 2022 03:03:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 289BA8E0001 for ; Mon, 24 Oct 2022 03:03:05 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 016091C2E9E for ; Mon, 24 Oct 2022 07:03:04 +0000 (UTC) X-FDA: 80054951130.24.3A813D4 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf27.hostedemail.com (Postfix) with ESMTP id 6C20D40028 for ; Mon, 24 Oct 2022 07:03:03 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E6F5FB80ECB; Mon, 24 Oct 2022 07:03:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73E6FC433C1; Mon, 24 Oct 2022 07:02:55 +0000 (UTC) From: Huacai Chen To: Arnd Bergmann , Huacai Chen , Thomas Bogendoerfer , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Catalin Marinas , Will Deacon , Dinh Nguyen Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , Andrew Morton , linux-mm@kvack.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Huacai Chen , Feiyang Chen Subject: [PATCH V13 0/4] mm/sparse-vmemmap: Generalise helpers and enable for LoongArch Date: Mon, 24 Oct 2022 15:01:01 +0800 Message-Id: <20221024070105.306280-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666594984; a=rsa-sha256; cv=none; b=ld8GvoTM9IZ8kRWtm/8SPbxQgMpEustld7xo9xrOQGuB+dYC4BxW2aHgt56cClEYIy3jwR B5+vlGFw065qNYYJDlzW7h4LqxQss2b3Win7j7aPjKWxs0peMe9FA6DUaaYTcJu8Gbub/p kYCgOISutfaQnzjoKJKrW/dbifW4JCE= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.hostedemail.com: domain of "SRS0=G4cU=2Z=loongson.cn=chenhuacai@kernel.org" designates 145.40.68.75 as permitted sender) smtp.mailfrom="SRS0=G4cU=2Z=loongson.cn=chenhuacai@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666594984; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=Bo85nk7/kNf2GokfztbsBikxGblTMo1mRvJavvjKuAY=; b=ErTl96yFYzxHD9g1csVF2VR4p4d1O3DwJqQCedS3jcguUvRKhfFydXaKmpcAPTs0vU/Gvu mW4ouZ5kxjfl9xurmxTgpEde10yBkJDU5UELHB0eNuxfyXVdckMMWS5JVRr3rDA7CjQrq/ muyYtM9JPsseA5I9NMP/w22B87nMCZk= Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.hostedemail.com: domain of "SRS0=G4cU=2Z=loongson.cn=chenhuacai@kernel.org" designates 145.40.68.75 as permitted sender) smtp.mailfrom="SRS0=G4cU=2Z=loongson.cn=chenhuacai@kernel.org" X-Rspamd-Server: rspam04 X-Rspam-User: X-Stat-Signature: b5fjbahmdyp1wsc1ns1zt1krwdgcg8qp X-Rspamd-Queue-Id: 6C20D40028 X-HE-Tag: 1666594983-24228 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This series is in order to enable sparse-vmemmap for LoongArch. But LoongArch cannot use generic helpers directly because MIPS&LoongArch need to call pgd_init()/pud_init()/pmd_init() when populating page tables. So we adjust the prototypes of p?d_init() to make generic helpers can call them, then enable sparse-vmemmap with generic helpers, and to be further, generalise vmemmap_populate_hugepages() for ARM64, X86 and LoongArch. V1 -> V2: Split ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP to a separate patch. V2 -> V3: 1, Change the Signed-off-by order of author and committer; 2, Update commit message about the build error on LoongArch. V3 -> V4: Change pmd to pmdp for ARM64 for consistency. V4 -> V5: Add a detailed comment for no-fallback in the altmap case. V5 -> V6: 1, Fix build error for NIOS2; 2, Fix build error for allnoconfig; 3, Update comment for no-fallback in the altmap case. V6 -> V7: Fix build warnings of "no previous prototype". V7 -> V8: Fix build error for MIPS pud_init(). V8 -> V9: Remove redundant #include to avoid build error with latest upstream kernel. V9 -> V10: Fix build error due to VMEMMAP changes in 6.0-rc1. V10 -> V11: Adjust context due to ARM64 changes in 6.1-rc1. V11 -> V12: 1, Fix build error for !SPARSEMEM; 2, Simplify pagetable_init() for MIPS32. V12 -> V13: 1, Add Acked-by and Reviewed-by tags; 2, Update commit message for the 4th patch. Huacai Chen and Feiyang Chen(4): MIPS&LoongArch&NIOS2: Adjust prototypes of p?d_init(). LoongArch: Add sparse memory vmemmap support. mm/sparse-vmemmap: Generalise vmemmap_populate_hugepages(). LoongArch: Enable ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP. Signed-off-by: Huacai Chen Signed-off-by: Feiyang Chen --- arch/arm64/mm/mmu.c | 53 ++++++-------------- arch/loongarch/Kconfig | 2 + arch/loongarch/include/asm/pgalloc.h | 13 +---- arch/loongarch/include/asm/pgtable.h | 13 +++-- arch/loongarch/include/asm/sparsemem.h | 8 +++ arch/loongarch/kernel/numa.c | 4 +- arch/loongarch/mm/init.c | 44 +++++++++++++++- arch/loongarch/mm/pgtable.c | 23 +++++---- arch/mips/include/asm/pgalloc.h | 8 +-- arch/mips/include/asm/pgtable-64.h | 8 +-- arch/mips/kvm/mmu.c | 3 +- arch/mips/mm/pgtable-32.c | 10 ++-- arch/mips/mm/pgtable-64.c | 18 ++++--- arch/mips/mm/pgtable.c | 2 +- arch/x86/mm/init_64.c | 92 ++++++++++++---------------------- include/linux/mm.h | 8 +++ include/linux/page-flags.h | 1 + mm/sparse-vmemmap.c | 64 +++++++++++++++++++++++ 18 files changed, 222 insertions(+), 152 deletions(-) -- 2.27.0