<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[勿于浮沙筑高台]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/feifei_csdn</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; feifei_csdn]]></copyright><item><title><![CDATA[【数据结构】【task_group】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107512740</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107512740</guid><author>feifei_csdn</author><pubDate>Wed, 22 Jul 2020 14:27:34 +0800</pubDate><description><![CDATA[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() 中]]></description><category></category></item><item><title><![CDATA[【调度器初始化】【sched_init】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107511707</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107511707</guid><author>feifei_csdn</author><pubDate>Wed, 22 Jul 2020 13:40:43 +0800</pubDate><description><![CDATA[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]]></description><category></category></item><item><title><![CDATA[【内核调度、调度组】【bandwidth throttle】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107508133</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107508133</guid><author>feifei_csdn</author><pubDate>Wed, 22 Jul 2020 11:03:48 +0800</pubDate><description><![CDATA[cfs bandwidth是针对task_group的配置，一个task_group的bandwidth使用一个struct cfs_bandwidth *cfs_b数据结构来控制

struct cfs_bandwidth


struct cfs_bandwidth {
#ifdef CONFIG_CFS_BANDWIDTH
	raw_spinlock_t lock;
	/*cfs bandwidth的监控周期，默认值是default_cfs_period() 0.1s
    */ 
	ktime_.]]></description><category></category></item><item><title><![CDATA[【内核调度、EAS】【cpu boost和task boost的区别和联系】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107507045</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107507045</guid><author>feifei_csdn</author><pubDate>Wed, 22 Jul 2020 10:54:38 +0800</pubDate><description><![CDATA[cpu boost


unsigned long
boosted_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+margin


static inline int
schedtune_]]></description><category></category></item><item><title><![CDATA[【内核调度、调度组】【struct sched_group】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107493243</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107493243</guid><author>feifei_csdn</author><pubDate>Tue, 21 Jul 2020 17:08:52 +0800</pubDate><description><![CDATA[struct sched_group


struct 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]]></description><category></category></item><item><title><![CDATA[【内核调度、负载均衡】【find_energy_efficient_cpu】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107487991</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107487991</guid><author>feifei_csdn</author><pubDate>Tue, 21 Jul 2020 14:33:45 +0800</pubDate><description><![CDATA[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]]></description><category></category></item><item><title><![CDATA[【内核调度】【休眠进程的唤醒】【wake_up_process】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107486547</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107486547</guid><author>feifei_csdn</author><pubDate>Tue, 21 Jul 2020 13:35:12 +0800</pubDate><description><![CDATA[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]]></description><category></category></item><item><title><![CDATA[【负载均衡、负载计算】【propagate_entity_load_avg】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107482111</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107482111</guid><author>feifei_csdn</author><pubDate>Tue, 21 Jul 2020 10:20:33 +0800</pubDate><description><![CDATA[对于组调度而言，需要传播负载的变化到整个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]]></description><category></category></item><item><title><![CDATA[【内核调度、负载均衡】【entity_tick】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107465648</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107465648</guid><author>feifei_csdn</author><pubDate>Mon, 20 Jul 2020 16:18:53 +0800</pubDate><description><![CDATA[在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 ]]></description><category></category></item><item><title><![CDATA[【内核调度、负载计算】【calc_global_load_tick】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107461952</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107461952</guid><author>feifei_csdn</author><pubDate>Mon, 20 Jul 2020 13:53:30 +0800</pubDate><description><![CDATA[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]]></description><category></category></item><item><title><![CDATA[【内核调度、负载计算】【WALT】【walt_update_task_ravg】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107459819</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107459819</guid><author>feifei_csdn</author><pubDate>Mon, 20 Jul 2020 11:27:50 +0800</pubDate><description><![CDATA[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 || !]]></description><category></category></item><item><title><![CDATA[【内核调度、负载计算】【WALT】【update_cpu_busy_time】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107457728</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107457728</guid><author>feifei_csdn</author><pubDate>Mon, 20 Jul 2020 10:46:25 +0800</pubDate><description><![CDATA[1、获取初始化变量


	new_window = mark_start &lt; window_start;
	if (new_window) {//包含多个窗口
		nr_full_windows = div64_u64((window_start - mark_start),
						window_size);
		if (p-&gt;ravg.active_windows &lt; USHRT_MAX)
			p-&gt;ravg.active_windows++;
	}

	/* Hand..]]></description><category></category></item><item><title><![CDATA[【内核调度、hotplug进程迁移】【migrate_tasks】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107388490</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107388490</guid><author>feifei_csdn</author><pubDate>Thu, 16 Jul 2020 17:45:32 +0800</pubDate><description><![CDATA[在cpu_down()时，需要调用migration_call() -&gt; 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]]></description><category></category></item><item><title><![CDATA[【内核调度、负载均衡】【select_task_rq_fair】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107387769</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107387769</guid><author>feifei_csdn</author><pubDate>Thu, 16 Jul 2020 17:26:48 +0800</pubDate><description><![CDATA[在新建一个task或者block的task被唤醒的时候，也会执行负载均衡，调用的函数是select_task_rq_fair

和内核周期性调度相似（寻找最忙的cpu上的任务，然后把该任务pull过来执行。或者从最忙的cpu上将当时正在执行的任务停掉，然后放到local cpu上去执行）。只是他寻找的是最idlest的cpu来运行task

select_task_rq_fair


/*
 * select_task_rq_fair: Select target runqueue for the waki]]></description><category></category></item><item><title><![CDATA[【内核调度、负载均衡】【scheduler_tick】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107384454</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107384454</guid><author>feifei_csdn</author><pubDate>Thu, 16 Jul 2020 16:03:50 +0800</pubDate><description><![CDATA[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]]></description><category></category></item><item><title><![CDATA[【内核调度、负载计算】【cpu_load_update_active】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107382905</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107382905</guid><author>feifei_csdn</author><pubDate>Thu, 16 Jul 2020 15:23:57 +0800</pubDate><description><![CDATA[之前看了entity_load和cfs_rq的负载的计算，他们的核心code都是一样的，至于具体差别后面有时间再去看，现在来看看cpu级别的负载的计算

cpu_load_update_active

cpu级别的负载的计算主要是涉及到一个数组


/*
 * Called from scheduler_tick()
 */
void cpu_load_update_active(struct rq *this_rq)
{
	unsigned long load = weighted_cpuload(thi]]></description><category></category></item><item><title><![CDATA[【内核调度、负载计算】【update_load_avg】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107381373</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107381373</guid><author>feifei_csdn</author><pubDate>Thu, 16 Jul 2020 13:55:37 +0800</pubDate><description><![CDATA[___update_load_avg

之前版本的kernel没有accumulate_sum函数，而是直接将这部分放在本函数内执行。

accumulate_sum详见https://blog.youkuaiyun.com/feifei_csdn/article/details/103814876

主要是对time进行衰减


/*
 * We can represent the historical contribution to runnable average as the
 * coefficients o]]></description><category></category></item><item><title><![CDATA[【内核调度、负载均衡】【detach_tasks】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107364240</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107364240</guid><author>feifei_csdn</author><pubDate>Wed, 15 Jul 2020 16:42:56 +0800</pubDate><description><![CDATA[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]]></description><category></category></item><item><title><![CDATA[【内核调度、负载均衡】【load_balance】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107362031</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107362031</guid><author>feifei_csdn</author><pubDate>Wed, 15 Jul 2020 15:31:34 +0800</pubDate><description><![CDATA[pull task

pull 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]]></description><category></category></item><item><title><![CDATA[【内核调度、负载均衡】【find_busiest_queue】]]></title><link>https://blog.youkuaiyun.com/feifei_csdn/article/details/107354600</link><guid>https://blog.youkuaiyun.com/feifei_csdn/article/details/107354600</guid><author>feifei_csdn</author><pubDate>Wed, 15 Jul 2020 10:33:41 +0800</pubDate><description><![CDATA[在最繁忙的group中去寻找最繁忙的cpu

find_busiest_queue


/*
 * find_busiest_queue - find the busiest runqueue among the cpus in group.
 */
 //冒泡排序找到group内最忙的rq
static struct rq *find_busiest_queue(struct lb_env *env,
				     struct sched_group *group)
{
	struct rq *bu]]></description><category></category></item></channel></rss>