ttm_backup_backup_folio(9)
π ttm_backup_backup_folio β it's giving "backup a folio" β¨
okay so bestie, welcome to the Kernel API Manual page for ttm_backup_backup_folio(9) and honestly? this one is a little crunchy but we're gonna get through it together π«Ά like it's from ./drivers/gpu/drm/ttm and it's literally the function that backs up a folio. the whole name.
It returns an s64, it lives in the kernel, and it has opinions about context. let's go π
πΈ SYNOPSIS πΈ
s64 ttm_backup_backup_folio (struct file *backup , struct folio *folio ,
unsigned int order , bool writeback , pgoff_t idx , gfp_t folio_gfp ,
gfp_t alloc_gfp , pgoff_t *nr_pages_backed );
eight arguments. EIGHT. not me counting on both hands π but it's fine, they all make sense, i promise.
π ARGUMENTS π
backupβ thestruct backuppointer to use. your main character struct, fr fr.folioβ the folio to back up. the whole point of the function, no cap π¦orderβ the allocation order offolio. and okay this bit is highkey important: since TTM allocates higher-order pages without__GFP_COMP,folio_nr_pages(folio)would always return1π³ so the caller has to pass the true order explicitly. no shortcuts, bestie.writebackβ whether to perform immediate writeback of the folio's pages. lowkey it may have performance implications, so likeβ¦ be aware πidxβ a unique integer for the first page of the folio and eachstruct backup. this lets the backup implementation avoid managing its address space separately, which is iconic of it actually πfolio_gfpβ the gfp value used when the folio was allocated. currently unused. so like, it's there, it's vibing, it's doing nothing πalloc_gfpβ the gfp to be used when allocating memory.nr_pages_backedβ output π on a successful return, it's set to the number of pages actually backed up. and heads up: that number may be less than(1 << order)if an-ENOMEMwas encountered mid-folio. yes, partway through. it happens π
β¨ CONTEXT β¨
okay this is the part where you read carefully, bestie, because it's giving "consequences" π
If you're calling from reclaim context, the caller needs to assert that the shrinker gfp has __GFP_FS set β this is to avoid deadlocking on lock_page. deadlocking! we're not doing that today π₯
And if writeback is set to true and you're called from reclaim context, the caller also needs to assert that the shrinker gfp has __GFP_IO set, since without it we're not allowed to start backup IO. like, the kernel said no π
β οΈ for real though: both of those assertions are on you, the caller. skip them and you get deadlocks or illegal IO, and nobody wants that energy.
π RETURN π
- π«Ά A handle for the first backed-up page on success β and handles for subsequent pages follow sequentially, so it's a little conga line of handles.
- π
-ENOMEMif no pages could be backed up. - π Any other negative error code if a non-
ENOMEMfailure occurred β and in that case, any pages backed up so far are truncated before returning. cleanup crew said periodt.
π§ SEE ALSO π§
Kernel file ./drivers/gpu/drm/ttm/ttm_backup.c, plus the rest of the backup fam:
ttm_backup_drop(9)ttm_backup_copy_page(9)ttm_backup_fini(9)ttm_backup_bytes_avail(9)ttm_backup_shmem_create(9)
and that's the page, bestie!! π go back up those folios responsibly π
mwah π β this one's from ./drivers/gpu/drm/ttm, dated October 2026. slay, bye π
π¦ 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