转载:Linux 负载均衡

/procfs 运行时文件系统

loadavg:算法与内核实现

2.2 内核基础

本文主要关注的是与计算 load 有关的几个字段,

// kernel/sched/sched.h

// This is the main, per-CPU runqueue data structure.
struct rq {
unsigned int nr_running; // running task 数量
struct cfs_rq cfs; // 完全公平调度器 CFS

unsigned long        nr_uninterruptible;// 不可中断状态的 task 数量

// 与 load 计算相关的字段
unsigned long        calc_load_update;  // 上次计算 load 的时刻
long                 calc_load_active;  // 上次计算 load 时的 nr_active (running+uninterruptible)
...

};
2.2.3 内核时间基础:HZ/tick/jiffies/uptime

posted @ 2024-03-29 15:52  skyycj  阅读(16)  评论(0)    收藏  举报