VirtualBox

Changeset 10446

Show
Ignore:
Timestamp:
07/09/08 20:39:22 (5 months ago)
Author:
vboxsync
Message:

Adjusted cpu frequency logic a bit. Make more generous assumptions about cur frequency, and be more strict with max frequency.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/Runtime/r3/linux/mp-linux.cpp

    r10445 r10446  
    373373    if (kHz == -1) 
    374374    { 
    375         if (rtLinuxSysFsExists("devices/system/cpu/cpu%d/cpufreq/cpuinfo_cur_freq", (int)idCpu)) 
     375        /* The file may be just unreadable - in that case use plan B, i.e. 
     376         * /proc/cpuinfo to get the data we want. The assumption is that if 
     377         * cpuinfo_cur_freq doesn't exist then the speed won't change, and 
     378         * thus cur == max. If it does exist then cpuinfo contains the 
     379         * current frequency. */ 
     380        kHz = rtMpLinuxGetFrequency(idCpu) * 1000; 
     381    } 
     382    return (kHz + 999) / 1000; 
     383
     384 
     385 
     386RTDECL(uint32_t) RTMpGetMaxFrequency(RTCPUID idCpu) 
     387
     388    int64_t kHz = rtLinuxSysFsReadIntFile(0, "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", (int)idCpu); 
     389    if (kHz == -1) 
     390    { 
     391        /* Check if the file isn't there - if it is there, then /proc/cpuinfo 
     392         * would provide current frequency information, which is wrong. */ 
     393        if (!rtLinuxSysFsExists("devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", (int)idCpu)) 
    376394            kHz = rtMpLinuxGetFrequency(idCpu) * 1000; 
    377395        else 
     
    380398    return (kHz + 999) / 1000; 
    381399} 
    382  
    383  
    384 RTDECL(uint32_t) RTMpGetMaxFrequency(RTCPUID idCpu) 
    385 { 
    386     int64_t kHz = rtLinuxSysFsReadIntFile(0, "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", (int)idCpu); 
    387     if (kHz == -1) 
    388         kHz = rtMpLinuxGetFrequency(idCpu) * 1000; 
    389     return (kHz + 999) / 1000; 
    390 } 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy