kernel/power/energy_model.c
Source file repositories/reference/linux-study-clean/kernel/power/energy_model.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/power/energy_model.c- Extension
.c- Size
- 26409 bytes
- Lines
- 1049
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- 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/cpufreq.hlinux/cpumask.hlinux/debugfs.hlinux/energy_model.hlinux/sched/topology.hlinux/slab.hem_netlink.h
Detected Declarations
struct em_dbg_infofunction _is_cpu_devicefunction em_debug_create_psfunction em_debug_cpus_showfunction em_debug_flags_showfunction em_debug_id_showfunction em_debug_create_pdfunction em_debug_remove_pdfunction em_debug_initfunction em_debug_create_pdfunction em_table_freefunction em_table_allocfunction em_init_performancefunction em_compute_costsfunction em_dev_compute_costsfunction em_dev_update_perf_domainfunction em_create_perf_tablefunction active_statefunction em_create_pdfunction em_cpufreq_update_efficienciesfunction em_pd_getfunction em_cpu_getfunction em_dev_register_perf_domainfunction em_dev_register_pd_no_updatefunction for_each_cpufunction uWfunction em_dev_unregister_perf_domainfunction em_recalc_and_updatefunction em_adjust_new_capacityfunction em_adjust_cpu_capacityfunction em_check_capacity_updatefunction em_update_workfnfunction em_dev_update_chip_binningfunction em_update_performance_limitsfunction rebuild_sd_workfnfunction em_rebuild_sched_domainsfunction for_each_em_perf_domainfunction list_for_each_entryfunction list_for_each_entrymodule init em_debug_initexport em_dev_update_perf_domainexport em_pd_getexport em_cpu_getexport em_dev_register_perf_domainexport em_dev_register_pd_no_updateexport em_dev_unregister_perf_domainexport em_dev_update_chip_binningexport em_update_performance_limits
Annotated Snippet
struct em_dbg_info {
struct em_perf_domain *pd;
int ps_id;
};
#define DEFINE_EM_DBG_SHOW(name, fname) \
static int em_debug_##fname##_show(struct seq_file *s, void *unused) \
{ \
struct em_dbg_info *em_dbg = s->private; \
struct em_perf_state *table; \
unsigned long val; \
\
rcu_read_lock(); \
table = em_perf_state_from_pd(em_dbg->pd); \
val = table[em_dbg->ps_id].name; \
rcu_read_unlock(); \
\
seq_printf(s, "%lu\n", val); \
return 0; \
} \
DEFINE_SHOW_ATTRIBUTE(em_debug_##fname)
DEFINE_EM_DBG_SHOW(frequency, frequency);
DEFINE_EM_DBG_SHOW(power, power);
DEFINE_EM_DBG_SHOW(cost, cost);
DEFINE_EM_DBG_SHOW(performance, performance);
DEFINE_EM_DBG_SHOW(flags, inefficiency);
static void em_debug_create_ps(struct em_perf_domain *em_pd,
struct em_dbg_info *em_dbg, int i,
struct dentry *pd)
{
struct em_perf_state *table;
unsigned long freq;
struct dentry *d;
char name[24];
em_dbg[i].pd = em_pd;
em_dbg[i].ps_id = i;
rcu_read_lock();
table = em_perf_state_from_pd(em_pd);
freq = table[i].frequency;
rcu_read_unlock();
snprintf(name, sizeof(name), "ps:%lu", freq);
/* Create per-ps directory */
d = debugfs_create_dir(name, pd);
debugfs_create_file("frequency", 0444, d, &em_dbg[i],
&em_debug_frequency_fops);
debugfs_create_file("power", 0444, d, &em_dbg[i],
&em_debug_power_fops);
debugfs_create_file("cost", 0444, d, &em_dbg[i],
&em_debug_cost_fops);
debugfs_create_file("performance", 0444, d, &em_dbg[i],
&em_debug_performance_fops);
debugfs_create_file("inefficient", 0444, d, &em_dbg[i],
&em_debug_inefficiency_fops);
}
static int em_debug_cpus_show(struct seq_file *s, void *unused)
{
seq_printf(s, "%*pbl\n", cpumask_pr_args(to_cpumask(s->private)));
return 0;
}
DEFINE_SHOW_ATTRIBUTE(em_debug_cpus);
static int em_debug_flags_show(struct seq_file *s, void *unused)
{
struct em_perf_domain *pd = s->private;
seq_printf(s, "%#lx\n", pd->flags);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(em_debug_flags);
static int em_debug_id_show(struct seq_file *s, void *unused)
{
struct em_perf_domain *pd = s->private;
seq_printf(s, "%d\n", pd->id);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(em_debug_id);
static void em_debug_create_pd(struct device *dev)
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/cpufreq.h`, `linux/cpumask.h`, `linux/debugfs.h`, `linux/energy_model.h`, `linux/sched/topology.h`, `linux/slab.h`, `em_netlink.h`.
- Detected declarations: `struct em_dbg_info`, `function _is_cpu_device`, `function em_debug_create_ps`, `function em_debug_cpus_show`, `function em_debug_flags_show`, `function em_debug_id_show`, `function em_debug_create_pd`, `function em_debug_remove_pd`, `function em_debug_init`, `function em_debug_create_pd`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.