fs/proc/loadavg.c
Source file repositories/reference/linux-study-clean/fs/proc/loadavg.c
File Facts
- System
- Linux kernel
- Corpus path
fs/proc/loadavg.c- Extension
.c- Size
- 963 bytes
- Lines
- 38
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/init.hlinux/pid_namespace.hlinux/proc_fs.hlinux/sched.hlinux/sched/loadavg.hlinux/sched/stat.hlinux/seq_file.hlinux/seqlock.hlinux/time.hinternal.h
Detected Declarations
function loadavg_proc_showfunction proc_loadavg_initmodule init proc_loadavg_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/pid_namespace.h>
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <linux/sched/loadavg.h>
#include <linux/sched/stat.h>
#include <linux/seq_file.h>
#include <linux/seqlock.h>
#include <linux/time.h>
#include "internal.h"
static int loadavg_proc_show(struct seq_file *m, void *v)
{
unsigned long avnrun[3];
get_avenrun(avnrun, FIXED_1/200, 0);
seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %u/%d %d\n",
LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
nr_running(), nr_threads,
idr_get_cursor(&task_active_pid_ns(current)->idr) - 1);
return 0;
}
static int __init proc_loadavg_init(void)
{
struct proc_dir_entry *pde;
pde = proc_create_single("loadavg", 0, NULL, loadavg_proc_show);
pde_make_permanent(pde);
return 0;
}
fs_initcall(proc_loadavg_init);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/init.h`, `linux/pid_namespace.h`, `linux/proc_fs.h`, `linux/sched.h`, `linux/sched/loadavg.h`, `linux/sched/stat.h`, `linux/seq_file.h`.
- Detected declarations: `function loadavg_proc_show`, `function proc_loadavg_init`, `module init proc_loadavg_init`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.