include/linux/kernel_stat.h
Source file repositories/reference/linux-study-clean/include/linux/kernel_stat.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/kernel_stat.h- Extension
.h- Size
- 5852 bytes
- Lines
- 222
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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/smp.hlinux/threads.hlinux/percpu.hlinux/interrupt.hlinux/sched.hlinux/vtime.hasm/irq.h
Detected Declarations
struct kernel_cpustatstruct kernel_statenum cpu_usage_statfunction kstat_incr_softirqs_this_cpufunction kstat_softirqs_cpufunction kstat_cpu_softirqs_sumfunction kstat_snapshot_irqsfunction kstat_cpu_irqs_sumfunction kcpustat_dyntick_startfunction kcpustat_field_idlefunction kcpustat_field_iowaitfunction kcpustat_idle_dyntickfunction kcpustat_field_idlefunction kcpustat_field_iowaitfunction kcpustat_idle_dyntickfunction kcpustat_field_defaultfunction kcpustat_cpu_fetch_defaultfunction kcpustat_fieldfunction kcpustat_cpu_fetchfunction account_process_tick
Annotated Snippet
struct kernel_cpustat {
#ifdef CONFIG_NO_HZ_COMMON
bool idle_dyntick;
bool idle_elapse;
seqcount_t idle_sleeptime_seq;
u64 idle_entrytime;
u64 idle_stealtime[2];
#endif
u64 cpustat[NR_STATS];
};
struct kernel_stat {
unsigned long irqs_sum;
unsigned int softirqs[NR_SOFTIRQS];
};
DECLARE_PER_CPU(struct kernel_stat, kstat);
DECLARE_PER_CPU(struct kernel_cpustat, kernel_cpustat);
/* Must have preemption disabled for this to be meaningful. */
#define kstat_this_cpu this_cpu_ptr(&kstat)
#define kcpustat_this_cpu this_cpu_ptr(&kernel_cpustat)
#define kstat_cpu(cpu) per_cpu(kstat, cpu)
#define kcpustat_cpu(cpu) per_cpu(kernel_cpustat, cpu)
extern unsigned long long nr_context_switches_cpu(int cpu);
extern unsigned long long nr_context_switches(void);
extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu);
extern void kstat_incr_irq_this_cpu(unsigned int irq);
static inline void kstat_incr_softirqs_this_cpu(unsigned int irq)
{
__this_cpu_inc(kstat.softirqs[irq]);
}
static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu)
{
return kstat_cpu(cpu).softirqs[irq];
}
static inline unsigned int kstat_cpu_softirqs_sum(int cpu)
{
int i;
unsigned int sum = 0;
for (i = 0; i < NR_SOFTIRQS; i++)
sum += kstat_softirqs_cpu(i, cpu);
return sum;
}
#ifdef CONFIG_GENERIC_IRQ_STAT_SNAPSHOT
extern void kstat_snapshot_irqs(void);
extern unsigned int kstat_get_irq_since_snapshot(unsigned int irq);
#else
static inline void kstat_snapshot_irqs(void) { }
static inline unsigned int kstat_get_irq_since_snapshot(unsigned int irq) { return 0; }
#endif
/*
* Number of interrupts per specific IRQ source, since bootup
*/
extern unsigned int kstat_irqs_usr(unsigned int irq);
/*
* Number of interrupts per cpu, since bootup
*/
static inline unsigned long kstat_cpu_irqs_sum(unsigned int cpu)
{
return kstat_cpu(cpu).irqs_sum;
}
#ifdef CONFIG_NO_HZ_COMMON
#ifdef CONFIG_HAVE_VIRT_CPU_ACCOUNTING_IDLE
static inline void kcpustat_dyntick_start(u64 now) { }
static inline void kcpustat_dyntick_stop(u64 now) { }
static inline void kcpustat_irq_enter(u64 now) { }
static inline void kcpustat_irq_exit(u64 now) { }
static inline bool kcpustat_idle_dyntick(void) { return false; }
extern u64 arch_kcpustat_field_idle(int cpu);
extern u64 arch_kcpustat_field_iowait(int cpu);
static inline u64 kcpustat_field_idle(int cpu)
{
return arch_kcpustat_field_idle(cpu);
}
Annotation
- Immediate include surface: `linux/smp.h`, `linux/threads.h`, `linux/percpu.h`, `linux/interrupt.h`, `linux/sched.h`, `linux/vtime.h`, `asm/irq.h`.
- Detected declarations: `struct kernel_cpustat`, `struct kernel_stat`, `enum cpu_usage_stat`, `function kstat_incr_softirqs_this_cpu`, `function kstat_softirqs_cpu`, `function kstat_cpu_softirqs_sum`, `function kstat_snapshot_irqs`, `function kstat_cpu_irqs_sum`, `function kcpustat_dyntick_start`, `function kcpustat_field_idle`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.