find_resource_space(9)
β¨ find_resource_space β a lil kernel API page β¨
okay so this is find_resource_space from the Kernel API Manual (section 9, kernel-space functions, iykyk) π
πΈ NAME πΈ
find_resource_space β literally just: find empty space in the resource tree π
π¦ SYNOPSIS π¦
int find_resource_space (struct resource *root , struct resource *new ,
resource_size_t size , struct resource_constraint *constraint );
bestie it returns an int, and yes the parameter is named new β I know, new is a keyword in other languages, don't come for me, it's C and it's fine π«Ά
π ARGUMENTS π
rootβ the root resource descriptor. this is the top of the tree you're searching under, the main character of the whole operation πnewβ a resource descriptor that is awaiting an empty resource space. it's the one getting placed, the one we're doing all this for π₯Ίsizeβ the minimum size of the empty space. no budget for less than this, periodt.constraintβ the range and alignment constraints that have to be met. it's giving picky, but like, necessarily π
π₯ DESCRIPTION π₯
So what it does: it finds an empty space under root in the resource tree that satisfies the range and alignment constraints. that's the whole vibe. it goes looking, it finds a hole that actually fits your requirements, and it's done β¨
no cap, that's it β the constraints are doing the heavy lifting here, and size is the floor for how big the hole has to be.
π RETURN π
0β if successful,newmembersstart,end, andflagsare altered. yes, it mutates your struct β that's the deal, bestie, it's filling in the details for you π-EBUSYβ if no empty space was found. π it looked, nothing fit, that's a wrap.
ngl, -EBUSY here doesn't mean "someone else is using it" in the usual sense β it means no empty space was found. don't get it twisted π«Ά
π SEE ALSO π
Kernel file ./kernel/resource.c β that's where the magic lives, go read it, I'm obsessed π§
and the whole resource-management friend group, fr fr:
request_resource_conflict(9)request_resource(9)release_resource(9)find_next_res(9)walk_iomem_res_desc(9)region_intersects(9)reallocate_resource(9)allocate_resource(9)lookup_resource(9)insert_resource_conflict(9)insert_resource(9)insert_resource_expand_to_fit(9)remove_resource(9)adjust_resource(9)resource_alignment(9)__request_region(9)__release_region(9)release_mem_region_adjustable(9)merge_system_ram_resource(9)devm_request_resource(9)devm_release_resource(9)devm_request_free_mem_region(9)alloc_free_mem_region(9)
that's the page, bestie π this one shipped from the ./kernel source tree, October 2026 edition β and the man page itself is find_resource_space(9), so you literally can't lose it. go find some space, slay π
π¦ 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