SVN: toys/tools/cleanbuild/fixfreq
sparky
sparky at pld-linux.org
Tue Dec 8 02:08:17 CET 2009
Author: sparky
Date: Tue Dec 8 02:08:17 2009
New Revision: 11014
Added:
toys/tools/cleanbuild/fixfreq (contents, props changed)
Log:
- set cpufreq scaling governor to performance on all cores while building
something, set to ondemand otherwise
Added: toys/tools/cleanbuild/fixfreq
==============================================================================
--- (empty file)
+++ toys/tools/cleanbuild/fixfreq Tue Dec 8 02:08:17 2009
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+
+use Fcntl;
+my $fifo = "/tmp/fixfreq";
+
+system "mkfifo", $fifo;
+chmod 0600, $fifo;
+
+sysopen( READ_PIDS, $fifo, O_NONBLOCK|O_RDONLY) or die "Can't open modem: $!\n";
+
+
+END {
+ set( 0 );
+ close READ_PIDS;
+ unlink $fifo;
+}
+
+sub bye { exit; }
+
+$SIG{TERM} = \&bye;
+$SIG{INT} = \&bye;
+
+my $now_is = "";
+sub set
+{
+ my $num = shift;
+ my $set_to = $num ? "performance" : "ondemand";
+ return if $now_is eq $set_to;
+ $now_is = $set_to;
+ foreach my $gov ( glob "/sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor" ) {
+ open GOV, ">", $gov;
+ print GOV $set_to;
+ close GOV;
+ }
+}
+
+my %pids;
+
+while ( 1 ) {
+ foreach my $pid ( keys %pids ) {
+ unless ( -d "/proc/".$pid ) {
+ delete $pids{ $pid };
+ }
+ }
+ while ( my $pid = <READ_PIDS> ) {
+ chomp $pid;
+ if ( -d "/proc/$pid" ) {
+ $pids{ $pid } = 1;
+ }
+ }
+ set( keys %pids );
+ sleep 1;
+}
+
More information about the pld-cvs-commit
mailing list