idr_for_each(9)
π idr_for_each(9) β Kernel API Manual, bestie β¨
πΈ NAME
idr_for_each β Iterate through all stored pointers. no cap, that's the whole vibe π
β¨ SYNOPSIS
int idr_for_each (const struct idr *idr , int (*fn)(int id, void *p, void *data) , void *data );
π ARGUMENTS
idrβ IDR handle. the main character struct, lowkey π¦fnβ Function to be called for each pointer. your callback bestie, fr fr πdataβ Data passed to callback function. it gets handed straight tofn, periodt π«Ά
π DESCRIPTION
okay so here's the tea: the callback function fn will be called for each entry in idr, passing the ID, the entry and data. cute, iconic, efficient β¨
if fn returns anything other than 0, the iteration stops and that value is returned from this function. literally that simple, bestie πββοΈ
idr_for_each can be called concurrently with idr_alloc and idr_remove if protected by RCU. Newly added entries may not be seen and deleted entries may be seen, but adding and removing entries will not cause other entries to be skipped, nor spurious ones to be seen. π this RCU caveat is important β protect it properly, iykyk π₯
π SEE ALSO
Kernel file ./lib/idr.c and the whole friend group: idr_alloc_u32(9), idr_alloc(9), idr_alloc_cyclic(9), idr_remove(9), idr_find(9), idr_get_next_ul(9), idr_get_next(9), idr_replace(9), IDA description(9), ida_alloc_range(9), ida_find_first_range(9), ida_free(9), ida_destroy(9). slay π
byeee π«Ά this iconic page lives under ./lib, dated October 2026, and it's literally idr_for_each(9) πβ¨
π¦ 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