【内核调度、负载均衡】【find_busiest_group】
find_busiest_group
enum group_type {
group_other = 0,
group_misfit_task,
group_imbalanced,
group_overloaded,
};
/*** find_busiest_group - Returns the busiest group within the sched_domain* if there is an imbalance(不平衡).** Also calculates the amount of weighted load which should be moved* to restore(恢复) balance.** @env: The load balancing environment.** Return: - The busiest group if imbalance exists.*/
static struct sched_group *find_busiest_group(struct lb_env *env)
{struct sg_lb_stats *local, *busiest;struct sd_lb_stats sds;init_sd_lb_stats(&sds);/** Compute the various statistics relavent for load balancing at* this level.*//* (7.3.1) 更新本层级sched_group链表中,每个sched_group的负载,并选出busiest的一个sched_group*/update_sd_lb_stats(env, &sds);/* (7.3.2) 如果EAS使能,跨cluster的任务迁移使用EAS来做 */if (energy_aware() && !sd_overutilized(env->sd) &&!env->sd->parent)goto out_balanced;local = &sds.local_stat;busiest = &sds.busiest_stat;/* ASYM feature bypasses nice load balance check */
//ASYM功能绕过了不错的负载平衡检查if (check_asym_packing(env, &sds))return sds.busiest;/* There is no busy sibling group to pull tasks from *//* (7.3.4) busiest sg上没有负载,返回空 */if (!sds.busiest || busiest->sum_nr_running == 0)goto out_balanced;/* XXX broken for overlapping NUMA groups *//* (7.3.5) sg链表里的平均负载 */sds.avg_load = (SCHED_CAPACITY_SCALE * sds.total_load)/ sds.total_capacity;/** If the busiest group is imbalanced the below checks don't* work because they assume all things are equal, which typically* isn't true due to cpus_allowed constraints and the like.*//* (7.3.6) 如果busiest sg低一级别的因为cpu affinity没有balance成功,设置了group_imbalanced标志 强制在当前级别上进行balance*/if (busiest->group_type == group_imbalanced)goto force_balance;/** When dst_cpu is idle, prevent SMP nice and/or asymmetric group* capacities from resulting in underutilization due to avg_load.*//* (7.3.7) 如果dest cpu/group很闲,busiest负载很重, 强制开展balance*/if (env->idle != CPU_NOT_IDLE && group_has_capacity(env, local) &&busiest->group_no_capacity)goto force_balance;/* Misfit tasks should be dealt with regardless of the avg load */if (busiest->group_type == group_misfit_task)goto force_balance;/** If the local group is busier than the selected busiest group* don't try and pull any tasks.*//* (7.3.8) 如果dest_cpu所在sg的负载都大于busiest sg的负载,放弃balance*/if (local->avg_load >= busiest->avg_load)goto out_balanced;/** Don't pull any tasks if this group is already above the domain* average load.*/if (local->avg_load >= sds.avg_load)goto out_balanced;if (env->idle == CPU_IDLE) {/** This cpu is idle. If the busiest group is not overloaded* and there is no imbalance between this and busiest group* wrt idle cpus, it is balanced. The imbalance becomes* significant if the diff is greater than 1 otherwise we* might end up to just move the imbalance on another group*/if ((busiest->group_type != group_overloaded) &&(local->idle_cpus <= (busiest->idle_cpus + 1)))goto out_balanced;} else {/** In the CPU_NEWLY_IDLE, CPU_NOT_IDLE cases, use* imbalance_pct to be conservative.*/if (100 * busiest->avg_load <=env->sd->imbalance_pct * local->avg_load)goto out_balanced;}force_balance:/* Looks like there is an imbalance. Compute it */env->src_grp_type = busiest->group_type;calculate_imbalance(env, &sds);//也去计算需要迁移的负载量return env->imbalance ? sds.busiest : NULL;out_balanced:env->imbalance = 0;return NULL;
}
init_sd_lb_stats(&sds)详见
https://blog.csdn.net/feifei_csdn/article/details/107160808
update_sd_lb_stats(env, &sds);详见
https://blog.csdn.net/feifei_csdn/article/details/107317450
【内核调度、负载均衡】【find_busiest_group】相关推荐
- Go 如何利用 Linux 内核的负载均衡能力?
在测试 HTTP 服务时,如果该进程我们忘记关闭,而重新尝试启动一个新的服务进程,那么将会遇到类似以下的错误信息: $ go run main.go listen tcp :8000: bind: a ...
- Go 如何利用 Linux 内核的负载均衡能力
在测试 HTTP 服务时,如果该进程我们忘记关闭,而重新尝试启动一个新的服务进程,那么将会遇到类似以下的错误信息: $ go run main.go listen tcp :8000: bind: a ...
- linux内核SMP负载均衡浅析
需求 在<linux进程调度浅析>一文中提到,在SMP(对称多处理器)环境下,每个CPU对应一个run_queue(可执行队列).如果一个进程处于TASK_RUNNING状态( ...
- 一种基于优先级轮询调度负载均衡的crossbar结构
特点:支持群组路由,端口可配置 主体rra_crossbar代码 `timescale 1ns / 1ps // // Company: nssc // Engineer: liumeng // Cr ...
- linux内核死锁检测机制 | oenhan,Linux内核CPU负载均衡机制 | OenHan
还是神奇的进程调度问题引发的,参看Linux进程组调度机制分析,组调度机制是看清楚了,发现在重启过程中,很多内核调用栈阻塞在了double_rq_lock函数上,而double_rq_lock则是lo ...
- 查看linux cpu负载均衡,关于linux内核cpu进程的负载均衡
2.6内核中进程调度模块的负载均衡行为分为"拉"和"推",推这里不考虑,关于拉均衡有一篇文章特别好,具体出处就不记得了,我当时用的百度快照,那篇文章我认为最精彩 ...
- LVS负载均衡群集(LVS-NAT搭建)
企业群集类型 集群根据所针对的目标差异,可分为3类型 负载均衡群集 高可用群集 高性能运算群集 负载均衡群集 提高应用系统的响应能力,尽可能处理更多的访问请求,减少延迟为目标,获得高并发,高负载(LB ...
- LVS负载均衡群集合集
目录 一.概述 1.群集的含义 2.问题 3.解决方法 二.分类 1.根据群集所针对的目标差异,可分为三种类型 2.负载均衡群集(Load Balance Cluster) 3.高可用群集(High ...
- LVS负载均衡群集—NAT模式实例
文章目录 前言 一.群集与分布式 1.1 群集的含义 1.2 系统性能扩展方式 1.3 群集的三种类型 1.4 LVS的负载调度算法 1.5 分布式系统 1.6 集群和分布式 1.7 负载均衡群集架构 ...
- LVS 负载均衡群集----NAT模式
目录 一.企业群集应用概述 1.1 群集的含义 1.2 问题 1.3 解决办法 1.4 系统性能扩展方式 二.企业群集分类 2.1 负载均衡群集 2.2 高可用群集 2.3 高性能运算群集 三. ...
最新文章
- Linux启动流程(二)
- [译]Mimic, 轻量级Web Service测试桩
- python中insert()函数的用法_Python list insert()用法及代码示例
- 【物联网】 Yeelink开发平台注册
- mysql授权 改表_mysql开启远程登陆(修改数据表和授权两种方法)
- Notepad++插件Base64编解码
- 小米12 mini曝光:骁龙898加持
- BZOJ 1066 蜥蜴 最大流
- 处理 TXT 文本技巧
- restlet和ajax,使用Web测试插件Restlet Client发送Get和Post请求的方法教程
- python实现bt下载器_10行 Python代码使用磁力链接批量下载种子
- MySQL Mac 终端环境变量配置
- 破解物联网落地困境-阿里云硬件接入最佳实践
- 浅析SEO搜索引擎优化
- 考研复试(控制工程专硕)及大学本科(物联网工程)知识点回顾(三)——模拟电子技术
- 如何解密Token?
- 阿里云oos对象存储 上手快速入门
- mysql参数化查询 in_mysql in 查询参数化
- 怎么压缩word文档大小?
- 力扣--阿拉伯转数字
热门文章
- swoole.so: undefined symbol: _zval_ptr_dtor
- php+后台+限制+登录次数,THINKSNS取消后台登录密码错误次数限制的办法详解
- html 淡入淡出效果,css3 transition实现淡入淡出效果 - 小俊学习网
- 何夕 - 六道众生·何夕科幻自选集(2014年1月31日)
- QGuiApplication底层鼠标处理(二)QSocketNotifier在事件循环中触发activated信号
- centos 6.5 mysql 5.5 安装,centos6.5 安装mysql-5.5
- 计算机网络实验:802.3协议分析和以太网
- python聊天机器人_用 Python 实现聊天机器人
- kinit 某个账户,提示 Clients credentials have been revoked
- python word 表格宽度_RPA手把手——python-docx 设置 word 文档中表格格式