kernel/power/qos.c
Source file repositories/reference/linux-study-clean/kernel/power/qos.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/power/qos.c- Extension
.c- Size
- 20844 bytes
- Lines
- 795
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/pm_qos.hlinux/sched.hlinux/spinlock.hlinux/slab.hlinux/time.hlinux/fs.hlinux/device.hlinux/miscdevice.hlinux/string.hlinux/platform_device.hlinux/init.hlinux/kernel.hlinux/debugfs.hlinux/seq_file.hlinux/uaccess.hlinux/export.htrace/events/power.h
Detected Declarations
function pm_qos_read_valuefunction pm_qos_get_valuefunction pm_qos_set_valuefunction pm_qos_update_targetfunction pm_qos_flags_remove_reqfunction pm_qos_update_flagsfunction cpu_latency_qos_value_invalidfunction cpu_latency_qos_limitfunction cpu_latency_qos_request_activefunction cpu_latency_qos_applyfunction cpu_latency_qos_add_requestfunction cpu_latency_qos_update_requestfunction cpu_latency_qos_remove_requestfunction cpu_latency_qos_openfunction cpu_latency_qos_releasefunction cpu_latency_qos_readfunction cpu_latency_qos_writefunction cpu_wakeup_latency_qos_limitfunction cpu_wakeup_latency_qos_openfunction cpu_wakeup_latency_qos_releasefunction cpu_wakeup_latency_qos_readfunction cpu_wakeup_latency_qos_writefunction cpu_latency_qos_initfunction freq_qos_value_invalidfunction freq_constraints_initfunction freq_qos_read_valuefunction freq_qos_applyfunction freq_qos_add_requestfunction freq_qos_update_requestfunction freq_qos_remove_requestfunction freq_qos_add_notifierfunction freq_qos_remove_notifierexport cpu_latency_qos_request_activeexport cpu_latency_qos_add_requestexport cpu_latency_qos_update_requestexport cpu_latency_qos_remove_requestexport freq_qos_add_requestexport freq_qos_update_requestexport freq_qos_remove_requestexport freq_qos_add_notifierexport freq_qos_remove_notifier
Annotated Snippet
static const struct file_operations cpu_latency_qos_fops = {
.write = cpu_latency_qos_write,
.read = cpu_latency_qos_read,
.open = cpu_latency_qos_open,
.release = cpu_latency_qos_release,
.llseek = noop_llseek,
};
static struct miscdevice cpu_latency_qos_miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "cpu_dma_latency",
.fops = &cpu_latency_qos_fops,
};
#ifdef CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP
/* The CPU system wakeup latency QoS. */
static struct pm_qos_constraints cpu_wakeup_latency_constraints = {
.list = PLIST_HEAD_INIT(cpu_wakeup_latency_constraints.list),
.target_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT,
.default_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT,
.no_constraint_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT,
.type = PM_QOS_MIN,
};
/**
* cpu_wakeup_latency_qos_limit - Current CPU system wakeup latency QoS limit.
*
* Returns the current CPU system wakeup latency QoS limit that may have been
* requested by user space.
*/
s32 cpu_wakeup_latency_qos_limit(void)
{
return pm_qos_read_value(&cpu_wakeup_latency_constraints);
}
static int cpu_wakeup_latency_qos_open(struct inode *inode, struct file *filp)
{
struct pm_qos_request *req;
req = kzalloc_obj(*req);
if (!req)
return -ENOMEM;
req->qos = &cpu_wakeup_latency_constraints;
pm_qos_update_target(req->qos, &req->node, PM_QOS_ADD_REQ,
PM_QOS_RESUME_LATENCY_NO_CONSTRAINT);
filp->private_data = req;
return 0;
}
static int cpu_wakeup_latency_qos_release(struct inode *inode,
struct file *filp)
{
struct pm_qos_request *req = filp->private_data;
filp->private_data = NULL;
pm_qos_update_target(req->qos, &req->node, PM_QOS_REMOVE_REQ,
PM_QOS_RESUME_LATENCY_NO_CONSTRAINT);
kfree(req);
return 0;
}
static ssize_t cpu_wakeup_latency_qos_read(struct file *filp, char __user *buf,
size_t count, loff_t *f_pos)
{
s32 value = pm_qos_read_value(&cpu_wakeup_latency_constraints);
return simple_read_from_buffer(buf, count, f_pos, &value, sizeof(s32));
}
static ssize_t cpu_wakeup_latency_qos_write(struct file *filp,
const char __user *buf,
size_t count, loff_t *f_pos)
{
struct pm_qos_request *req = filp->private_data;
s32 value;
if (count == sizeof(s32)) {
if (copy_from_user(&value, buf, sizeof(s32)))
return -EFAULT;
} else {
int ret;
ret = kstrtos32_from_user(buf, count, 16, &value);
if (ret)
return ret;
}
Annotation
- Immediate include surface: `linux/pm_qos.h`, `linux/sched.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/time.h`, `linux/fs.h`, `linux/device.h`, `linux/miscdevice.h`.
- Detected declarations: `function pm_qos_read_value`, `function pm_qos_get_value`, `function pm_qos_set_value`, `function pm_qos_update_target`, `function pm_qos_flags_remove_req`, `function pm_qos_update_flags`, `function cpu_latency_qos_value_invalid`, `function cpu_latency_qos_limit`, `function cpu_latency_qos_request_active`, `function cpu_latency_qos_apply`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.