Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Tested-by: "Sierra Guiza, Alejandro (Alex)" <alex.sierra@amd.com>

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Chaitanya Kulkarni <kch@nvidia.com>
Cc: Karol Herbst <kherbst@redhat.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

authored by

Christoph Hellwig and committed by
Matthew Wilcox (Oracle)
dc90f084 89574945

+38 -22
+1
arch/arm64/mm/mmu.c
··· 17 17 #include <linux/mman.h> 18 18 #include <linux/nodemask.h> 19 19 #include <linux/memblock.h> 20 + #include <linux/memremap.h> 20 21 #include <linux/memory.h> 21 22 #include <linux/fs.h> 22 23 #include <linux/io.h>
+1
arch/powerpc/kvm/book3s_hv_uvmem.c
··· 91 91 #include <linux/kvm_host.h> 92 92 #include <linux/ksm.h> 93 93 #include <linux/of.h> 94 + #include <linux/memremap.h> 94 95 #include <asm/ultravisor.h> 95 96 #include <asm/mman.h> 96 97 #include <asm/kvm_ppc.h>
+1
arch/powerpc/mm/book3s64/pgtable.c
··· 6 6 #include <linux/sched.h> 7 7 #include <linux/mm_types.h> 8 8 #include <linux/memblock.h> 9 + #include <linux/memremap.h> 9 10 #include <linux/debugfs.h> 10 11 #include <misc/cxl-base.h> 11 12
+1
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
··· 25 25 26 26 #include <linux/hashtable.h> 27 27 #include <linux/mmu_notifier.h> 28 + #include <linux/memremap.h> 28 29 #include <linux/mutex.h> 29 30 #include <linux/types.h> 30 31 #include <linux/atomic.h>
+1 -1
drivers/gpu/drm/drm_cache.c
··· 27 27 /* 28 28 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com> 29 29 */ 30 - 31 30 #include <linux/dma-buf-map.h> 32 31 #include <linux/export.h> 33 32 #include <linux/highmem.h> 34 33 #include <linux/cc_platform.h> 34 + #include <linux/ioport.h> 35 35 #include <xen/xen.h> 36 36 37 37 #include <drm/drm_cache.h>
+1
drivers/gpu/drm/nouveau/nouveau_dmem.c
··· 39 39 40 40 #include <linux/sched/mm.h> 41 41 #include <linux/hmm.h> 42 + #include <linux/memremap.h> 42 43 #include <linux/migrate.h> 43 44 44 45 /*
+1
drivers/gpu/drm/nouveau/nouveau_svm.c
··· 35 35 #include <linux/sched/mm.h> 36 36 #include <linux/sort.h> 37 37 #include <linux/hmm.h> 38 + #include <linux/memremap.h> 38 39 #include <linux/rmap.h> 39 40 40 41 struct nouveau_svm {
+1
drivers/infiniband/core/rw.c
··· 2 2 /* 3 3 * Copyright (c) 2016 HGST, a Western Digital Company. 4 4 */ 5 + #include <linux/memremap.h> 5 6 #include <linux/moduleparam.h> 6 7 #include <linux/slab.h> 7 8 #include <linux/pci-p2pdma.h>
+1
drivers/nvdimm/pmem.h
··· 3 3 #define __NVDIMM_PMEM_H__ 4 4 #include <linux/page-flags.h> 5 5 #include <linux/badblocks.h> 6 + #include <linux/memremap.h> 6 7 #include <linux/types.h> 7 8 #include <linux/pfn_t.h> 8 9 #include <linux/fs.h>
+1
drivers/nvme/host/pci.c
··· 15 15 #include <linux/init.h> 16 16 #include <linux/interrupt.h> 17 17 #include <linux/io.h> 18 + #include <linux/memremap.h> 18 19 #include <linux/mm.h> 19 20 #include <linux/module.h> 20 21 #include <linux/mutex.h>
+1
drivers/nvme/target/io-cmd-bdev.c
··· 6 6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 7 7 #include <linux/blkdev.h> 8 8 #include <linux/blk-integrity.h> 9 + #include <linux/memremap.h> 9 10 #include <linux/module.h> 10 11 #include "nvmet.h" 11 12
+1
fs/fuse/virtio_fs.c
··· 8 8 #include <linux/dax.h> 9 9 #include <linux/pci.h> 10 10 #include <linux/pfn_t.h> 11 + #include <linux/memremap.h> 11 12 #include <linux/module.h> 12 13 #include <linux/virtio.h> 13 14 #include <linux/virtio_fs.h>
+1
fs/proc/page.c
··· 10 10 #include <linux/proc_fs.h> 11 11 #include <linux/seq_file.h> 12 12 #include <linux/hugetlb.h> 13 + #include <linux/memremap.h> 13 14 #include <linux/memcontrol.h> 14 15 #include <linux/mmu_notifier.h> 15 16 #include <linux/page_idle.h>
+18
include/linux/memremap.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 #ifndef _LINUX_MEMREMAP_H_ 3 3 #define _LINUX_MEMREMAP_H_ 4 + 5 + #include <linux/mm.h> 4 6 #include <linux/range.h> 5 7 #include <linux/ioport.h> 6 8 #include <linux/percpu-refcount.h> ··· 129 127 static inline unsigned long pgmap_vmemmap_nr(struct dev_pagemap *pgmap) 130 128 { 131 129 return 1 << pgmap->vmemmap_shift; 130 + } 131 + 132 + static inline bool is_device_private_page(const struct page *page) 133 + { 134 + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && 135 + IS_ENABLED(CONFIG_DEVICE_PRIVATE) && 136 + is_zone_device_page(page) && 137 + page->pgmap->type == MEMORY_DEVICE_PRIVATE; 138 + } 139 + 140 + static inline bool is_pci_p2pdma_page(const struct page *page) 141 + { 142 + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && 143 + IS_ENABLED(CONFIG_PCI_P2PDMA) && 144 + is_zone_device_page(page) && 145 + page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA; 132 146 } 133 147 134 148 #ifdef CONFIG_ZONE_DEVICE
-20
include/linux/mm.h
··· 23 23 #include <linux/err.h> 24 24 #include <linux/page-flags.h> 25 25 #include <linux/page_ref.h> 26 - #include <linux/memremap.h> 27 26 #include <linux/overflow.h> 28 27 #include <linux/sizes.h> 29 28 #include <linux/sched.h> ··· 1100 1101 return false; 1101 1102 if (!is_zone_device_page(page)) 1102 1103 return false; 1103 - if (page->pgmap->type != MEMORY_DEVICE_PRIVATE && 1104 - page->pgmap->type != MEMORY_DEVICE_FS_DAX) 1105 - return false; 1106 1104 return __put_devmap_managed_page(page); 1107 1105 } 1108 1106 ··· 1109 1113 return false; 1110 1114 } 1111 1115 #endif /* CONFIG_DEV_PAGEMAP_OPS */ 1112 - 1113 - static inline bool is_device_private_page(const struct page *page) 1114 - { 1115 - return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && 1116 - IS_ENABLED(CONFIG_DEVICE_PRIVATE) && 1117 - is_zone_device_page(page) && 1118 - page->pgmap->type == MEMORY_DEVICE_PRIVATE; 1119 - } 1120 - 1121 - static inline bool is_pci_p2pdma_page(const struct page *page) 1122 - { 1123 - return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && 1124 - IS_ENABLED(CONFIG_PCI_P2PDMA) && 1125 - is_zone_device_page(page) && 1126 - page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA; 1127 - } 1128 1116 1129 1117 /* 127: arbitrary random number, small enough to assemble well */ 1130 1118 #define folio_ref_zero_or_close_to_overflow(folio) \
+1
lib/test_hmm.c
··· 12 12 #include <linux/kernel.h> 13 13 #include <linux/cdev.h> 14 14 #include <linux/device.h> 15 + #include <linux/memremap.h> 15 16 #include <linux/mutex.h> 16 17 #include <linux/rwsem.h> 17 18 #include <linux/sched.h>
+1
mm/memcontrol.c
··· 53 53 #include <linux/fs.h> 54 54 #include <linux/seq_file.h> 55 55 #include <linux/vmpressure.h> 56 + #include <linux/memremap.h> 56 57 #include <linux/mm_inline.h> 57 58 #include <linux/swap_cgroup.h> 58 59 #include <linux/cpu.h>
+5 -1
mm/memremap.c
··· 4 4 #include <linux/io.h> 5 5 #include <linux/kasan.h> 6 6 #include <linux/memory_hotplug.h> 7 - #include <linux/mm.h> 7 + #include <linux/memremap.h> 8 8 #include <linux/pfn_t.h> 9 9 #include <linux/swap.h> 10 10 #include <linux/mmzone.h> ··· 504 504 505 505 bool __put_devmap_managed_page(struct page *page) 506 506 { 507 + if (page->pgmap->type != MEMORY_DEVICE_PRIVATE && 508 + page->pgmap->type != MEMORY_DEVICE_FS_DAX) 509 + return false; 510 + 507 511 /* 508 512 * devmap page refcounts are 1-based, rather than 0-based: if 509 513 * refcount is 1, then the page is free and the refcount is