QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2455|回复: 3

难倒中国linux高手的一个问题!

[复制链接]
发表于 2006-11-8 18:47:07 | 显示全部楼层 |阅读模式
/*
         * Check for affine wakeup and passive balancing possibilities.
         */
        if (this_sd) {
                int idx = this_sd->wake_idx;
                unsigned int imbalance;

                imbalance = 100 + (this_sd->imbalance_pct - 100) / 2;

                load = source_load(cpu, idx);
                this_load = target_load(this_cpu, idx);

                new_cpu = this_cpu; /* Wake to this CPU if we can */

                if (this_sd->flags & SD_WAKE_AFFINE) {
                        unsigned long tl = this_load;
                        /*
                         * If sync wakeup then subtract the (maximum possible)
                         * effect of the currently running task from the load
                         * of the current CPU:
                         */
                        if (sync)
                                tl -= SCHED_LOAD_SCALE;

                        if ((tl <= load &&
                                tl + target_load(cpu, idx) <= SCHED_LOAD_SCALE) ||
                                100*(tl + SCHED_LOAD_SCALE) <= imbalance*load) {
                                /*
                                 * This domain has SD_WAKE_AFFINE and
                                 * p is cache cold in this domain, and
                                 * there is no bad imbalance.
                                 */
                                schedstat_inc(this_sd, ttwu_move_affine);
                                goto out_set_cpu;
                        }
                }

                /*
                 * Start passive balancing when half the imbalance_pct
                 * limit is reached.
                 */
                if (this_sd->flags & SD_WAKE_BALANCE) {
                        if (imbalance*this_load <= 100*load) {
                                schedstat_inc(this_sd, ttwu_move_balance);
                                goto out_set_cpu;
                        }
                }
        }


嗨,各位DX,上面是


try_to_wake_up


的一段代码,上面的代码本身我并没有什么问题,问题出在这段代码使用的调度域平衡算法.比如


imbalance = 100 + (this_sd->imbalance_pct - 100) / 2;


这里这样做是如何考虑的.虽然代码作者有注释,但是我还是不明白它的调度原理所在.那位DX能结合这段代码给一个解释.或者告诉小弟哪里有相关资料也行,谢谢了!
发表于 2006-11-8 19:23:54 | 显示全部楼层
连你这个linux高手都被难倒了,还发到这里干什么?
回复

使用道具 举报

 楼主| 发表于 2006-11-9 00:23:36 | 显示全部楼层
得罪了,赫赫,贴子挂了好长时间得不到答案,耐何俺又禁不住这种求知的欲望,所以标题权是吸引眼球,解决问题才是关键,望各位不要介意!
说明一下,俺算不上linux菜鸟,更不是linux高手,只是跟众多linux的爱好者一样,不过希望通过努力能够成为一名linux菜鸟。
回复

使用道具 举报

 楼主| 发表于 2006-11-9 01:01:52 | 显示全部楼层
还是将问题具体些:请教dx:
100代表何意,
this_sd->imbalance_pct

作何解释?
imbalance*this_load <= 100*load
为何如此作?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-3-28 22:44 , Processed in 0.120440 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表