lib/objagg.c
Source file repositories/reference/linux-study-clean/lib/objagg.c
File Facts
- System
- Linux kernel
- Corpus path
lib/objagg.c- Extension
.c- Size
- 28340 bytes
- Lines
- 1039
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/slab.hlinux/rhashtable.hlinux/idr.hlinux/list.hlinux/sort.hlinux/objagg.htrace/events/objagg.h
Detected Declarations
struct objagg_hintsstruct objagg_hints_nodestruct objaggstruct objagg_objstruct objagg_tmp_nodestruct objagg_tmp_graphstruct objagg_opt_algofunction objagg_hints_lookupfunction objagg_obj_ref_incfunction objagg_obj_ref_decfunction objagg_obj_stats_incfunction objagg_obj_stats_decfunction objagg_obj_is_rootfunction objagg_obj_getfunction objagg_obj_parent_assignfunction objagg_obj_parent_lookup_assignfunction list_for_each_entryfunction objagg_obj_parent_unassignfunction objagg_obj_root_id_allocfunction objagg_obj_root_id_freefunction objagg_obj_root_createfunction objagg_obj_root_destroyfunction objagg_obj_init_with_hintsfunction objagg_obj_initfunction objagg_obj_finifunction objagg_obj_destroyfunction __objagg_obj_putfunction objagg_obj_getfunction objagg_destroyfunction objagg_stats_info_sort_cmp_funcfunction objagg_stats_putfunction objagg_hints_node_createfunction objagg_hints_flushfunction list_for_each_entry_safefunction objagg_tmp_graph_edge_indexfunction objagg_tmp_graph_edge_setfunction objagg_tmp_graph_is_edgefunction objagg_tmp_graph_node_weightfunction objagg_tmp_graph_node_max_weightfunction objagg_tmp_graph_destroyfunction objagg_opt_simple_greedy_fillup_hintsfunction objagg_hints_putfunction objagg_hints_stats_getexport objagg_obj_root_privexport objagg_obj_delta_privexport objagg_obj_rawexport objagg_obj_getexport objagg_obj_put
Annotated Snippet
struct objagg_hints {
struct rhashtable node_ht;
struct rhashtable_params ht_params;
struct list_head node_list;
unsigned int node_count;
unsigned int root_count;
unsigned int refcount;
const struct objagg_ops *ops;
};
struct objagg_hints_node {
struct rhash_head ht_node; /* member of objagg_hints->node_ht */
struct list_head list; /* member of objagg_hints->node_list */
struct objagg_hints_node *parent;
unsigned int root_id;
struct objagg_obj_stats_info stats_info;
unsigned long obj[];
};
static struct objagg_hints_node *
objagg_hints_lookup(struct objagg_hints *objagg_hints, void *obj)
{
if (!objagg_hints)
return NULL;
return rhashtable_lookup_fast(&objagg_hints->node_ht, obj,
objagg_hints->ht_params);
}
struct objagg {
const struct objagg_ops *ops;
void *priv;
struct rhashtable obj_ht;
struct rhashtable_params ht_params;
struct list_head obj_list;
unsigned int obj_count;
struct ida root_ida;
struct objagg_hints *hints;
};
struct objagg_obj {
struct rhash_head ht_node; /* member of objagg->obj_ht */
struct list_head list; /* member of objagg->obj_list */
struct objagg_obj *parent; /* if the object is nested, this
* holds pointer to parent, otherwise NULL
*/
union {
void *delta_priv; /* user delta private */
void *root_priv; /* user root private */
};
unsigned int root_id;
unsigned int refcount; /* counts number of users of this object
* including nested objects
*/
struct objagg_obj_stats stats;
unsigned long obj[];
};
static unsigned int objagg_obj_ref_inc(struct objagg_obj *objagg_obj)
{
return ++objagg_obj->refcount;
}
static unsigned int objagg_obj_ref_dec(struct objagg_obj *objagg_obj)
{
return --objagg_obj->refcount;
}
static void objagg_obj_stats_inc(struct objagg_obj *objagg_obj)
{
objagg_obj->stats.user_count++;
objagg_obj->stats.delta_user_count++;
if (objagg_obj->parent)
objagg_obj->parent->stats.delta_user_count++;
}
static void objagg_obj_stats_dec(struct objagg_obj *objagg_obj)
{
objagg_obj->stats.user_count--;
objagg_obj->stats.delta_user_count--;
if (objagg_obj->parent)
objagg_obj->parent->stats.delta_user_count--;
}
static bool objagg_obj_is_root(const struct objagg_obj *objagg_obj)
{
/* Nesting is not supported, so we can use ->parent
* to figure out if the object is root.
*/
return !objagg_obj->parent;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/rhashtable.h`, `linux/idr.h`, `linux/list.h`, `linux/sort.h`, `linux/objagg.h`, `trace/events/objagg.h`.
- Detected declarations: `struct objagg_hints`, `struct objagg_hints_node`, `struct objagg`, `struct objagg_obj`, `struct objagg_tmp_node`, `struct objagg_tmp_graph`, `struct objagg_opt_algo`, `function objagg_hints_lookup`, `function objagg_obj_ref_inc`, `function objagg_obj_ref_dec`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.