Gentoo Archives: gentoo-commits

From: "Samuli Suominen (ssuominen)" <ssuominen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-apps/uevt/files: uevt-2.3-support_for_more_than_one_CPU.patch
Date: Thu, 01 Nov 2012 23:17:40
Message-Id: 20121101231722.9CD3520E47@flycatcher.gentoo.org
1 ssuominen 12/11/01 23:17:22
2
3 Added: uevt-2.3-support_for_more_than_one_CPU.patch
4 Log:
5 stable new version, drop old
6
7 (Portage version: 2.2.0_alpha142/cvs/Linux x86_64, signed Manifest commit with key 4868F14D)
8
9 Revision Changes Path
10 1.1 sys-apps/uevt/files/uevt-2.3-support_for_more_than_one_CPU.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/uevt/files/uevt-2.3-support_for_more_than_one_CPU.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/uevt/files/uevt-2.3-support_for_more_than_one_CPU.patch?rev=1.1&content-type=text/plain
14
15 Index: uevt-2.3-support_for_more_than_one_CPU.patch
16 ===================================================================
17 From 69d2f45e234190fbfb37745ea05ab88547a3de96 Mon Sep 17 00:00:00 2001
18 From: Elentir <elentir@××××××××××.org>
19 Date: Wed, 29 Aug 2012 03:41:38 +0000
20 Subject: fix for processors with more than 2 cores
21
22 ---
23 diff --git a/src/helpers/uevt-cpu-helper.vala b/src/helpers/uevt-cpu-helper.vala
24 index 89df7db..81283ff 100644
25 --- a/src/helpers/uevt-cpu-helper.vala
26 +++ b/src/helpers/uevt-cpu-helper.vala
27 @@ -21,9 +21,9 @@ using Posix;
28
29 namespace UEvtCpuHelper
30 {
31 - string[] availcpulist;
32 + int cpunumber;
33
34 - private string[] uevt_cpu_helper_detect_cpu_number()
35 + private int uevt_cpu_helper_detect_cpu_number()
36 {
37 string prescpu = "";
38 GLib.File file = File.new_for_path("/sys/devices/system/cpu/present");
39 @@ -38,17 +38,17 @@ namespace UEvtCpuHelper
40
41 string[] availcpu = prescpu.split("-", 0);
42
43 - return availcpu;
44 + return int.parse(availcpu[1]);
45 }
46
47 - private string uevt_cpu_helper_get_cpu_max_freq(string cpu_num)
48 + private string uevt_cpu_helper_get_cpu_max_freq(int cpu_num)
49 {
50 string freq = "";
51
52 - if(!(cpu_num in availcpulist))
53 + if(cpu_num > cpunumber)
54 return "";
55
56 - GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%s/cpufreq/scaling_max_freq"
57 + GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq"
58 .printf(cpu_num));
59
60 try {
61 @@ -61,14 +61,14 @@ namespace UEvtCpuHelper
62 return freq;
63 }
64
65 - private string uevt_cpu_helper_get_cpu_min_freq(string cpu_num)
66 + private string uevt_cpu_helper_get_cpu_min_freq(int cpu_num)
67 {
68 string freq = "";
69
70 - if(!(cpu_num in availcpulist))
71 + if(cpu_num > cpunumber)
72 return "";
73
74 - GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%s/cpufreq/scaling_min_freq"
75 + GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq"
76 .printf(cpu_num));
77
78 try {
79 @@ -81,14 +81,14 @@ namespace UEvtCpuHelper
80 return freq;
81 }
82
83 - private string uevt_cpu_helper_get_frequency(string cpu_num)
84 + private string uevt_cpu_helper_get_frequency(int cpu_num)
85 {
86 string freq = "";
87
88 - if(!(cpu_num in availcpulist))
89 + if(cpu_num > cpunumber)
90 return "";
91
92 - GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%s/cpufreq/scaling_cur_freq"
93 + GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq"
94 .printf(cpu_num));
95
96 try {
97 @@ -101,7 +101,7 @@ namespace UEvtCpuHelper
98 return freq;
99 }
100
101 - private void uevt_cpu_helper_set_frequency(string cpu_num, string newfreq)
102 + private void uevt_cpu_helper_set_frequency(int cpu_num, string newfreq)
103 {
104 string newfreqstring = newfreq.to_string();
105
106 @@ -110,7 +110,7 @@ namespace UEvtCpuHelper
107 return;
108 }
109
110 - FILE file = FILE.open("/sys/devices/system/cpu/cpu%s/cpufreq/scaling_setspeed"
111 + FILE file = FILE.open("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed"
112 .printf(cpu_num), "w");
113 file.puts(newfreq);
114
115 @@ -119,20 +119,20 @@ namespace UEvtCpuHelper
116
117 private void uevt_cpu_helper_set_global_frequency(string newfrequency)
118 {
119 - foreach(string cpu in availcpulist)
120 + for(int cpu = 0; cpu <= cpunumber; cpu++)
121 uevt_cpu_helper_set_frequency(cpu, newfrequency);
122
123 return;
124 }
125
126 - private string[] uevt_cpu_helper_get_available_cpu_freqs(string cpu_num)
127 + private string[] uevt_cpu_helper_get_available_cpu_freqs(int cpu_num)
128 {
129 string[] freqs = {};
130
131 - if(!(cpu_num in availcpulist))
132 + if(cpu_num > cpunumber)
133 return {};
134
135 - GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%s/cpufreq/scaling_available_frequencies"
136 + GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_frequencies"
137 .printf(cpu_num));
138
139 try {
140 @@ -147,14 +147,14 @@ namespace UEvtCpuHelper
141 return freqs;
142 }
143
144 - private string[] uevt_cpu_helper_get_available_governors(string cpu_num)
145 + private string[] uevt_cpu_helper_get_available_governors(int cpu_num)
146 {
147 string[] govs = {};
148
149 - if(!(cpu_num in availcpulist))
150 + if(cpu_num > cpunumber)
151 return {};
152
153 - GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%s/cpufreq/scaling_available_governors"
154 + GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_governors"
155 .printf(cpu_num));
156
157 try {
158 @@ -169,14 +169,14 @@ namespace UEvtCpuHelper
159 return govs;
160 }
161
162 - private string uevt_cpu_helper_get_governor(string cpu_num)
163 + private string uevt_cpu_helper_get_governor(int cpu_num)
164 {
165 string gov = "";
166
167 - if(!(cpu_num in availcpulist))
168 + if(cpu_num > cpunumber)
169 return "";
170
171 - GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%s/cpufreq/scaling_governor"
172 + GLib.File file = File.new_for_path("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor"
173 .printf(cpu_num));
174
175 try {
176 @@ -189,14 +189,14 @@ namespace UEvtCpuHelper
177 return gov;
178 }
179
180 - private void uevt_cpu_helper_set_governor(string cpu_num, string newgovernor)
181 + private void uevt_cpu_helper_set_governor(int cpu_num, string newgovernor)
182 {
183 if(!(newgovernor in uevt_cpu_helper_get_available_governors(cpu_num))) {
184 Posix.stdout.printf("Unrecognized governor %s\n", newgovernor);
185 return;
186 }
187
188 - FILE file = FILE.open("/sys/devices/system/cpu/cpu%s/cpufreq/scaling_governor"
189 + FILE file = FILE.open("/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor"
190 .printf(cpu_num), "w");
191 file.puts(newgovernor);
192
193 @@ -205,7 +205,7 @@ namespace UEvtCpuHelper
194
195 private void uevt_cpu_helper_set_global_governor(string newgovernor)
196 {
197 - foreach(string cpu in availcpulist)
198 + for(int cpu = 0; cpu <= cpunumber; cpu++)
199 uevt_cpu_helper_set_governor(cpu, newgovernor);
200
201 return;
202 @@ -215,7 +215,7 @@ namespace UEvtCpuHelper
203 {
204 string minfreq;
205
206 - foreach(string cpu in availcpulist) {
207 + for(int cpu = 0; cpu <= cpunumber; cpu++) {
208 minfreq = uevt_cpu_helper_get_cpu_min_freq(cpu);
209 uevt_cpu_helper_set_frequency(cpu, minfreq);
210 }
211 @@ -227,7 +227,7 @@ namespace UEvtCpuHelper
212 {
213 string maxfreq;
214
215 - foreach(string cpu in availcpulist) {
216 + for(int cpu = 0; cpu <= cpunumber; cpu++) {
217 maxfreq = uevt_cpu_helper_get_cpu_max_freq(cpu);
218 uevt_cpu_helper_set_frequency(cpu, maxfreq);
219 }
220 @@ -242,11 +242,11 @@ namespace UEvtCpuHelper
221 return 1;
222 }
223
224 - availcpulist = uevt_cpu_helper_detect_cpu_number();
225 + cpunumber = uevt_cpu_helper_detect_cpu_number();
226
227 if(args[1] == "show-infos") {
228 - foreach(string cpu in availcpulist) {
229 - Posix.stdout.printf("CPU %s : current governor %s, current frequency %s\n",
230 + for(int cpu = 0; cpu <= cpunumber; cpu++) {
231 + Posix.stdout.printf("CPU %d : current governor %s, current frequency %s\n",
232 cpu,
233 uevt_cpu_helper_get_governor(cpu),
234 uevt_cpu_helper_get_frequency(cpu));
235 --
236 cgit v0.9.0.3