include/linux/leafops.h
Source file repositories/reference/linux-study-clean/include/linux/leafops.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/leafops.h- Extension
.h- Size
- 17454 bytes
- Lines
- 661
- 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/mm_types.hlinux/swapops.hlinux/swap.h
Detected Declarations
enum softleaf_typefunction softleaf_mk_nonefunction softleaf_from_ptefunction softleaf_to_ptefunction softleaf_from_pmdfunction softleaf_from_pmdfunction softleaf_is_nonefunction softleaf_typefunction softleaf_is_swapfunction softleaf_is_migration_writefunction softleaf_is_migration_readfunction softleaf_is_migration_read_exclusivefunction softleaf_is_migrationfunction softleaf_is_device_private_writefunction softleaf_is_device_privatefunction softleaf_is_device_exclusivefunction softleaf_is_hwpoisonfunction softleaf_is_markerfunction softleaf_to_markerfunction softleaf_has_pfnfunction softleaf_to_pfnfunction softleaf_migration_syncfunction softleaf_to_pagefunction softleaf_to_foliofunction softleaf_is_poison_markerfunction softleaf_is_guard_markerfunction softleaf_is_uffd_wp_markerfunction softleaf_is_migration_youngfunction softleaf_is_migration_dirtyfunction softleaf_is_migration_youngfunction softleaf_is_migration_dirtyfunction pte_is_markerfunction pte_is_uffd_wp_markerfunction pte_is_uffd_markerfunction pmd_is_device_private_entryfunction pmd_is_device_private_entryfunction pmd_is_migration_entryfunction softleaf_is_valid_pmd_entryfunction pmd_is_valid_softleaffunction pmd_to_softleaf_folio
Annotated Snippet
#ifndef _LINUX_LEAFOPS_H
#define _LINUX_LEAFOPS_H
#include <linux/mm_types.h>
#include <linux/swapops.h>
#include <linux/swap.h>
#ifdef CONFIG_MMU
/* Temporary until swp_entry_t eliminated. */
#define LEAF_TYPE_SHIFT SWP_TYPE_SHIFT
enum softleaf_type {
/* Fundamental types. */
SOFTLEAF_NONE,
SOFTLEAF_SWAP,
/* Migration types. */
SOFTLEAF_MIGRATION_READ,
SOFTLEAF_MIGRATION_READ_EXCLUSIVE,
SOFTLEAF_MIGRATION_WRITE,
/* Device types. */
SOFTLEAF_DEVICE_PRIVATE_READ,
SOFTLEAF_DEVICE_PRIVATE_WRITE,
SOFTLEAF_DEVICE_EXCLUSIVE,
/* H/W posion types. */
SOFTLEAF_HWPOISON,
/* Marker types. */
SOFTLEAF_MARKER,
};
/**
* softleaf_mk_none() - Create an empty ('none') leaf entry.
* Returns: empty leaf entry.
*/
static inline softleaf_t softleaf_mk_none(void)
{
return ((softleaf_t) { 0 });
}
/**
* softleaf_from_pte() - Obtain a leaf entry from a PTE entry.
* @pte: PTE entry.
*
* If @pte is present (therefore not a leaf entry) the function returns an empty
* leaf entry. Otherwise, it returns a leaf entry.
*
* Returns: Leaf entry.
*/
static inline softleaf_t softleaf_from_pte(pte_t pte)
{
softleaf_t arch_entry;
if (pte_present(pte) || pte_none(pte))
return softleaf_mk_none();
pte = pte_swp_clear_flags(pte);
arch_entry = __pte_to_swp_entry(pte);
/* Temporary until swp_entry_t eliminated. */
return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
}
/**
* softleaf_to_pte() - Obtain a PTE entry from a leaf entry.
* @entry: Leaf entry.
*
* This generates an architecture-specific PTE entry that can be utilised to
* encode the metadata the leaf entry encodes.
*
* Returns: Architecture-specific PTE entry encoding leaf entry.
*/
static inline pte_t softleaf_to_pte(softleaf_t entry)
{
/* Temporary until swp_entry_t eliminated. */
return swp_entry_to_pte(entry);
}
#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
/**
* softleaf_from_pmd() - Obtain a leaf entry from a PMD entry.
* @pmd: PMD entry.
*
* If @pmd is present (therefore not a leaf entry) the function returns an empty
* leaf entry. Otherwise, it returns a leaf entry.
*
* Returns: Leaf entry.
*/
static inline softleaf_t softleaf_from_pmd(pmd_t pmd)
{
softleaf_t arch_entry;
Annotation
- Immediate include surface: `linux/mm_types.h`, `linux/swapops.h`, `linux/swap.h`.
- Detected declarations: `enum softleaf_type`, `function softleaf_mk_none`, `function softleaf_from_pte`, `function softleaf_to_pte`, `function softleaf_from_pmd`, `function softleaf_from_pmd`, `function softleaf_is_none`, `function softleaf_type`, `function softleaf_is_swap`, `function softleaf_is_migration_write`.
- 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.