lib/parman.c
Source file repositories/reference/linux-study-clean/lib/parman.c
File Facts
- System
- Linux kernel
- Corpus path
lib/parman.c- Extension
.c- Size
- 10832 bytes
- Lines
- 376
- 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/kernel.hlinux/module.hlinux/slab.hlinux/export.hlinux/list.hlinux/err.hlinux/parman.h
Detected Declarations
struct parman_algostruct parmanfunction parman_enlargefunction parman_shrinkfunction parman_prio_usedfunction parman_prio_first_indexfunction parman_prio_last_indexfunction parman_lsort_new_index_findfunction __parman_prio_movefunction parman_prio_shift_downfunction parman_prio_shift_upfunction parman_prio_item_removefunction parman_lsort_item_addfunction parman_lsort_item_removefunction parman_destroyfunction parman_prio_initfunction parman_prio_finifunction parman_item_addfunction parman_item_removeexport parman_createexport parman_destroyexport parman_prio_initexport parman_prio_finiexport parman_item_addexport parman_item_remove
Annotated Snippet
struct parman_algo {
int (*item_add)(struct parman *parman, struct parman_prio *prio,
struct parman_item *item);
void (*item_remove)(struct parman *parman, struct parman_prio *prio,
struct parman_item *item);
};
struct parman {
const struct parman_ops *ops;
void *priv;
const struct parman_algo *algo;
unsigned long count;
unsigned long limit_count;
struct list_head prio_list;
};
static int parman_enlarge(struct parman *parman)
{
unsigned long new_count = parman->limit_count +
parman->ops->resize_step;
int err;
err = parman->ops->resize(parman->priv, new_count);
if (err)
return err;
parman->limit_count = new_count;
return 0;
}
static int parman_shrink(struct parman *parman)
{
unsigned long new_count = parman->limit_count -
parman->ops->resize_step;
int err;
if (new_count < parman->ops->base_count)
return 0;
err = parman->ops->resize(parman->priv, new_count);
if (err)
return err;
parman->limit_count = new_count;
return 0;
}
static bool parman_prio_used(struct parman_prio *prio)
{
return !list_empty(&prio->item_list);
}
static struct parman_item *parman_prio_first_item(struct parman_prio *prio)
{
return list_first_entry(&prio->item_list,
typeof(struct parman_item), list);
}
static unsigned long parman_prio_first_index(struct parman_prio *prio)
{
return parman_prio_first_item(prio)->index;
}
static struct parman_item *parman_prio_last_item(struct parman_prio *prio)
{
return list_last_entry(&prio->item_list,
typeof(struct parman_item), list);
}
static unsigned long parman_prio_last_index(struct parman_prio *prio)
{
return parman_prio_last_item(prio)->index;
}
static unsigned long parman_lsort_new_index_find(struct parman *parman,
struct parman_prio *prio)
{
list_for_each_entry_from_reverse(prio, &parman->prio_list, list) {
if (!parman_prio_used(prio))
continue;
return parman_prio_last_index(prio) + 1;
}
return 0;
}
static void __parman_prio_move(struct parman *parman, struct parman_prio *prio,
struct parman_item *item, unsigned long to_index,
unsigned long count)
{
parman->ops->move(parman->priv, item->index, to_index, count);
}
static void parman_prio_shift_down(struct parman *parman,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/export.h`, `linux/list.h`, `linux/err.h`, `linux/parman.h`.
- Detected declarations: `struct parman_algo`, `struct parman`, `function parman_enlarge`, `function parman_shrink`, `function parman_prio_used`, `function parman_prio_first_index`, `function parman_prio_last_index`, `function parman_lsort_new_index_find`, `function __parman_prio_move`, `function parman_prio_shift_down`.
- 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.