source: patches/procps-3.2.8-fix_HZ_errors-1.patch@ 2a265ef

clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 2a265ef was 6d1db7d, checked in by Joe Ciccone <jciccone@…>, 14 years ago

Added a patch to procps to fix an issue when the
screen refresh rate isn't 60Hz.

  • Property mode set to 100644
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,  
    124124unsigned long long Hertz;
    125125
    126126static 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) */
    128128  double up_1, up_2, seconds;
    129129  unsigned long long jiffies;
    130130  unsigned h;
    131131  char *restrict savelocale;
    132132
     133  wait_j = hirq_j = sirq_j = stol_j = 0;
    133134  savelocale = setlocale(LC_NUMERIC, NULL);
    134135  setlocale(LC_NUMERIC, "C");
    135136  do{
    136137    FILE_TO_BUF(UPTIME_FILE,uptime_fd);  sscanf(buf, "%lf", &up_1);
    137138    /* uptime(&up_1, NULL); */
    138139    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);
    140141    FILE_TO_BUF(UPTIME_FILE,uptime_fd);  sscanf(buf, "%lf", &up_2);
    141142    /* uptime(&up_2, NULL); */
    142143  } while((long long)( (up_2-up_1)*1000.0/up_1 )); /* want under 0.1% error */
    143144  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 ;
    145146  seconds = (up_1 + up_2) / 2;
    146147  h = (unsigned)( (double)jiffies/seconds/smp_num_cpus );
    147148  /* actual values used by 2.4 kernels: 32 64 100 128 1000 1024 1200 */
    static void init_libproc(void){  
    221222  // _SC_NPROCESSORS_ONLN returns 1, which should work OK
    222223  smp_num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
    223224  if(smp_num_cpus<1) smp_num_cpus=1; /* SPARC glibc is buggy */
    224 
     225#ifdef __linux__
    225226  if(linux_version_code > LINUX_VERSION(2, 4, 0)){
    226227    Hertz = find_elf_note(AT_CLKTCK);
    227228    if(Hertz!=NOTE_NOT_FOUND) return;
    228229    fputs("2.4+ kernel w/o ELF notes? -- report this\n", stderr);
    229230  }
     231#endif
    230232  old_Hertz_hack();
    231233}
    232234
Note: See TracBrowser for help on using the repository browser.