drivers/cpuidle/governors/haltpoll.c

Source file repositories/reference/linux-study-clean/drivers/cpuidle/governors/haltpoll.c

File Facts

System
Linux kernel
Corpus path
drivers/cpuidle/governors/haltpoll.c
Extension
.c
Size
3962 bytes
Lines
156
Domain
Driver Families
Bucket
drivers/cpuidle
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

if (shrink == 0) {
			val = 0;
		} else {
			val /= shrink;
			/* Reset value to 0 if shrunk below grow_start */
			if (val < guest_halt_poll_grow_start)
				val = 0;
		}

		trace_guest_halt_poll_ns_shrink(val, dev->poll_limit_ns);
		dev->poll_limit_ns = val;
	}
}

/**
 * haltpoll_reflect - update variables and update poll time
 * @dev: the CPU
 * @index: the index of actual entered state
 */
static void haltpoll_reflect(struct cpuidle_device *dev, int index)
{
	dev->last_state_idx = index;

	if (index != 0)
		adjust_poll_limit(dev, dev->last_residency_ns);
}

/**
 * haltpoll_enable_device - scans a CPU's states and does setup
 * @drv: cpuidle driver
 * @dev: the CPU
 */
static int haltpoll_enable_device(struct cpuidle_driver *drv,
				  struct cpuidle_device *dev)
{
	dev->poll_limit_ns = 0;

	return 0;
}

static struct cpuidle_governor haltpoll_governor = {
	.name =			"haltpoll",
	.rating =		9,
	.enable =		haltpoll_enable_device,
	.select =		haltpoll_select,
	.reflect =		haltpoll_reflect,
};

static int __init init_haltpoll(void)
{
	if (kvm_para_available())
		return cpuidle_register_governor(&haltpoll_governor);

	return 0;
}

postcore_initcall(init_haltpoll);

Annotation

Implementation Notes