drivers/xen/balloon.c
Source file repositories/reference/linux-study-clean/drivers/xen/balloon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/xen/balloon.c- Extension
.c- Size
- 20834 bytes
- Lines
- 825
- Domain
- Driver Families
- Bucket
- drivers/xen
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/cpu.hlinux/kernel.hlinux/sched.hlinux/cred.hlinux/errno.hlinux/freezer.hlinux/kthread.hlinux/mm.hlinux/memblock.hlinux/pagemap.hlinux/highmem.hlinux/mutex.hlinux/list.hlinux/gfp.hlinux/notifier.hlinux/memory.hlinux/memory_hotplug.hlinux/percpu-defs.hlinux/slab.hlinux/sysctl.hlinux/moduleparam.hlinux/jiffies.hasm/page.hasm/tlb.hasm/xen/hypervisor.hasm/xen/hypercall.hxen/xen.hxen/interface/xen.hxen/interface/memory.hxen/balloon.hxen/features.hxen/page.h
Detected Declarations
function balloon_appendfunction update_schedulefunction release_memory_resourcefunction reserve_additional_memoryfunction add_memoryfunction xen_online_pagefunction xen_memory_notifierfunction reserve_additional_memoryfunction current_creditfunction balloon_is_inflatedfunction increase_reservationfunction decrease_reservationfunction balloon_thread_condfunction countsfunction balloon_set_new_targetfunction add_ballooned_pagesfunction xen_alloc_ballooned_pagesfunction xen_free_ballooned_pagesfunction balloon_add_regionsfunction balloon_initfunction balloon_wait_finishmodule init balloon_initexport balloon_statsexport balloon_set_new_targetexport xen_alloc_ballooned_pagesexport xen_free_ballooned_pages
Annotated Snippet
subsys_initcall(balloon_init);
static int __init balloon_wait_finish(void)
{
long credit, last_credit = 0;
unsigned long last_changed = 0;
if (!xen_domain())
return -ENODEV;
/* PV guests don't need to wait. */
if (xen_pv_domain() || !current_credit())
return 0;
pr_notice("Waiting for initial ballooning down having finished.\n");
while ((credit = current_credit()) < 0) {
if (credit != last_credit) {
last_changed = jiffies;
last_credit = credit;
}
if (balloon_state == BP_ECANCELED) {
pr_warn_once("Initial ballooning failed, %ld pages need to be freed.\n",
-credit);
if (time_is_before_eq_jiffies(last_changed + HZ * balloon_boot_timeout))
panic("Initial ballooning failed!\n");
}
schedule_timeout_interruptible(HZ / 10);
}
pr_notice("Initial ballooning down finished.\n");
return 0;
}
late_initcall_sync(balloon_wait_finish);
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/kernel.h`, `linux/sched.h`, `linux/cred.h`, `linux/errno.h`, `linux/freezer.h`, `linux/kthread.h`, `linux/mm.h`.
- Detected declarations: `function balloon_append`, `function update_schedule`, `function release_memory_resource`, `function reserve_additional_memory`, `function add_memory`, `function xen_online_page`, `function xen_memory_notifier`, `function reserve_additional_memory`, `function current_credit`, `function balloon_is_inflated`.
- Atlas domain: Driver Families / drivers/xen.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.