自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(238)
  • 收藏
  • 关注

原创 【数据结构】【task_group】

task_group/* task group related information */struct task_group { /* 用于进程找到其所属进程组结构 */ struct cgroup_subsys_state css;#ifdef CONFIG_FAIR_GROUP_SCHED /* schedulable entities of this group on each cpu */ /* CFS调度器的进程组变量,在 alloc_fair_sched_group() 中

2020-07-22 14:27:34 920

原创 【调度器初始化】【sched_init】

0号进程初始化调度器相关的结构体,并将0号进程调度类变换为idle_sched_class调度类Kernel_init------------》Sched_init​#ifdef CONFIG_CGROUP_SCHED/* * Default task group. * Every task in system belongs to this group at bootup. */struct task_group root_task_group;LIST_HEAD(task_g

2020-07-22 13:40:43 3011

转载 【内核调度、调度组】【bandwidth throttle】

cfs bandwidth是针对task_group的配置,一个task_group的bandwidth使用一个struct cfs_bandwidth *cfs_b数据结构来控制struct cfs_bandwidthstruct cfs_bandwidth {#ifdef CONFIG_CFS_BANDWIDTH raw_spinlock_t lock; /*cfs bandwidth的监控周期,默认值是default_cfs_period() 0.1s */ ktime_.

2020-07-22 11:03:48 854

转载 【内核调度、EAS】【cpu boost和task boost的区别和联系】

cpu boostunsigned longboosted_cpu_util(int cpu, unsigned long util){ long margin; margin = schedtune_cpu_margin(util, cpu); trace_sched_boost_cpu(cpu, util, margin); return util + margin;}task的boost=util+marginstatic inline intschedtune_

2020-07-22 10:54:38 1851

原创 【内核调度、调度组】【struct sched_group】

struct sched_groupstruct sched_group { struct sched_group *next; /* Must be a circular list */ atomic_t ref; unsigned int group_weight; struct sched_group_capacity *sgc; int asym_prefer_cpu; /* cpu of highest priority in group */ const struct sc

2020-07-21 17:08:52 402

原创 【内核调度、负载均衡】【find_energy_efficient_cpu】

get_eenv/* * get_eenv - reset the eenv struct cached for this CPU * * When the eenv is returned, it is configured to do * energy calculations for the maximum number of CPUs * the task can be placed on. The prev_cpu entry is * filled in here. Calle

2020-07-21 14:33:45 1985

原创 【内核调度】【休眠进程的唤醒】【wake_up_process】

wake_up_process一般当队列里面为空的时候,核心调度器(是否是核心调度器还需要后续去confirm)会在已经睡眠的task中通过调用wake_up_process函数将其唤醒,然后选择合适的cpu来运行/** * wake_up_process - Wake up a specific process * @p: The process to be woken up. * * Attempt to wake up the nominated process and move i

2020-07-21 13:35:12 3649

原创 【负载均衡、负载计算】【propagate_entity_load_avg】

对于组调度而言,需要传播负载的变化到整个cfs列表里面。propagate_entity_load_avg就负责传播组调度负载的变化propagate_entity_load_avg/* Update task and its cfs_rq load average */static inline int propagate_entity_load_avg(struct sched_entity *se){ struct cfs_rq *cfs_rq; //只有group下面才有cfs_r

2020-07-21 10:20:33 577 1

原创 【内核调度、负载均衡】【entity_tick】

在scheduler_tick函数中会调用task_tick函数,具体到fair class,他的入口函数为task_tick_fair/* * scheduler tick hitting a task of our scheduling class: */ /* 获取到当前进程curr所在的调度实体 */static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued){ struct

2020-07-20 16:18:53 427

原创 【内核调度、负载计算】【calc_global_load_tick】

calc_global_load_tick是计算整个系统的负载,这个函数在scheduler_tick中被周期性的调用calc_global_load_tick/* * Called from scheduler_tick() to periodically update this CPU's * active count. */void calc_global_load_tick(struct rq *this_rq){ long delta; if (time_before(j

2020-07-20 13:53:30 587

原创 【内核调度、负载计算】【WALT】【walt_update_task_ravg】

walt_update_task_ravg/* Reflect task activity on its demand and cpu's busy time statistics */void walt_update_task_ravg(struct task_struct *p, struct rq *rq, int event, u64 wallclock, u64 irqtime){ u64 old_window_start; if (walt_disabled || !

2020-07-20 11:27:50 1355 1

原创 【内核调度、负载计算】【WALT】【update_cpu_busy_time】

1、获取初始化变量 new_window = mark_start < window_start; if (new_window) {//包含多个窗口 nr_full_windows = div64_u64((window_start - mark_start), window_size); if (p->ravg.active_windows < USHRT_MAX) p->ravg.active_windows++; } /* Hand..

2020-07-20 10:46:25 1309

原创 【内核调度、hotplug进程迁移】【migrate_tasks】

在cpu_down()时,需要调用migration_call() -> migrate_tasks()把cpu上所有runnable进程迁移到其他cpu;在cpu_up()时,并不需要在函数中迁移进程,直接等待负载均衡算法的迁移。migrate_tasks需要注意的是被迁移的task的dst cpu很有可能都是不一样的。/* * Migrate all tasks from the rq, sleeping tasks will be migrated by * try_to_wa

2020-07-16 17:45:32 1075

原创 【内核调度、负载均衡】【select_task_rq_fair】

在新建一个task或者block的task被唤醒的时候,也会执行负载均衡,调用的函数是select_task_rq_fair和内核周期性调度相似(寻找最忙的cpu上的任务,然后把该任务pull过来执行。或者从最忙的cpu上将当时正在执行的任务停掉,然后放到local cpu上去执行)。只是他寻找的是最idlest的cpu来运行taskselect_task_rq_fair/* * select_task_rq_fair: Select target runqueue for the waki

2020-07-16 17:26:48 1449

原创 【内核调度、负载均衡】【scheduler_tick】

scheduler_tick系统的软中断触发会周期性的调度scheduler_tick函数/* * This function gets called by the timer code, with HZ frequency. * We call it with interrupts disabled. */void scheduler_tick(void){ int cpu = smp_processor_id(); struct rq *rq = cpu_rq(cpu); st

2020-07-16 16:03:50 850

原创 【内核调度、负载计算】【cpu_load_update_active】

之前看了entity_load和cfs_rq的负载的计算,他们的核心code都是一样的,至于具体差别后面有时间再去看,现在来看看cpu级别的负载的计算cpu_load_update_activecpu级别的负载的计算主要是涉及到一个数组/* * Called from scheduler_tick() */void cpu_load_update_active(struct rq *this_rq){ unsigned long load = weighted_cpuload(thi

2020-07-16 15:23:57 718

原创 【内核调度、负载计算】【update_load_avg】

___update_load_avg之前版本的kernel没有accumulate_sum函数,而是直接将这部分放在本函数内执行。accumulate_sum详见https://blog.csdn.net/feifei_csdn/article/details/103814876主要是对time进行衰减/* * We can represent the historical contribution to runnable average as the * coefficients o

2020-07-16 13:55:37 1163

原创 【内核调度、负载均衡】【detach_tasks】

detach_tasks在load balance中会将busiest cpu上的task detach掉,然后atach在local cpu上。返回值为detach的task的数量/* * detach_tasks() -- tries to detach up to imbalance weighted load from * busiest_rq, as part of a balancing operation(操作) within domain "sd". * * Returns

2020-07-15 16:42:56 773

原创 【内核调度、负载均衡】【load_balance】

pull taskpull task 是当前的cpu将busiest cpu上的task拉到自己身上来执行。/* * Check this_cpu to ensure it is balanced within domain. Attempt to move * tasks if there is an imbalance. */ // 找出负载最重的cpu,将busiest cpu上的部分task迁移到local cpu上。 // 返回的是迁移的task的数量static int l

2020-07-15 15:31:34 1121

原创 【内核调度、负载均衡】【find_busiest_queue】

在最繁忙的group中去寻找最繁忙的cpufind_busiest_queue/* * find_busiest_queue - find the busiest runqueue among the cpus in group. */ //冒泡排序找到group内最忙的rqstatic struct rq *find_busiest_queue(struct lb_env *env, struct sched_group *group){ struct rq *bu

2020-07-15 10:33:41 326

原创 【内核调度、负载均衡】【calculate_imbalance】

calculate_imbalance函数对于该版本的kernel在网上没有找到相同的code,所以这里只是通过他的注释来确认。calculate_imbalance/** * calculate_imbalance - Calculate the amount of imbalance present(当下的) within the * groups of a given sched_domain during load balance. * @env: load balance e

2020-07-15 09:51:52 475

原创 【内核调度、负载均衡】【find_busiest_group】

find_busiest_group/** * 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 bal

2020-07-14 11:28:58 788

原创 【内核调度】【update_blocked_averages】

update_blocked_averagesstatic void update_blocked_averages(int cpu){ struct rq *rq = cpu_rq(cpu); struct cfs_rq *cfs_rq; struct rq_flags rf; const struct sched_class *curr_class; rq_lock_irqsave(rq, &rf); update_rq_clock(rq); /* * Iterat

2020-07-14 10:10:49 940

原创 【内核调度、负载均衡】【update_group_capacity】

MC层级的group_capacity的更新这里需要区分是MC层级还是DIE。他们的区别是sd->child是否为NULL。MC层级为NULL具体可以看update_cpu_capacity这个函数void update_group_capacity(struct sched_domain *sd, int cpu){ struct sched_domain *child = sd->child; struct sched_group *group, *sdg = sd-&g

2020-07-13 16:09:18 972

原创 【内核调度、负载均衡】【update_sd_lb_stats】

get_sd_load_idx这里面涉及到了一个unsigned long cpu_load[CPU_LOAD_IDX_MAX];数组。scheduler会更具不同的load balance类型(busy,newly idle,idle)选择不同的load进行计算,主要是在update_sg_lb_stats时进行计算/** * get_sd_load_idx - Obtain the load index for a given sched domain. * @sd: The sched_

2020-07-13 15:09:22 775

原创 【内核调度、负载均衡】【update_sg_lb_stats】

target_loadtarget_load是迁移到的cpu的load,或者我们可以说是目的cpu的loadstatic inline unsigned long cfs_rq_runnable_load_avg(struct cfs_rq *cfs_rq){ return cfs_rq->runnable_load_avg;}/* Used instead of source_load when we know the type == 0 */static unsigned l

2020-07-13 14:34:03 685

原创 【内核调度、负载计算】【update_curr】

1、update_currUpdate the current task's runtime statistics./* * Update the current task's runtime statistics. */static void update_curr(struct cfs_rq *cfs_rq){ struct sched_entity *curr = cfs_rq->curr; u64 now = rq_clock_task(rq_of(cfs_rq));

2020-07-08 11:20:43 1271

原创 【数据结构】【cfs_rq】【task_struct】【sched_domain】

1、struct cfs_rq/* CFS-related fields in a runqueue */struct cfs_rq {/*该cfs_rq的load,它只计算它本层下面的se的weight之和,并不是这个se的load,也不是递归到叶子节点上的所有se weight之和(理解这点非常重要)*/ struct load_weight load;/*所有进程的累计负荷值*///h_nr_running只对于组才有效,包括底层所有cfs_rq的nr_running之和 unsig

2020-07-06 15:54:39 842

原创 内核调度【一】【set_load_weight】

基于androidq的code来看内核调度1、nice值/** Nice levels are multiplicative, with a gentle 10% change for every* nice level changed. I.e. when a CPU-bound task goes from nice 0 to* nice 1, it will get ~1...

2020-07-06 10:18:49 379 1

原创 【内核调度、负载均衡】【boosted_task_util&task_util_est】

boosted_task_util实际上包含两个部分,当前task的util加上margin值,margin就是将util的值给他扩大或者缩小一定的倍数boosted_task_utilstatic inline unsigned longboosted_task_util(struct task_struct *task){ unsigned long util = task_util_est(task);//这里我们假设walt机制是open的 long margin = schedt

2020-07-03 16:49:24 834

原创 【数据结构】【rq】【sched_entity】【util_est】

1、structutil_est/*** struct util_est - Estimation(估算) utilization of FAIR tasks* @enqueued: instantaneous(瞬时) estimated utilization of a task/cpu* @ewma: the Exponential(指数) Weighted Moving Average (EWMA)* utilization of a tas...

2020-07-03 15:06:18 2008

转载 C++ explicit关键字详解

首先, C++中的explicit关键字只能用于修饰只有一个参数的类构造函数, 它的作用是表明该构造函数是显示的, 而非隐式的, 跟它相对应的另一个关键字是implicit, 意思是隐藏的,类构造函数默认情况下即声明为implicit(隐式).那么显示声明的构造函数和隐式声明的有什么区别呢? 我们来看下面的例子:class CxString // 没有使用explicit关键字的类声明...

2019-09-27 11:41:54 316

翻译 C++标准转换运算符static_cast

虽然const_cast是用来去除变量的const限定,但是static_cast却不是用来去除变量的static引用。其实这是很容易理解的,static决定的是一个变量的作用域和生命周期,比如:在一个文件中将变量定义为static,则说明这个变量只能在本Package中使用;在方法中定义一个static变量,该变量在程序开始存在直到程序结束;类中定义一个static成员,该成员随类的...

2019-09-27 11:21:25 2614

翻译 const char * 、char const *、 char * const 三者的区别

C/C++ 中关于以下三种定义:const char *ptr;char const *ptr;char * const ptr;整理三者之间的区别与联系。一、const char *ptr;定义一个指向字符常量的指针,这里,ptr是一个指向 char* 类型的常量,所以不能用ptr来修改所指向的内容,换句话说,*ptr的值为const,不能修改。但是ptr...

2019-09-26 16:57:53 233

转载 JSON怎样添加注释

今天在写一个程序的时候发现了一个问题,在json文件中添加注释之后,程序就出现bug了于是,去搜了一下这个问题的相关解释,在这里和大家分享一下:JSON为什么不能添加注释?这位外国友人给出的解释:大神注意到有人利用注释来制定解析规则,这破坏了互操作性(Interoperability)。因此大神将其剔除。JSON有两种数据结构:名称/值对的集合:key : valu...

2019-08-16 17:22:49 28498

翻译 tf.placeholder函数说明

函数形式:tf.placeholder(dtype,shape=None,name=None)参数:dtype:数据类型。常用的是tf.float32,tf.float64等数值类型shape:数据形状。默认是None,就是一维值,也可以是多维(比如[2,3], [None, 3]表示列是3,行不定)name:名称为什么要用placeholder?...

2019-08-16 16:23:58 186

转载 tensorflow中的“tf.name_scope()”有什么用?

转自:https://www.jianshu.com/p/635d95b34e141. tf.name_scope()命名空间的实际作用(1)在某个tf.name_scope()指定的区域中定义的所有对象及各种操作,他们的“name”属性上会增加该命名区的区域名,用以区别对象属于哪个区域;(2)将不同的对象及操作放在由tf.name_scope()指定的区域中,便于在tensorboar...

2019-08-16 15:24:01 6351 1

转载 tensorflow中os.environ["TF_CPP_MIN_LOG_LEVEL"]的值的含义

闲扯一下,最近组内同事跑路或回乡的甚多,不知是经济不景气还是新官上任三把火,加之近来身体不佳更觉忧思深重,无奈房贷缠身上有60岁父母下有即将出世的孩童,倍感生活不易。本文转自:https://blog.csdn.net/qq_40549291/article/details/85274581感谢作者的知识分享~看代码时遇到os.environ['TF_CPP_MIN_LOG_LEVE...

2019-08-16 14:32:42 786

转载 too many open files(打开的文件过多)解决方法

一、产生原因too many open files(打开的文件过多)是Linux系统中常见的错误,从字面意思上看就是说程序打开的文件数过多,不过这里的files不单是文件的意思,也包括打开的通讯链接(比如socket),正在监听的端口等等,所以有时候也可以叫做句柄(handle),这个错误通常也可以叫做句柄数超出系统限制。引起的原因就是进程在某个时刻打开了超过系统限制的文件数量以及通讯链接数...

2019-08-13 14:07:30 1494

转载 【RL】【发展历史和分类】

发展历史分类现实中的很多例子是:不基于模型的且回报函数也是不知道的。但是网上给出的例子基本上都是基于模型的,当然模型中的回报函数也是给你定义出来了的,或许你要做的就是调节超参数或者网络结构,使得他更加快速的收敛而已。...

2019-07-17 15:56:33 202

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除