arch/loongarch/mm/pageattr.c
Source file repositories/reference/linux-study-clean/arch/loongarch/mm/pageattr.c
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/mm/pageattr.c- Extension
.c- Size
- 5110 bytes
- Lines
- 239
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/memblock.hlinux/pagewalk.hlinux/pgtable.hasm/set_memory.hasm/tlbflush.h
Detected Declarations
struct pageattr_masksfunction set_pageattr_masksfunction pageattr_pgd_entryfunction pageattr_p4d_entryfunction pageattr_pud_entryfunction pageattr_pmd_entryfunction pageattr_pte_entryfunction pageattr_pte_holefunction __set_memoryfunction set_memory_xfunction set_memory_nxfunction set_memory_rofunction set_memory_rwfunction kernel_page_presentfunction set_direct_map_default_noflushfunction set_direct_map_invalid_noflushfunction set_direct_map_valid_noflush
Annotated Snippet
struct pageattr_masks {
pgprot_t set_mask;
pgprot_t clear_mask;
};
static unsigned long set_pageattr_masks(unsigned long val, struct mm_walk *walk)
{
unsigned long new_val = val;
struct pageattr_masks *masks = walk->private;
new_val &= ~(pgprot_val(masks->clear_mask));
new_val |= (pgprot_val(masks->set_mask));
return new_val;
}
static int pageattr_pgd_entry(pgd_t *pgd, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
pgd_t val = pgdp_get(pgd);
if (pgd_leaf(val)) {
val = __pgd(set_pageattr_masks(pgd_val(val), walk));
set_pgd(pgd, val);
}
return 0;
}
static int pageattr_p4d_entry(p4d_t *p4d, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
p4d_t val = p4dp_get(p4d);
if (p4d_leaf(val)) {
val = __p4d(set_pageattr_masks(p4d_val(val), walk));
set_p4d(p4d, val);
}
return 0;
}
static int pageattr_pud_entry(pud_t *pud, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
pud_t val = pudp_get(pud);
if (pud_leaf(val)) {
val = __pud(set_pageattr_masks(pud_val(val), walk));
set_pud(pud, val);
}
return 0;
}
static int pageattr_pmd_entry(pmd_t *pmd, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
pmd_t val = pmdp_get(pmd);
if (pmd_leaf(val)) {
val = __pmd(set_pageattr_masks(pmd_val(val), walk));
set_pmd(pmd, val);
}
return 0;
}
static int pageattr_pte_entry(pte_t *pte, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
pte_t val = ptep_get(pte);
val = __pte(set_pageattr_masks(pte_val(val), walk));
set_pte(pte, val);
return 0;
}
static int pageattr_pte_hole(unsigned long addr, unsigned long next,
int depth, struct mm_walk *walk)
{
return 0;
}
static const struct mm_walk_ops pageattr_ops = {
.pgd_entry = pageattr_pgd_entry,
.p4d_entry = pageattr_p4d_entry,
.pud_entry = pageattr_pud_entry,
.pmd_entry = pageattr_pmd_entry,
Annotation
- Immediate include surface: `linux/memblock.h`, `linux/pagewalk.h`, `linux/pgtable.h`, `asm/set_memory.h`, `asm/tlbflush.h`.
- Detected declarations: `struct pageattr_masks`, `function set_pageattr_masks`, `function pageattr_pgd_entry`, `function pageattr_p4d_entry`, `function pageattr_pud_entry`, `function pageattr_pmd_entry`, `function pageattr_pte_entry`, `function pageattr_pte_hole`, `function __set_memory`, `function set_memory_x`.
- Atlas domain: Architecture Layer / arch/loongarch.
- 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.