The patch titled Subject: mm: don't include <linux/memremap.h> in <linux/mm.h> has been added to the -mm tree. Its filename is mm-dont-include-linux-memremaph-in-linux-mmh.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-dont-include-linux-memremaph-in-linux-mmh.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-dont-include-linux-memremaph-in-linux-mmh.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Christoph Hellwig <hch@xxxxxx> Subject: mm: don't include <linux/memremap.h> in <linux/mm.h> Move the check for the actual pgmap types that need the free at refcount one behavior into the out of line helper, and thus avoid the need to pull memremap.h into mm.h. Link: https://lkml.kernel.org/r/20220210072828.2930359-7-hch@xxxxxx Signed-off-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Reviewed-by: Dan Williams <dan.j.williams@xxxxxxxxx> Acked-by: Felix Kuehling <Felix.Kuehling@xxxxxxx> Tested-by: "Sierra Guiza, Alejandro (Alex)" <alex.sierra@xxxxxxx> Cc: Alex Deucher <alexander.deucher@xxxxxxx> Cc: Alistair Popple <apopple@xxxxxxxxxx> Cc: Ben Skeggs <bskeggs@xxxxxxxxxx> Cc: Chaitanya Kulkarni <kch@xxxxxxxxxx> Cc: Christian Knig <christian.koenig@xxxxxxx> Cc: Karol Herbst <kherbst@xxxxxxxxxx> Cc: Lyude Paul <lyude@xxxxxxxxxx> Cc: Miaohe Lin <linmiaohe@xxxxxxxxxx> Cc: Muchun Song <songmuchun@xxxxxxxxxxxxx> Cc: "Pan, Xinhui" <Xinhui.Pan@xxxxxxx> Cc: Ralph Campbell <rcampbell@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/arch/arm64/mm/mmu.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/arch/arm64/mm/mmu.c @@ -17,6 +17,7 @@ #include <linux/mman.h> #include <linux/nodemask.h> #include <linux/memblock.h> +#include <linux/memremap.h> #include <linux/memory.h> #include <linux/fs.h> #include <linux/io.h> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -25,6 +25,7 @@ #include <linux/hashtable.h> #include <linux/mmu_notifier.h> +#include <linux/memremap.h> #include <linux/mutex.h> #include <linux/types.h> #include <linux/atomic.h> --- a/drivers/gpu/drm/drm_cache.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/drivers/gpu/drm/drm_cache.c @@ -27,11 +27,11 @@ /* * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com> */ - #include <linux/dma-buf-map.h> #include <linux/export.h> #include <linux/highmem.h> #include <linux/cc_platform.h> +#include <linux/ioport.h> #include <xen/xen.h> #include <drm/drm_cache.h> --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -39,6 +39,7 @@ #include <linux/sched/mm.h> #include <linux/hmm.h> +#include <linux/memremap.h> #include <linux/migrate.h> /* --- a/drivers/gpu/drm/nouveau/nouveau_svm.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -35,6 +35,7 @@ #include <linux/sched/mm.h> #include <linux/sort.h> #include <linux/hmm.h> +#include <linux/memremap.h> #include <linux/rmap.h> struct nouveau_svm { --- a/drivers/infiniband/core/rw.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/drivers/infiniband/core/rw.c @@ -2,6 +2,7 @@ /* * Copyright (c) 2016 HGST, a Western Digital Company. */ +#include <linux/memremap.h> #include <linux/moduleparam.h> #include <linux/slab.h> #include <linux/pci-p2pdma.h> --- a/drivers/nvdimm/pmem.h~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/drivers/nvdimm/pmem.h @@ -3,6 +3,7 @@ #define __NVDIMM_PMEM_H__ #include <linux/page-flags.h> #include <linux/badblocks.h> +#include <linux/memremap.h> #include <linux/types.h> #include <linux/pfn_t.h> #include <linux/fs.h> --- a/drivers/nvme/host/pci.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/drivers/nvme/host/pci.c @@ -15,6 +15,7 @@ #include <linux/init.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/memremap.h> #include <linux/mm.h> #include <linux/module.h> #include <linux/mutex.h> --- a/drivers/nvme/target/io-cmd-bdev.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/drivers/nvme/target/io-cmd-bdev.c @@ -6,6 +6,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/blkdev.h> #include <linux/blk-integrity.h> +#include <linux/memremap.h> #include <linux/module.h> #include "nvmet.h" --- a/fs/fuse/virtio_fs.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/fs/fuse/virtio_fs.c @@ -8,6 +8,7 @@ #include <linux/dax.h> #include <linux/pci.h> #include <linux/pfn_t.h> +#include <linux/memremap.h> #include <linux/module.h> #include <linux/virtio.h> #include <linux/virtio_fs.h> --- a/include/linux/memremap.h~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/include/linux/memremap.h @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ #ifndef _LINUX_MEMREMAP_H_ #define _LINUX_MEMREMAP_H_ + +#include <linux/mm.h> #include <linux/range.h> #include <linux/ioport.h> #include <linux/percpu-refcount.h> @@ -129,6 +131,22 @@ static inline unsigned long pgmap_vmemma return 1 << pgmap->vmemmap_shift; } +static inline bool is_device_private_page(const struct page *page) +{ + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && + IS_ENABLED(CONFIG_DEVICE_PRIVATE) && + is_zone_device_page(page) && + page->pgmap->type == MEMORY_DEVICE_PRIVATE; +} + +static inline bool is_pci_p2pdma_page(const struct page *page) +{ + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && + IS_ENABLED(CONFIG_PCI_P2PDMA) && + is_zone_device_page(page) && + page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA; +} + #ifdef CONFIG_ZONE_DEVICE bool pfn_zone_device_reserved(unsigned long pfn); void *memremap_pages(struct dev_pagemap *pgmap, int nid); --- a/include/linux/mm.h~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/include/linux/mm.h @@ -23,7 +23,6 @@ #include <linux/err.h> #include <linux/page-flags.h> #include <linux/page_ref.h> -#include <linux/memremap.h> #include <linux/overflow.h> #include <linux/sizes.h> #include <linux/sched.h> @@ -1096,9 +1095,6 @@ static inline bool put_devmap_managed_pa return false; if (!is_zone_device_page(page)) return false; - if (page->pgmap->type != MEMORY_DEVICE_PRIVATE && - page->pgmap->type != MEMORY_DEVICE_FS_DAX) - return false; return __put_devmap_managed_page(page); } @@ -1109,22 +1105,6 @@ static inline bool put_devmap_managed_pa } #endif /* CONFIG_DEV_PAGEMAP_OPS */ -static inline bool is_device_private_page(const struct page *page) -{ - return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && - IS_ENABLED(CONFIG_DEVICE_PRIVATE) && - is_zone_device_page(page) && - page->pgmap->type == MEMORY_DEVICE_PRIVATE; -} - -static inline bool is_pci_p2pdma_page(const struct page *page) -{ - return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && - IS_ENABLED(CONFIG_PCI_P2PDMA) && - is_zone_device_page(page) && - page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA; -} - /* 127: arbitrary random number, small enough to assemble well */ #define folio_ref_zero_or_close_to_overflow(folio) \ ((unsigned int) folio_ref_count(folio) + 127u <= 127u) --- a/lib/test_hmm.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/lib/test_hmm.c @@ -12,6 +12,7 @@ #include <linux/kernel.h> #include <linux/cdev.h> #include <linux/device.h> +#include <linux/memremap.h> #include <linux/mutex.h> #include <linux/rwsem.h> #include <linux/sched.h> --- a/mm/memcontrol.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/mm/memcontrol.c @@ -53,6 +53,7 @@ #include <linux/fs.h> #include <linux/seq_file.h> #include <linux/vmpressure.h> +#include <linux/memremap.h> #include <linux/mm_inline.h> #include <linux/swap_cgroup.h> #include <linux/cpu.h> --- a/mm/memremap.c~mm-dont-include-linux-memremaph-in-linux-mmh +++ a/mm/memremap.c @@ -4,7 +4,7 @@ #include <linux/io.h> #include <linux/kasan.h> #include <linux/memory_hotplug.h> -#include <linux/mm.h> +#include <linux/memremap.h> #include <linux/pfn_t.h> #include <linux/swap.h> #include <linux/mmzone.h> @@ -525,6 +525,10 @@ void free_devmap_managed_page(struct pag bool __put_devmap_managed_page(struct page *page) { + if (page->pgmap->type != MEMORY_DEVICE_PRIVATE && + page->pgmap->type != MEMORY_DEVICE_FS_DAX) + return false; + /* * devmap page refcounts are 1-based, rather than 0-based: if * refcount is 1, then the page is free and the refcount is _ Patches currently in -mm which might be from hch@xxxxxx are mm-unexport-page_init_poison.patch mm-remove-a-pointless-config_zone_device-check-in-memremap_pages.patch mm-remove-the-__kernel__-guard-from-linux-mmh.patch mm-remove-pointless-includes-from-linux-hmmh.patch mm-move-free_devmap_managed_page-to-memremapc.patch mm-simplify-freeing-of-devmap-managed-pages.patch mm-dont-include-linux-memremaph-in-linux-mmh.patch mm-remove-the-extra-zone_device-struct-page-refcount.patch fsdax-depend-on-zone_device-fs_dax_limited.patch mm-generalize-the-pgmap-based-page_free-infrastructure.patch mm-refactor-check_and_migrate_movable_pages.patch mm-refactor-the-zone_device-handling-in-migrate_vma_insert_page.patch mm-refactor-the-zone_device-handling-in-migrate_vma_pages.patch mm-move-the-migrate_vma_-device-migration-code-into-its-own-file.patch mm-build-migrate_vma_-for-all-configs-with-zone_device-support.patch mm-add-zone-device-coherent-type-memory-support.patch mm-add-device-coherent-vma-selection-for-memory-migration.patch