source:
patches/procps-3.2.8-fix_HZ_errors-1.patch@
0a4f15b
Last change on this file since 0a4f15b was 6d1db7d, checked in by , 14 years ago | |
---|---|
|
|
File size: 2.3 KB |
-
proc/sysinfo.c
Submitted By: DJ Lucas <dj_AT_linuxfromscratch_DOT_org> Date: 2010-09-20 Initial Package Version: 3.2.8 Origin: Debian 30_sysinfo_7numbers.patch Upstream Status: Submitted Description: Fixes "unknown HZ value (##)" errors in procps utils. diff -Naurp procps-3.2.8-orig//proc/sysinfo.c procps-3.2.8//proc/sysinfo.c
old new int uptime(double *restrict uptime_secs, 124 124 unsigned long long Hertz; 125 125 126 126 static void old_Hertz_hack(void){ 127 unsigned long long user_j, nice_j, sys_j, other_j ; /* jiffies (clock ticks) */127 unsigned long long user_j, nice_j, sys_j, other_j, wait_j, hirq_j, sirq_j, stol_j; /* jiffies (clock ticks) */ 128 128 double up_1, up_2, seconds; 129 129 unsigned long long jiffies; 130 130 unsigned h; 131 131 char *restrict savelocale; 132 132 133 wait_j = hirq_j = sirq_j = stol_j = 0; 133 134 savelocale = setlocale(LC_NUMERIC, NULL); 134 135 setlocale(LC_NUMERIC, "C"); 135 136 do{ 136 137 FILE_TO_BUF(UPTIME_FILE,uptime_fd); sscanf(buf, "%lf", &up_1); 137 138 /* uptime(&up_1, NULL); */ 138 139 FILE_TO_BUF(STAT_FILE,stat_fd); 139 sscanf(buf, "cpu %Lu %Lu %Lu %Lu ", &user_j, &nice_j, &sys_j, &other_j);140 sscanf(buf, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", &user_j, &nice_j, &sys_j, &other_j, &wait_j, &hirq_j, &sirq_j, &stol_j); 140 141 FILE_TO_BUF(UPTIME_FILE,uptime_fd); sscanf(buf, "%lf", &up_2); 141 142 /* uptime(&up_2, NULL); */ 142 143 } while((long long)( (up_2-up_1)*1000.0/up_1 )); /* want under 0.1% error */ 143 144 setlocale(LC_NUMERIC, savelocale); 144 jiffies = user_j + nice_j + sys_j + other_j ;145 jiffies = user_j + nice_j + sys_j + other_j + wait_j + hirq_j + sirq_j + stol_j ; 145 146 seconds = (up_1 + up_2) / 2; 146 147 h = (unsigned)( (double)jiffies/seconds/smp_num_cpus ); 147 148 /* actual values used by 2.4 kernels: 32 64 100 128 1000 1024 1200 */ … … static void init_libproc(void){ 221 222 // _SC_NPROCESSORS_ONLN returns 1, which should work OK 222 223 smp_num_cpus = sysconf(_SC_NPROCESSORS_ONLN); 223 224 if(smp_num_cpus<1) smp_num_cpus=1; /* SPARC glibc is buggy */ 224 225 #ifdef __linux__ 225 226 if(linux_version_code > LINUX_VERSION(2, 4, 0)){ 226 227 Hertz = find_elf_note(AT_CLKTCK); 227 228 if(Hertz!=NOTE_NOT_FOUND) return; 228 229 fputs("2.4+ kernel w/o ELF notes? -- report this\n", stderr); 229 230 } 231 #endif 230 232 old_Hertz_hack(); 231 233 } 232 234
Note:
See TracBrowser
for help on using the repository browser.