STRUCT BINDER_ALLOC(9)
π NAME π
struct binder_alloc β the per-binder-proc state for the binder allocator, bestie β¨ (this is from the Kernel API Manual, in case you were wondering π«Ά)
β¨ SYNOPSIS β¨
struct binder_alloc {
struct mutex mutex;
struct mm_struct *mm;
unsigned long vm_start;
struct list_head buffers;
struct rb_root free_buffers;
struct rb_root allocated_buffers;
size_t free_async_space;
struct page **pages;
struct list_lru *freelist;
size_t buffer_size;
int pid;
size_t pages_high;
bool mapped;
bool oneway_spam_detected;
};
π MEMBERS π
Okay so every single field, one by one, no skipping, we're doing this π
mutexβ the bodyguard π‘οΈ it protects thebinder_allocfields, that's literally its whole job.mmβ a copy oftask->mm, and it's invariant after open, so like, it does not change. Periodt.vm_startβ the base of the per-proc address space, the one mapped viammap.buffersβ a list of all the buffers for this proc. The whole friend group π«Άfree_buffersβ an rb tree of buffers that are available for allocation, sorted by size. Shopping the free pile, iykyk.allocated_buffersβ an rb tree of the allocated buffers, sorted by address. Already-claimed besties β¨free_async_spaceβ the VA space available for async buffers. It gets initialized atmmaptime to 1/2 the full VA space, no cap πpagesβ an array ofstruct page *.freelistβ the lru list to use for free pages, and it's invariant after init πbuffer_sizeβ the size of the address space specified viammap.pidβ the pid for the associatedbinder_proc, and it's invariant after init πpages_highβ the high watermark of the offset in pages. It's giving peak performance tracking πmappedβ whether the vm area is mapped. Important caveat: each binder instance is allowed a single mapping throughout its lifetime, so like, one (1) mapping, that's the whole vibe check.oneway_spam_detectedβtrueif oneway spam detection fired π clear that flag once the async buffer has returned to a healthy state, we don't hold grudges.
π¦ DESCRIPTION π¦
So this is the bookkeeping structure for per-proc address space management for binder buffers β literally the receipts for who's using what memory, and it ate π½οΈ
It's normally initialized during binder_init and binder_mmap calls, like two little glow-up checkpoints at birth β¨
And the address space is used for both the user-visible buffers and for struct binder_buffer objects that are used to track the user buffers. Dual-purpose icon behavior π
π SEE ALSO π
- Kernel file
./drivers/android/binder_alloc.h struct binder_buffer(9)struct binder_shrinker_mdata(9)binder_alloc_get_free_async_space(9)
That's the whole page bestie, go read the kernel source now π§ββοΈβ¨ This one came from ./drivers/android and it's dated October 2026 β mwah, take care of her πππ
π¦ 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