CPU动态调频三:interactive governor如何选频

本文详细探讨了CPU动态调频中interactive governor的工作原理,重点在于choose_freq函数如何选择合适的频率以满足目标负载。核心思想是选取最小频率以达到或低于目标负载。关键因素包括平均频率loadadjfreq和预设目标负载。通过循环比较当前频率与前一次频率,不断调整,直至二者接近并达到最优选频结果。文章还解释了freqmin和freqmax的设定以及在不同情况下如何调用cpufreq_frequency_table_target函数来寻找最接近的频点。
摘要由CSDN通过智能技术生成

choose_freq函数用来选频,使选频后的系统workload小于或等于target load.
核心思想是:选择最小的频率来满足target load.
影响选频结果的因素有两个:
1.两次统计时间内系统频率的平均频率loadadjfreq,
2.系统设定好的target load,在INIT的时候设定,tunables->target_loads = default_target_loads;

drivers/cpufreq/cpufreq_interactive.c

/*
 * If increasing frequencies never map to a lower target load then
 * choose_freq() will find the minimum frequency that does not exceed its
 * target load given the current load.
 */
static unsigned int choose_freq(struct cpufreq_interactive_cpuinfo *pcpu,
        unsigned int loadadjfreq)
{
    unsigned int freq = pcpu->policy->cur;
    unsigned int prevfreq, freqmin, freqmax;
    unsigned int tl;
    int index;

    freqmin = 0;
    freqmax = UINT_MAX;

    do {
        prevfreq = freq;
        tl = freq_to_targetload(pcpu->policy->governor_data, freq);

        /*
         * Find the lowest frequency where the computed load is less
         * than or equal to the target load.
         */

        if (cpufreq_frequency_table_target(
                pcpu->policy, pcpu->freq_table, loadadjfreq / tl,
                CPUFREQ_RELATION_L, &index))
            break;
        freq = pcpu->freq_table[index].frequency;

        if (freq > prevfreq) {
            /* The previous frequency is too low. */
            freqmin = prevfreq;

            if (freq >= freqmax) {
                /*
                 * Find the highest frequency that is less
                 * than freqmax.
                 */
                if (cpufreq_frequency_table_target(
                        pcpu-&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值