include/linux/pagemap.h
Source file repositories/reference/linux-study-clean/include/linux/pagemap.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/pagemap.h- Extension
.h- Size
- 50713 bytes
- Lines
- 1586
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/mm.hlinux/fs.hlinux/list.hlinux/highmem.hlinux/compiler.hlinux/uaccess.hlinux/gfp.hlinux/bitops.hlinux/hardirq.hlinux/hugetlb_inline.h
Detected Declarations
struct folio_batchstruct wait_page_keystruct wait_page_queuestruct readahead_controlenum mapping_flagsfunction invalidate_remote_inodefunction filemap_fdatawaitfunction filemap_write_and_waitfunction filemap_set_wb_errfunction filemap_check_wb_errfunction filemap_sample_wb_errfunction file_sample_sb_errfunction inode_drain_writesfunction mapping_emptyfunction mapping_shrinkablefunction fsyncfunction mapping_set_unevictablefunction mapping_clear_unevictablefunction mapping_unevictablefunction mapping_set_exitingfunction mapping_exitingfunction mapping_set_no_writeback_tagsfunction mapping_use_writeback_tagsfunction mapping_release_alwaysfunction mapping_set_release_alwaysfunction mapping_clear_release_alwaysfunction mapping_stable_writesfunction mapping_set_stable_writesfunction mapping_clear_stable_writesfunction mapping_set_inaccessiblefunction mapping_inaccessiblefunction mapping_set_writeback_may_deadlock_on_reclaimfunction mapping_writeback_may_deadlock_on_reclaimfunction mapping_gfp_maskfunction mapping_gfp_constraintfunction mapping_set_gfp_maskfunction orderfunction mapping_set_folio_order_rangefunction mapping_set_folio_min_orderfunction mapping_set_large_foliosfunction mapping_max_folio_orderfunction mapping_min_folio_orderfunction mapping_min_folio_nrpagesfunction mapping_min_folio_nrbytesfunction mapping_align_indexfunction mapping_large_folio_supportfunction mapping_max_folio_sizefunction filemap_nr_thps
Annotated Snippet
struct wait_page_key {
struct folio *folio;
int bit_nr;
int page_match;
};
struct wait_page_queue {
struct folio *folio;
int bit_nr;
wait_queue_entry_t wait;
};
static inline bool wake_page_match(struct wait_page_queue *wait_page,
struct wait_page_key *key)
{
if (wait_page->folio != key->folio)
return false;
key->page_match = 1;
if (wait_page->bit_nr != key->bit_nr)
return false;
return true;
}
void __folio_lock(struct folio *folio);
int __folio_lock_killable(struct folio *folio);
vm_fault_t __folio_lock_or_retry(struct folio *folio, struct vm_fault *vmf);
void unlock_page(struct page *page);
void folio_unlock(struct folio *folio);
/**
* folio_trylock() - Attempt to lock a folio.
* @folio: The folio to attempt to lock.
*
* Sometimes it is undesirable to wait for a folio to be unlocked (eg
* when the locks are being taken in the wrong order, or if making
* progress through a batch of folios is more important than processing
* them in order). Usually folio_lock() is the correct function to call.
*
* Context: Any context.
* Return: Whether the lock was successfully acquired.
*/
static inline bool folio_trylock(struct folio *folio)
{
return likely(!test_and_set_bit_lock(PG_locked, folio_flags(folio, 0)));
}
/*
* Return true if the page was successfully locked
*/
static inline bool trylock_page(struct page *page)
{
return folio_trylock(page_folio(page));
}
/**
* folio_lock() - Lock this folio.
* @folio: The folio to lock.
*
* The folio lock protects against many things, probably more than it
* should. It is primarily held while a folio is being brought uptodate,
* either from its backing file or from swap. It is also held while a
* folio is being truncated from its address_space, so holding the lock
* is sufficient to keep folio->mapping stable.
*
* The folio lock is also held while write() is modifying the page to
* provide POSIX atomicity guarantees (as long as the write does not
* cross a page boundary). Other modifications to the data in the folio
* do not hold the folio lock and can race with writes, eg DMA and stores
* to mapped pages.
*
* Context: May sleep. If you need to acquire the locks of two or
* more folios, they must be in order of ascending index, if they are
* in the same address_space. If they are in different address_spaces,
* acquire the lock of the folio which belongs to the address_space which
* has the lowest address in memory first.
*/
static inline void folio_lock(struct folio *folio)
{
might_sleep();
if (!folio_trylock(folio))
__folio_lock(folio);
}
/**
* lock_page() - Lock the folio containing this page.
* @page: The page to lock.
*
* See folio_lock() for a description of what the lock protects.
Annotation
- Immediate include surface: `linux/mm.h`, `linux/fs.h`, `linux/list.h`, `linux/highmem.h`, `linux/compiler.h`, `linux/uaccess.h`, `linux/gfp.h`, `linux/bitops.h`.
- Detected declarations: `struct folio_batch`, `struct wait_page_key`, `struct wait_page_queue`, `struct readahead_control`, `enum mapping_flags`, `function invalidate_remote_inode`, `function filemap_fdatawait`, `function filemap_write_and_wait`, `function filemap_set_wb_err`, `function filemap_check_wb_err`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.