2
* Copyright 2007, Intel Corporation
4
* This file is part of PowerTOP
6
* This program file is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
* You should have received a copy of the GNU General Public License
16
* along with this program in a file named COPYING; if not, write to the
17
* Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301 USA
22
* Arjan van de Ven <arjan@linux.intel.com>
30
#include <sys/types.h>
35
static void activate_ondemand(void)
38
struct dirent *dirent;
40
char filename[PATH_MAX];
42
system("/sbin/modprobe cpufreq_ondemand > /dev/null 2>&1");
45
dir = opendir("/sys/devices/system/cpu");
49
while ((dirent = readdir(dir))) {
50
if (dirent->d_name[0]=='.')
52
sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name);
53
file = fopen(filename, "w");
56
fprintf(file, "ondemand\n");
63
void suggest_ondemand_governor(void)
66
struct dirent *dirent;
68
char filename[PATH_MAX];
78
dir = opendir("/sys/devices/system/cpu");
82
while ((dirent = readdir(dir))) {
83
if (dirent->d_name[0]=='.')
85
sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name);
86
file = fopen(filename, "r");
89
memset(line, 0, 1024);
90
if (fgets(line, 1023,file)==NULL) {
97
/* if the governors are inconsistent, warn */
98
if (strcmp(gov, line))
105
/* if the governor is set to userspace, also warn */
106
if (strstr(gov, "userspace"))
109
/* if the governor is set to performance, also warn */
110
/* FIXME: check if this is fair on all cpus */
111
if (strstr(gov, "performance"))
116
add_suggestion(_("Suggestion: Enable the ondemand cpu speed governor for all processors via: \n"
117
" echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor \n"),
118
15, 'O', _(" O - enable Ondemand governor "), activate_ondemand);