include/linux/highmem.h
Source file repositories/reference/linux-study-clean/include/linux/highmem.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/highmem.h- Extension
.h- Size
- 22430 bytes
- Lines
- 785
- 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/fs.hlinux/kernel.hlinux/bug.hlinux/cacheflush.hlinux/kmsan.hlinux/mm.hlinux/uaccess.hlinux/hardirq.hhighmem-internal.h
Detected Declarations
function flush_anon_pagefunction clear_user_pagesfunction clear_user_highpagefunction clear_user_highpagesfunction clear_highpagefunction clear_highpage_kasan_taggedfunction tag_clear_highpagesfunction zero_user_segmentsfunction zero_user_segmentfunction copy_user_highpagefunction copy_highpagefunction copy_mc_user_highpagefunction copy_mc_highpagefunction copy_mc_user_highpagefunction copy_mc_highpagefunction memcpy_pagefunction memcpy_foliofunction memset_pagefunction memcpy_from_pagefunction memcpy_to_pagefunction memzero_pagefunction memcpy_from_foliofunction memcpy_to_foliofunction kmap_local_foliofunction folio_fill_tailfunction memcpy_from_file_foliofunction folio_zero_segmentsfunction folio_zero_segmentfunction folio_zero_rangefunction folio_release_kmap
Annotated Snippet
while (len > max) {
memset(kaddr, 0, max);
kunmap_local(kaddr);
len -= max;
offset += max;
max = PAGE_SIZE;
kaddr = kmap_local_folio(folio, offset);
}
}
memset(kaddr, 0, len);
flush_dcache_folio(folio);
return kaddr;
}
/**
* folio_fill_tail - Copy some data to a folio and pad with zeroes.
* @folio: The destination folio.
* @offset: The offset into @folio at which to start copying.
* @from: The data to copy.
* @len: How many bytes of data to copy.
*
* This function is most useful for filesystems which support inline data.
* When they want to copy data from the inode into the page cache, this
* function does everything for them. It supports large folios even on
* HIGHMEM configurations.
*/
static inline void folio_fill_tail(struct folio *folio, size_t offset,
const char *from, size_t len)
{
char *to = kmap_local_folio(folio, offset);
VM_BUG_ON(offset + len > folio_size(folio));
if (folio_test_partial_kmap(folio)) {
size_t max = PAGE_SIZE - offset_in_page(offset);
while (len > max) {
memcpy(to, from, max);
kunmap_local(to);
len -= max;
from += max;
offset += max;
max = PAGE_SIZE;
to = kmap_local_folio(folio, offset);
}
}
memcpy(to, from, len);
to = folio_zero_tail(folio, offset + len, to + len);
kunmap_local(to);
}
/**
* memcpy_from_file_folio - Copy some bytes from a file folio.
* @to: The destination buffer.
* @folio: The folio to copy from.
* @pos: The position in the file.
* @len: The maximum number of bytes to copy.
*
* Copy up to @len bytes from this folio. This may be limited by PAGE_SIZE
* if the folio comes from HIGHMEM, and by the size of the folio.
*
* Return: The number of bytes copied from the folio.
*/
static inline size_t memcpy_from_file_folio(char *to, struct folio *folio,
loff_t pos, size_t len)
{
size_t offset = offset_in_folio(folio, pos);
char *from = kmap_local_folio(folio, offset);
if (folio_test_partial_kmap(folio)) {
offset = offset_in_page(offset);
len = min_t(size_t, len, PAGE_SIZE - offset);
} else
len = min(len, folio_size(folio) - offset);
memcpy(to, from, len);
kunmap_local(from);
return len;
}
/**
* folio_zero_segments() - Zero two byte ranges in a folio.
* @folio: The folio to write to.
* @start1: The first byte to zero.
* @xend1: One more than the last byte in the first range.
* @start2: The first byte to zero in the second range.
Annotation
- Immediate include surface: `linux/fs.h`, `linux/kernel.h`, `linux/bug.h`, `linux/cacheflush.h`, `linux/kmsan.h`, `linux/mm.h`, `linux/uaccess.h`, `linux/hardirq.h`.
- Detected declarations: `function flush_anon_page`, `function clear_user_pages`, `function clear_user_highpage`, `function clear_user_highpages`, `function clear_highpage`, `function clear_highpage_kasan_tagged`, `function tag_clear_highpages`, `function zero_user_segments`, `function zero_user_segment`, `function copy_user_highpage`.
- 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.