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.

Dependency Surface

Detected Declarations

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

Implementation Notes