ptep_try_set(9)
π ptep_try_set(9) β the Kernel API Manual tea π«Ά
okay bestie, buckle up, because we're diving into ptep_try_set(9) from the Kernel API Manual and honestly? it's giving β¨atomic vibesβ¨
π NAME π
ptep_try_set β atomically set an empty kernel PTE, no cap π
πΈ SYNOPSIS πΈ
bool ptep_try_set (pte_t *ptep , pte_t new_pte );
literally that's the whole signature, slay π¦
β¨ ARGUMENTS β¨
ptepβ the page table entry, bestie. the slot we're eyeing πnew_pteβ the value we wanna install in there π
π₯ DESCRIPTION π₯
okay so here's the whole vibe: ptep_try_set atomically sets *ptep to new_pte iff *ptep is pte_none. it returns true on success β and returns false if the slot was already populated or if the arch has no implementation. it's giving "you had one shot" energy π
β οΈ this is for special kernel page tables only β never user page tables. not me being dramatic, that's just the rule π
the caller must prevent concurrent teardown of ptep and must accept that other writers may race. yes, bestie, accept it β other writers are gonna race, that's just the situation π«Ά
and listen: concurrent clearers must use ptep_get_and_clear so that racing accesses agree on the outcome. teamwork makes the dream work, fr fr π
architectures opt in by providing a cmpxchg-based override and defining ptep_try_set as an identity macro β iconic behavior, honestly π
the generic stub returns false, which is correct for callers that fall through to oops on failure. yes that's on purpose. no that's not a bug. it's correct ππ
π¦ SEE ALSO π¦
Kernel file ./include/linux/pgtable.h and also this whole squad of legends:
lazy_mmu_mode_enable(9)lazy_mmu_mode_disable(9)__task_lazy_mmu_mode_pause(9)lazy_mmu_mode_pause(9)__task_lazy_mmu_mode_resume(9)lazy_mmu_mode_resume(9)pte_batch_hint(9)set_ptes(9)clear_young_dirty_ptes(9)get_and_clear_full_ptes(9)get_and_clear_ptes(9)clear_full_ptes(9)clear_ptes(9)clear_nonpresent_ptes(9)flush_tlb_before_set(9)wrprotect_ptes(9)clear_flush_young_ptes(9)test_and_clear_young_ptes(9)modify_prot_start_ptes(9)modify_prot_commit_ptes(9)pfnmap_setup_cachemode(9)pfnmap_track(9)pfnmap_untrack(9)pfnmap_setup_cachemode_pfn(9)
that's the whole page, bestie, go forth and set those PTEs atomically π
mwah π β this little number lives in ./include/linux, dated October 2026, and that's the tea π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms