From patchwork Tue Jun 4 09:08:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13684912 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 16C97C25B7E for ; Tue, 4 Jun 2024 09:09:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E7646B0089; Tue, 4 Jun 2024 05:09:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6972B6B008A; Tue, 4 Jun 2024 05:09:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 537976B008C; Tue, 4 Jun 2024 05:09:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 329116B0089 for ; Tue, 4 Jun 2024 05:09:10 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 97D811A033D for ; Tue, 4 Jun 2024 09:09:09 +0000 (UTC) X-FDA: 82192632018.24.DEC47C3 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf25.hostedemail.com (Postfix) with ESMTP id 81E10A0013 for ; Tue, 4 Jun 2024 09:09:07 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=FNYsIXO4; spf=pass (imf25.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.67 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717492147; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=PzIzp+ixMNHCeCKZs399tnTjJhrG7D+k1l6DCFs334k=; b=g2ysJxVu4tE6UEUWB+q9AVB7lMXptr8SSs+iC9KM5nA9bHKX/2gk4cKFlK8dlKDIO+2zuy nStX0oIHpDALAqexGaEX2m9Jt/9v3uSIglLw+1spqn845s6Udt9knnc0nRhv/RXX72Surg YZZIJTNJZBEJCfnVFJ9SyX+t2LmHzns= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=FNYsIXO4; spf=pass (imf25.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.67 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717492147; a=rsa-sha256; cv=none; b=qiX5aOZu1EAo8sdcHAf2/A+KQBVjZVDt4ZXDSIr7DYrbIsRq1UMzhUOBRDG+OuQA+1D1zF qBAVxWL7BvOe0cpo0EewAu8MFP0KGsL+S7mG7q1UuVDRgsIt3RGdJE/MBGF0TFVq4NqKqk yosQZuFPM62uld/Xi2L7PxroK23D88Y= Received: by mail-ej1-f67.google.com with SMTP id a640c23a62f3a-a68b54577aaso315390966b.3 for ; Tue, 04 Jun 2024 02:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492146; x=1718096946; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PzIzp+ixMNHCeCKZs399tnTjJhrG7D+k1l6DCFs334k=; b=FNYsIXO4qVStL8H9wTfpOgmVI/ORBrp6kgR8AOdYylV4wbJmgX9Q/GtkQjN2oEM8t/ /C484xmew36Eoi8c7xPUvZ0ZGAh3ovcMwmgjXQxSnXrynMWhoD922IIUbO0xN+QuE/2P E8r13FUzY4I3hmzOJY1naZyoyesgzx2kLW0VLLad/g4Ai4hGxXW+yb/HMSIh3zbVS2eT kmjUW5kLMn4KxuHWNTwMNKbC20xl5ZYk1daWUFqADkjwRkj3/Ogt8f1aRrnNAWPEvmoL iVneLK5LBnaX1VU7Rt4TQfLZnUMgu/NuIsbb6sr0DO8Hf6MyPRRPY223wnR9ne2WXHGr g9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492146; x=1718096946; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PzIzp+ixMNHCeCKZs399tnTjJhrG7D+k1l6DCFs334k=; b=otwss5eoJsSZ9E0qKB5wUC4Z8SxdLLZk0aDObWq9mKSj8QtRDin3aHFMWCWuelrrtZ cLlzySpfkU7hDj04MdJ13OuH76EsmDC7szlCznT1CuCx8O/dksfLhaucZQnItaSTGhmP GXN53jBDr5h/DwNFTvXC38reCxpmjeSiDL+XxNrYJGu7u5r7blHnTX6G88XmpeVbLZmR bY59YHrf85nLqx8Xf+BmCVSBBaB2HDOT67XPZ0ww5ZM649tGdw2Si67QddGQz/dCaTk0 e4gqzRSwQE3+dORzgJfNIHmwzBwVnLpSMbxy/FcBKO3xhsguSU3qo3dXtP02I356PXf1 xn7A== X-Forwarded-Encrypted: i=1; AJvYcCWykrN2TzUD1ipaCFIHLf7+NszVkiL7pYDG1MyzEbKJ2GluPHFVAVCDFicTRm9A+nD6RtqNJlhYYM+5JP9nmubaCus= X-Gm-Message-State: AOJu0Yw1x09etmL6X8noIzV7lMkqFNuk4SX+1KzhC+Xbi6Mlzhz6ec7D VQwRT7fYQUjUIYH6MdLBK/0i0fsigU3BrxatDtCbx/u+Ovef9tvPDU3wFcDdnjupgbhcDN5sR62 kvnyCww== X-Google-Smtp-Source: AGHT+IF0CVeraAix/Wu1DETz7eZJsftNnxHZh4LxVOxqHFlDfvUyJXKOpdf7qe5jC/cidD4CraAUaw== X-Received: by 2002:a17:906:3415:b0:a68:a287:da78 with SMTP id a640c23a62f3a-a68a287e3e7mr584081866b.62.1717492145637; Tue, 04 Jun 2024 02:09:05 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:04 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 00/15] Fast kernel headers: split linux/mm.h Date: Tue, 4 Jun 2024 11:08:30 +0200 Message-Id: <20240604090845.2182265-1-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 81E10A0013 X-Stat-Signature: 3g7ij748beb8ygjdmcggbfxcm39dpbyn X-Rspam-User: X-HE-Tag: 1717492147-280073 X-HE-Meta: U2FsdGVkX1+HT+FzgSa7M//FKjHzA9fs8WNlyESL7WGAcKofC7IBCt7+WE6zIMJuYd3l7U75xwlfNjjKrdwIljt8eVP/hRnPDtr4vgzqQPWNx0rzkKFW808XKDUS+BfXlgG8k7vL/97w81/jQsq9Id6fYXTkVE/F7aB3IMUnD9j+Y36RdIUnTpNX993SvjzDvv+BL1kh1NEX79+zKqTiB3NM1B34GRBjeNmMwjhLknbHhHFRW3+rRxPKSXixbFnnQrfKEk4my/35oDyncUdlvaCNl0dM30E0domYWobJpQzxdK+V416xCxDynivYoCdB10zHtTfiJ5K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sqk8JueEODJ8IFWjye5CME1oKDMxBP0yPIo76ecpF/WdCyQlutvQuAFDZk8cLyLxnDgcd/LpWCasqFdydQozodA/A== 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: List-Subscribe: List-Unsubscribe: This patch set aims to clean up the linux/mm.h header and reduce dependencies on it by moving parts out. The goal was to eliminate dependencies on linux/mm.h from other popular headers such as highmem.h and dma-mapping.h, and I started by checking which symbols were really used and moved those declarations to separate slim headers. This patch set borrows the name "fast kernel headers" from Ingo Molnar's effort a few years ago. While this kind of refactoring does indeed improve build times because the amount of code that has to be processed in each compilation unit is reduced, build speed is the least important advantage. Much more important is that this gives us greater confidence that the code is correct: if we forget to include a header, it might (or might not) already be included indirectly by some other header somewhere down the large impenetrable include tree. Chances are almost 100% that linux/kernel.h or linux/mm.h gets included somewhere, which then in turn includes everything else. Now if this indirect include just happens to be changed eventually, the build may suddenly fail at remote places. Worse, an #ifdef may silently produce different code. Therefore, at each source file, all the includes that are needed should be included directly (but not more). This is only possible if headers are small, and linux/mm.h and linux/kernel.h are large offenders resisting the cleanup. Therefore, splitting those is the first step towards leaner header dependencies. This patch set starts with linux/mm.h, and I am already preparing another patch set addressing linux/kernel.h. Some of these changes were part of a previous, bigger patch set (https://lore.kernel.org/lkml/20240131145008.1345531-1-max.kellermann@ionos.com/) but this patch set grew so large, it could not be reviewed. This is an attempt to break the patch set into smaller pieces. --- v1 -> v2: added more explanations to commit messages; renamed several new headers from page_*.h to folio_*.h as suggested by Matthew Wilcox; rebase on linux-next; fix build failures on architectures um,nios2,hexagon by adding more missing includes v2 -> v3: rebase on linux-next v3 -> v4: rebase on linux-next; fix build failure on loongarch64 (reported by kernel test robot); add missing includes to drivers/dma/bcm2835-dma.c and include/scsi/scsicam.h v4 -> v5: rebase on linux-next; more text in cover letter as suggested by David Hildenbrand v5 -> v6: rebase on linux-next d04466706db5...d97496ca23a2 Max Kellermann (15): drivers: add missing includes on linux/mm.h (and others) include/drm/drm_gem.h: add poll_table_struct forward declaration include/scsi/scsicam.h: forward-declare struct block_device linux/mm.h: move page_kasan_tag() to mm/page_kasan_tag.h linux/mm.h: move section functions to mm/page_section.h linux/mm.h: move page_address() and others to mm/page_address.h linux/mm.h: move folio_size(), ... to mm/folio_size.h linux/mm.h: move folio_next() to mm/folio_next.h linux/mm.h: move devmap-related declarations to mm/devmap_managed.h linux/mm.h: move usage count functions to mm/folio_usage.h linux/mm.h: move page_zone_id() and more to mm/folio_zone.h linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h linux/mm.h: move is_vmalloc_addr() to mm/vmalloc_addr.h linux/mm.h: move high_memory to mm/high_memory.h include: reduce dependencies on linux/mm.h MAINTAINERS | 1 + arch/arm/include/asm/memory.h | 4 + arch/arm/include/asm/pgtable.h | 2 + arch/arm/mm/iomap.c | 3 + arch/csky/include/asm/page.h | 1 + arch/hexagon/include/asm/mem-layout.h | 4 + arch/m68k/include/asm/page_mm.h | 1 + arch/m68k/include/asm/pgtable_mm.h | 1 + arch/parisc/include/asm/floppy.h | 1 + arch/powerpc/include/asm/book3s/32/pgtable.h | 4 + arch/powerpc/include/asm/nohash/32/pgtable.h | 1 + arch/powerpc/include/asm/page.h | 1 + arch/x86/include/asm/floppy.h | 1 + arch/x86/include/asm/pgtable_32_areas.h | 4 + drivers/comedi/comedi_buf.c | 1 + .../qat/qat_common/adf_gen4_pm_debugfs.c | 1 + drivers/dma/bcm2835-dma.c | 1 + drivers/dma/dma-axi-dmac.c | 1 + drivers/dma/sh/rcar-dmac.c | 1 + drivers/firmware/qcom/qcom_scm-legacy.c | 1 + drivers/firmware/qcom/qcom_scm-smc.c | 1 + drivers/firmware/raspberrypi.c | 1 + drivers/iio/buffer/industrialio-buffer-dma.c | 1 + drivers/iommu/iommufd/ioas.c | 2 + drivers/iommu/iommufd/selftest.c | 1 + drivers/media/platform/mediatek/vpu/mtk_vpu.c | 1 + drivers/media/platform/ti/omap/omap_voutlib.c | 1 + drivers/misc/bcm-vk/bcm_vk_dev.c | 1 + drivers/misc/fastrpc.c | 1 + drivers/misc/genwqe/card_dev.c | 1 + drivers/misc/uacce/uacce.c | 1 + drivers/mtd/nand/onenand/onenand_samsung.c | 1 + drivers/mtd/spi-nor/core.h | 2 + drivers/pci/p2pdma.c | 1 + drivers/pci/pci.c | 1 + drivers/remoteproc/mtk_scp.c | 1 + drivers/remoteproc/remoteproc_core.c | 1 + drivers/soc/qcom/rmtfs_mem.c | 1 + drivers/spi/spi-aspeed-smc.c | 1 + drivers/spi/spi-bcm2835.c | 2 + drivers/spi/spi-intel.c | 1 + drivers/virtio/virtio_ring.c | 1 + include/drm/drm_file.h | 1 + include/linux/bio.h | 2 + include/linux/bpfptr.h | 1 - include/linux/dma-mapping.h | 1 + include/linux/highmem-internal.h | 2 + include/linux/highmem.h | 4 +- include/linux/huge_mm.h | 2 + include/linux/iommu.h | 1 + include/linux/mm.h | 598 +----------------- include/linux/mm/devmap_managed.h | 32 + include/linux/mm/folio_next.h | 27 + include/linux/mm/folio_size.h | 150 +++++ include/linux/mm/folio_usage.h | 182 ++++++ include/linux/mm/folio_zone.h | 56 ++ include/linux/mm/high_memory.h | 7 + include/linux/mm/page_address.h | 71 +++ include/linux/mm/page_kasan_tag.h | 66 ++ include/linux/mm/page_section.h | 23 + include/linux/mm/pfmemalloc.h | 52 ++ include/linux/mm/vmalloc_addr.h | 33 + include/linux/net.h | 2 +- include/linux/nvme-keyring.h | 2 + include/linux/oom.h | 2 +- include/linux/page-flags.h | 3 + include/linux/pagemap.h | 2 +- include/linux/scatterlist.h | 8 +- include/linux/skbuff.h | 4 + include/linux/vmstat.h | 2 + include/scsi/scsicam.h | 5 + kernel/dma/ops_helpers.c | 1 + kernel/dma/remap.c | 1 + kernel/rcu/rcutorture.c | 1 + lib/scatterlist.c | 1 + mm/dmapool.c | 1 + 76 files changed, 811 insertions(+), 595 deletions(-) create mode 100644 include/linux/mm/devmap_managed.h create mode 100644 include/linux/mm/folio_next.h create mode 100644 include/linux/mm/folio_size.h create mode 100644 include/linux/mm/folio_usage.h create mode 100644 include/linux/mm/folio_zone.h create mode 100644 include/linux/mm/high_memory.h create mode 100644 include/linux/mm/page_address.h create mode 100644 include/linux/mm/page_kasan_tag.h create mode 100644 include/linux/mm/page_section.h create mode 100644 include/linux/mm/pfmemalloc.h create mode 100644 include/linux/mm/vmalloc_addr.h