/[smeserver]/rpms/cpuspeed/sme10/cpuspeed-1.5-no-affected_cpus-fallback.patch
ViewVC logotype

Annotation of /rpms/cpuspeed/sme10/cpuspeed-1.5-no-affected_cpus-fallback.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Thu Mar 17 16:10:39 2016 UTC (8 years, 2 months ago) by unnilennium
Branch: MAIN
CVS Tags: cpuspeed-1_5-23_el7_sme, cpuspeed-1_5-23_el7_centos, HEAD
Initial import

1 unnilennium 1.1 --- cpuspeed-1.5/cpuspeed.cc.orig 2008-10-08 14:59:29.000000000 -0400
2     +++ cpuspeed-1.5/cpuspeed.cc 2008-10-08 19:22:33.000000000 -0400
3     @@ -159,6 +159,8 @@ unsigned last_step; // lowest speed step
4     // which CPU cores are we controlling
5     unsigned tied_cpu_cores[MAX_TIED_CORES];
6     unsigned num_tied_cores = 0;
7     +unsigned cpu = 0;
8     +bool no_affected_cpus_attr = false;
9    
10     // display an error message and exit the program
11     void
12     @@ -485,12 +487,16 @@ get_times(
13     if (nice_counts_as_idle)
14     {
15     idle_time += nice_time;
16     + } else {
17     + user_time += nice_time;
18     }
19    
20     // count IO wait time as idle time
21     if (io_counts_as_idle)
22     {
23     idle_time += wait_time;
24     + } else {
25     + user_time += wait_time;
26     }
27    
28     unsigned long total_time = user_time + system_time + idle_time;
29     @@ -711,6 +717,7 @@ unsigned num_cores = 0; // how many CPU
30     // restore initial speed on program exit
31     unsigned saved_speed = 0;
32     char saved_governor[32];
33     +pid_t * saved_pids;
34    
35     void
36     term_handler(int which)
37     @@ -721,6 +728,12 @@ term_handler(int which)
38     write_line(GOVERNOR_FILE, "%s\n", saved_governor);
39     }
40    
41     + if (cpu == 0 && no_affected_cpus_attr)
42     + {
43     + for (unsigned i = 1; i < num_cores; i++)
44     + kill(saved_pids[i], which);
45     + }
46     +
47     raise(which);
48     }
49    
50     @@ -1036,6 +1049,7 @@ main(int argc, char * argv[])
51     // iterate through all cpu cores in main process
52     for (unsigned i = 0, forked = 0; i < num_cores && !forked; i++)
53     {
54     + int n;
55     // does this core do cpufreq?
56     char cpufreq_dir[256];
57     snprintf(cpufreq_dir, sizeof cpufreq_dir, SYSFS_CPUFREQ_DIR, i);
58     @@ -1067,7 +1081,14 @@ main(int argc, char * argv[])
59     }
60     #endif
61     unsigned cores[MAX_TIED_CORES];
62     - int n = read_values(acfn, cores, MAX_TIED_CORES);
63     + if (access(acfn, F_OK) != 0)
64     + {
65     + // fall back to the old 1.2.x method of forking for each core
66     + no_affected_cpus_attr = true;
67     + n = 1;
68     + }
69     + else
70     + n = read_values(acfn, cores, MAX_TIED_CORES);
71    
72     // if we can't figure out the affected cores
73     if (n == 0)
74     @@ -1102,8 +1123,22 @@ main(int argc, char * argv[])
75     i, cores[0]
76     );
77     #endif
78     + if (no_affected_cpus_attr)
79     + break;
80     }
81     }
82     +
83     + if (no_affected_cpus_attr)
84     + {
85     + saved_pids = (pid_t *)calloc(num_cores, sizeof(pid_t));
86     +
87     + // fork() a process to handle each core
88     + for (unsigned i = 1; i < num_cores; i++)
89     + if ( !(saved_pids[i] = fork())) {
90     + cpu = i;
91     + break;
92     + }
93     + }
94     }
95    
96    

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed