kernel/sched/debug.c
Source file repositories/reference/linux-study-clean/kernel/sched/debug.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/sched/debug.c- Extension
.c- Size
- 36399 bytes
- Lines
- 1462
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/nmi.hlinux/log2.hsched.hfeatures.h
Detected Declarations
enum dl_paramfunction nsec_highfunction nsec_lowfunction sched_feat_showfunction sched_feat_disablefunction sched_feat_enablefunction sched_feat_disablefunction sched_feat_enablefunction sched_feat_setfunction sched_feat_writefunction sched_feat_openfunction sched_scaling_writefunction sched_scaling_showfunction sched_scaling_openfunction sched_cache_enable_writefunction sched_cache_enable_showfunction sched_cache_enable_openfunction sched_dynamic_writefunction sched_dynamic_showfunction sched_dynamic_openfunction sched_verbose_writefunction sched_debug_openfunction sched_server_write_commonfunction scoped_guardfunction sched_server_show_commonfunction sched_fair_server_runtime_writefunction sched_fair_server_runtime_showfunction sched_fair_server_runtime_openfunction sched_ext_server_runtime_writefunction sched_ext_server_runtime_showfunction sched_ext_server_runtime_openfunction sched_ext_server_period_writefunction sched_ext_server_period_showfunction sched_ext_server_period_openfunction debugfs_ext_server_initfunction for_each_possible_cpufunction sched_fair_server_period_writefunction sched_fair_server_period_showfunction sched_fair_server_period_openfunction debugfs_fair_server_initfunction for_each_possible_cpufunction sched_init_debugfunction sd_flags_showfunction for_each_set_bitfunction sd_flags_openfunction register_sdfunction update_sched_domain_debugfsfunction for_each_cpu
Annotated Snippet
static const struct file_operations sched_feat_fops = {
.open = sched_feat_open,
.write = sched_feat_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *ppos)
{
unsigned int scaling;
int ret;
ret = kstrtouint_from_user(ubuf, cnt, 10, &scaling);
if (ret)
return ret;
if (scaling >= SCHED_TUNABLESCALING_END)
return -EINVAL;
sysctl_sched_tunable_scaling = scaling;
if (sched_update_scaling())
return -EINVAL;
*ppos += cnt;
return cnt;
}
static int sched_scaling_show(struct seq_file *m, void *v)
{
seq_printf(m, "%d\n", sysctl_sched_tunable_scaling);
return 0;
}
static int sched_scaling_open(struct inode *inode, struct file *filp)
{
return single_open(filp, sched_scaling_show, NULL);
}
static const struct file_operations sched_scaling_fops = {
.open = sched_scaling_open,
.write = sched_scaling_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#ifdef CONFIG_SCHED_CACHE
static ssize_t
sched_cache_enable_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *ppos)
{
bool val;
int ret;
ret = kstrtobool_from_user(ubuf, cnt, &val);
if (ret)
return ret;
sysctl_sched_cache_user = val;
sched_cache_active_set();
*ppos += cnt;
return cnt;
}
static int sched_cache_enable_show(struct seq_file *m, void *v)
{
seq_printf(m, "%d\n", sysctl_sched_cache_user);
return 0;
}
static int sched_cache_enable_open(struct inode *inode,
struct file *filp)
{
return single_open(filp, sched_cache_enable_show, NULL);
}
static const struct file_operations sched_cache_enable_fops = {
.open = sched_cache_enable_open,
.write = sched_cache_enable_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/nmi.h`, `linux/log2.h`, `sched.h`, `features.h`.
- Detected declarations: `enum dl_param`, `function nsec_high`, `function nsec_low`, `function sched_feat_show`, `function sched_feat_disable`, `function sched_feat_enable`, `function sched_feat_disable`, `function sched_feat_enable`, `function sched_feat_set`, `function sched_feat_write`.
- 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.