try_get_locked_pte(9)
π¦ try_get_locked_pte(9) β Kernel API Manual π¦
okay bestie, so this one is in section 9 of the kernel API manual, and it's genuinely such a vibe once you get it. it's try_get_locked_pte, and it's basically get_locked_pte()'s chill, non-blocking little sibling. let's get into it π
β¨ NAME β¨
try_get_locked_pte β literally just like get_locked_pte(), except it's atomic and it does a trylock instead of committing to the wait π«Ά
πΈ SYNOPSIS πΈ
pte_t * try_get_locked_pte (struct mm_struct *mm , unsigned long vmaddr
, spinlock_t **ptl );
π ARGUMENTS π
mmβ the mm. that's it, that's the whole description, she's mysterious like that β¨vmaddrβ the userspace virtual address whose pte we're trying to find πptlβ this gets set to the pointer to the lock that's used to lock the pte, but only in case of success. if it doesn't work out, don't count on it π
π DESCRIPTION π
so this function returns the pointer to the pte corresponding to addr in mm, super similarly to get_locked_pte. but here's where they differ, and it's kind of a big deal: unlike get_locked_pte, no attempt is made to allocate missing page tables. none. zero. not today π
so if a missing or large entry is found, the function just returns NULL. no drama, no allocation, just nope. and if the ptl lock is contended? you get -EAGAIN back, because she's not about to sit around waiting π₯
in case of success, *ptl will point to the locked pte lock for the returned pte β same behavior as get_locked_pte does, icon behavior honestly π
π CONTEXT π
you gotta hold mmap_lock or the vma lock, and it needs to be held for read or for write. non-negotiable bestie, don't skip this one π«Ά
β RETURN β
NULLif the pte cannot be reached.-EAGAINif the pte can be reached, but it just cannot be locked π- the pointer to the pte corresponding to addr in mm, if it can be reached and locked. slay π
π SEE ALSO π
kernel file ./arch/s390/mm/gmap_helpers.c, plus these absolute legends:
gmap_helper_zap_one_page(9)gmap_helper_discard(9)gmap_helper_try_set_pte_unused(9)gmap_helper_disable_cow_sharing(9)
and that's the whole page, bestie π brought to you by the fine folks over at ./arch/s390/mm, dated October 2026, from the try_get_locked_pte(9) files β go forth and trylock responsibly π¦π
π¦ 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