include/linux/memremap.h
Source file repositories/reference/linux-study-clean/include/linux/memremap.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/memremap.h- Extension
.h- Size
- 9646 bytes
- Lines
- 311
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mmzone.hlinux/range.hlinux/ioport.hlinux/percpu-refcount.h
Detected Declarations
struct resourcestruct devicestruct vmem_altmapstruct dev_pagemap_opsstruct dev_pagemapenum memory_typefunction pgmap_has_memory_failurefunction pgmap_vmemmap_nrfunction folio_is_device_privatefunction is_device_private_pagefunction folio_is_pci_p2pdmafunction folio_set_zone_device_datafunction is_pci_p2pdma_pagefunction folio_is_device_coherentfunction is_device_coherent_pagefunction folio_is_fsdaxfunction is_fsdax_pagefunction zone_device_folio_initfunction zone_device_private_split_cbfunction devm_memunmap_pagesfunction pgmap_pfn_validfunction memremap_compat_alignfunction zone_device_private_split_cb
Annotated Snippet
struct vmem_altmap {
unsigned long base_pfn;
const unsigned long end_pfn;
const unsigned long reserve;
unsigned long free;
unsigned long align;
unsigned long alloc;
};
/*
* Specialize ZONE_DEVICE memory into multiple types each has a different
* usage.
*
* MEMORY_DEVICE_PRIVATE:
* Device memory that is not directly addressable by the CPU: CPU can neither
* read nor write private memory. In this case, we do still have struct pages
* backing the device memory. Doing so simplifies the implementation, but it is
* important to remember that there are certain points at which the struct page
* must be treated as an opaque object, rather than a "normal" struct page.
*
* A more complete discussion of unaddressable memory may be found in
* include/linux/hmm.h and Documentation/mm/hmm.rst.
*
* MEMORY_DEVICE_COHERENT:
* Device memory that is cache coherent from device and CPU point of view. This
* is used on platforms that have an advanced system bus (like CAPI or CXL). A
* driver can hotplug the device memory using ZONE_DEVICE and with that memory
* type. Any page of a process can be migrated to such memory. However no one
* should be allowed to pin such memory so that it can always be evicted.
*
* MEMORY_DEVICE_FS_DAX:
* Host memory that has similar access semantics as System RAM i.e. DMA
* coherent and supports page pinning. In support of coordinating page
* pinning vs other operations MEMORY_DEVICE_FS_DAX arranges for a
* wakeup event whenever a page is unpinned and becomes idle. This
* wakeup is used to coordinate physical address space management (ex:
* fs truncate/hole punch) vs pinned pages (ex: device dma).
*
* MEMORY_DEVICE_GENERIC:
* Host memory that has similar access semantics as System RAM i.e. DMA
* coherent and supports page pinning. This is for example used by DAX devices
* that expose memory using a character device.
*
* MEMORY_DEVICE_PCI_P2PDMA:
* Device memory residing in a PCI BAR intended for use with Peer-to-Peer
* transactions.
*/
enum memory_type {
/* 0 is reserved to catch uninitialized type fields */
MEMORY_DEVICE_PRIVATE = 1,
MEMORY_DEVICE_COHERENT,
MEMORY_DEVICE_FS_DAX,
MEMORY_DEVICE_GENERIC,
MEMORY_DEVICE_PCI_P2PDMA,
};
struct dev_pagemap_ops {
/*
* Called once the folio refcount reaches 0. The reference count will be
* reset to one by the core code after the method is called to prepare
* for handing out the folio again.
*/
void (*folio_free)(struct folio *folio);
/*
* Used for private (un-addressable) device memory only. Must migrate
* the page back to a CPU accessible page.
*/
vm_fault_t (*migrate_to_ram)(struct vm_fault *vmf);
/*
* Handle the memory failure happens on a range of pfns. Notify the
* processes who are using these pfns, and try to recover the data on
* them if necessary. The mf_flags is finally passed to the recover
* function through the whole notify routine.
*
* When this is not implemented, or it returns -EOPNOTSUPP, the caller
* will fall back to a common handler called mf_generic_kill_procs().
*/
int (*memory_failure)(struct dev_pagemap *pgmap, unsigned long pfn,
unsigned long nr_pages, int mf_flags);
/*
* Used for private (un-addressable) device memory only.
* This callback is used when a folio is split into
* a smaller folio
*/
void (*folio_split)(struct folio *head, struct folio *tail);
};
Annotation
- Immediate include surface: `linux/mmzone.h`, `linux/range.h`, `linux/ioport.h`, `linux/percpu-refcount.h`.
- Detected declarations: `struct resource`, `struct device`, `struct vmem_altmap`, `struct dev_pagemap_ops`, `struct dev_pagemap`, `enum memory_type`, `function pgmap_has_memory_failure`, `function pgmap_vmemmap_nr`, `function folio_is_device_private`, `function is_device_private_page`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.