dma_buf_put(9)
π
dma_buf_put β a Kernel API Manual moment (yes, that's the 9 section, iykyk)
okay so bestie, welcome to the group chat. this page lives in the Kernel API Manual and it's literally about letting go of a buffer. one function, huge main character energy. let's get into it π
πΈ NAME πΈ
dma_buf_put β decreases refcount of the buffer
like, it's the "okay bye ily but I'm leaving" of reference counting. no cap.
β¨ SYNOPSIS β¨
void dma_buf_put (struct dma_buf *dmabuf );
that's it. that's the whole signature. she's simple, she's iconic, she returns nothing (void) and she's not sorry about it. π
π«Ά ARGUMENTS π«Ά
dmabufβ[in]the buffer to reduce refcount of. that's your little guy. you're lowering his refcount. be gentle. π¦
π DESCRIPTION π
so here's the tea: this function uses the file's refcounting, and that refcounting is done implicitly by fput. no extra work from you, it just vibes through the file layer. β¨
now the dramatic part β if, as a result of this call, the refcount becomes 0, then the 'release' file operation related to this fd gets called. and that in turn calls the dma_buf_ops.release vfunc, and frees the memory allocated for dmabuf when it was exported. so it's giving final rose ceremony. when the count hits zero, the memory gets its goodbye moment. ππ
ngl this is the important bit: the cleanup doesn't happen at some random time. it happens on this call, the one that drops the count to 0. so like, mind your refcounts bestie. π
π₯ SEE ALSO π₯
- Kernel file
./drivers/dma-buf/dma-buf.c dma_buf_iter_begin(9)dma_buf_iter_next(9)implicit fence polling(9)dma_buf_set_name(9)dma buf device access(9)dma_buf_export(9)dma_buf_fd(9)dma_buf_fd_install(9)dma_buf_get(9)locking convention(9)dma_buf_dynamic_attach(9)dma_buf_attach(9)dma_buf_detach(9)dma_buf_pin(9)dma_buf_unpin(9)dma_buf_map_attachment(9)dma_buf_map_attachment_unlocked(9)dma_buf_unmap_attachment(9)dma_buf_unmap_attachment_unlocked(9)dma_buf_attach_revocable(9)dma_buf_invalidate_mappings(9)cpu access(9)dma_buf_begin_cpu_access(9)dma_buf_end_cpu_access(9)dma_buf_mmap(9)dma_buf_vmap(9)dma_buf_vmap_unlocked(9)dma_buf_vunmap(9)dma_buf_vunmap_unlocked(9)
that's the whole friend group. the dma_buf_get / dma_buf_put duo is literally the classic paired set β grab one, put one back. iykyk π
and that's the page bestie! π this one comes to you from ./drivers/dma-buf, dated October 2026, and the page itself is dma_buf_put(9). go forth and decrement responsibly. mwah ππ§π
π¦ 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