Updated with Tizen:Base source codes
[external/procps.git] / packaging / procps-3.2.7-vmstat-pgpg.patch
1 --- procps-3.2.7/proc/sysinfo.h.kzak    2006-06-25 08:41:48.000000000 +0200
2 +++ procps-3.2.7/proc/sysinfo.h 2006-08-04 11:19:09.000000000 +0200
3 @@ -57,7 +57,7 @@
4  #define BUFFSIZE (64*1024)
5  typedef unsigned long long jiff;
6  extern void getstat(jiff *restrict cuse, jiff *restrict cice, jiff *restrict csys, jiff *restrict cide, jiff *restrict ciow, jiff *restrict cxxx, jiff *restrict cyyy, jiff *restrict czzz,
7 -            unsigned long *restrict pin, unsigned long *restrict pout, unsigned long *restrict s_in, unsigned long *restrict sout,
8 +            unsigned long long *restrict pin, unsigned long long *restrict pout, unsigned long long *restrict s_in, unsigned long long *restrict sout,
9              unsigned *restrict intr, unsigned *restrict ctxt,
10              unsigned int *restrict running, unsigned int *restrict blocked,
11              unsigned int *restrict btime, unsigned int *restrict processes);
12 @@ -72,10 +72,10 @@
13  extern unsigned long vm_nr_reverse_maps;
14  extern unsigned long vm_nr_mapped;
15  extern unsigned long vm_nr_slab;
16 -extern unsigned long vm_pgpgin;
17 -extern unsigned long vm_pgpgout;
18 -extern unsigned long vm_pswpin;
19 -extern unsigned long vm_pswpout;
20 +extern unsigned long long vm_pgpgin;
21 +extern unsigned long long vm_pgpgout;
22 +extern unsigned long long vm_pswpin;
23 +extern unsigned long long vm_pswpout;
24  extern unsigned long vm_pgalloc;
25  extern unsigned long vm_pgfree;
26  extern unsigned long vm_pgactivate;
27 --- procps-3.2.7/proc/sysinfo.c.kzak    2006-06-25 08:41:48.000000000 +0200
28 +++ procps-3.2.7/proc/sysinfo.c 2006-08-04 12:04:06.000000000 +0200
29 @@ -368,7 +368,7 @@
30  /***********************************************************************/
31  
32  void getstat(jiff *restrict cuse, jiff *restrict cice, jiff *restrict csys, jiff *restrict cide, jiff *restrict ciow, jiff *restrict cxxx, jiff *restrict cyyy, jiff *restrict czzz,
33 -            unsigned long *restrict pin, unsigned long *restrict pout, unsigned long *restrict s_in, unsigned long *restrict sout,
34 +            unsigned long long *restrict pin, unsigned long long *restrict pout, unsigned long long *restrict s_in, unsigned long long *restrict sout,
35              unsigned *restrict intr, unsigned *restrict ctxt,
36              unsigned int *restrict running, unsigned int *restrict blocked,
37              unsigned int *restrict btime, unsigned int *restrict processes) {
38 @@ -396,11 +396,11 @@
39    if(b) sscanf(b,  "cpu  %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", cuse, cice, csys, cide, ciow, cxxx, cyyy, czzz);
40  
41    b = strstr(buff, "page ");
42 -  if(b) sscanf(b,  "page %lu %lu", pin, pout);
43 +  if(b) sscanf(b,  "page %llu %llu", pin, pout);
44    else need_vmstat_file = 1;
45  
46    b = strstr(buff, "swap ");
47 -  if(b) sscanf(b,  "swap %lu %lu", s_in, sout);
48 +  if(b) sscanf(b,  "swap %llu %llu", s_in, sout);
49    else need_vmstat_file = 1;
50  
51    b = strstr(buff, "intr ");
52 @@ -611,9 +611,12 @@
53  
54  typedef struct vm_table_struct {
55    const char *name;     /* VM statistic name */
56 -  unsigned long *slot;       /* slot in return struct */
57 +  void *slot;           /* slot in return struct */
58 +  int  sz;             /* size of slot value */
59  } vm_table_struct;
60  
61 +#define VM_TABENTRY(_name_)    { # _name_, &vm_ ## _name_, sizeof(vm_ ## _name_) }
62 +
63  static int compare_vm_table_structs(const void *a, const void *b){
64    return strcmp(((const vm_table_struct*)a)->name,((const vm_table_struct*)b)->name);
65  }
66 @@ -626,10 +629,10 @@
67  unsigned long vm_nr_reverse_maps;    // includes PageDirect
68  unsigned long vm_nr_mapped;          // mapped into pagetables
69  unsigned long vm_nr_slab;            // in slab
70 -unsigned long vm_pgpgin;             // kB disk reads  (same as 1st num on /proc/stat page line)
71 -unsigned long vm_pgpgout;            // kB disk writes (same as 2nd num on /proc/stat page line)
72 -unsigned long vm_pswpin;             // swap reads     (same as 1st num on /proc/stat swap line)
73 -unsigned long vm_pswpout;            // swap writes    (same as 2nd num on /proc/stat swap line)
74 +unsigned long long vm_pgpgin;        // kB disk reads  (same as 1st num on /proc/stat page line)
75 +unsigned long long vm_pgpgout;       // kB disk writes (same as 2nd num on /proc/stat page line)
76 +unsigned long long vm_pswpin;        // swap reads     (same as 1st num on /proc/stat swap line)
77 +unsigned long long vm_pswpout;       // swap writes    (same as 2nd num on /proc/stat swap line)
78  unsigned long vm_pgalloc;            // page allocations
79  unsigned long vm_pgfree;             // page freeings
80  unsigned long vm_pgactivate;         // pages moved inactive -> active
81 @@ -668,54 +671,54 @@
82  
83  void vminfo(void){
84    char namebuf[16]; /* big enough to hold any row name */
85 -  vm_table_struct findme = { namebuf, NULL};
86 +  vm_table_struct findme = { namebuf, NULL, 0};
87    vm_table_struct *found;
88    char *head;
89    char *tail;
90    static const vm_table_struct vm_table[] = {
91 -  {"allocstall",          &vm_allocstall},
92 -  {"kswapd_inodesteal",   &vm_kswapd_inodesteal},
93 -  {"kswapd_steal",        &vm_kswapd_steal},
94 -  {"nr_dirty",            &vm_nr_dirty},           // page version of meminfo Dirty
95 -  {"nr_mapped",           &vm_nr_mapped},          // page version of meminfo Mapped
96 -  {"nr_page_table_pages", &vm_nr_page_table_pages},// same as meminfo PageTables
97 -  {"nr_pagecache",        &vm_nr_pagecache},       // gone in 2.5.66+ kernels
98 -  {"nr_reverse_maps",     &vm_nr_reverse_maps},    // page version of meminfo ReverseMaps GONE
99 -  {"nr_slab",             &vm_nr_slab},            // page version of meminfo Slab
100 -  {"nr_unstable",         &vm_nr_unstable},
101 -  {"nr_writeback",        &vm_nr_writeback},       // page version of meminfo Writeback
102 -  {"pageoutrun",          &vm_pageoutrun},
103 -  {"pgactivate",          &vm_pgactivate},
104 -  {"pgalloc",             &vm_pgalloc},  // GONE (now separate dma,high,normal)
105 -  {"pgalloc_dma",         &vm_pgalloc_dma},
106 -  {"pgalloc_high",        &vm_pgalloc_high},
107 -  {"pgalloc_normal",      &vm_pgalloc_normal},
108 -  {"pgdeactivate",        &vm_pgdeactivate},
109 -  {"pgfault",             &vm_pgfault},
110 -  {"pgfree",              &vm_pgfree},
111 -  {"pginodesteal",        &vm_pginodesteal},
112 -  {"pgmajfault",          &vm_pgmajfault},
113 -  {"pgpgin",              &vm_pgpgin},     // important
114 -  {"pgpgout",             &vm_pgpgout},     // important
115 -  {"pgrefill",            &vm_pgrefill},  // GONE (now separate dma,high,normal)
116 -  {"pgrefill_dma",        &vm_pgrefill_dma},
117 -  {"pgrefill_high",       &vm_pgrefill_high},
118 -  {"pgrefill_normal",     &vm_pgrefill_normal},
119 -  {"pgrotated",           &vm_pgrotated},
120 -  {"pgscan",              &vm_pgscan},  // GONE (now separate direct,kswapd and dma,high,normal)
121 -  {"pgscan_direct_dma",   &vm_pgscan_direct_dma},
122 -  {"pgscan_direct_high",  &vm_pgscan_direct_high},
123 -  {"pgscan_direct_normal",&vm_pgscan_direct_normal},
124 -  {"pgscan_kswapd_dma",   &vm_pgscan_kswapd_dma},
125 -  {"pgscan_kswapd_high",  &vm_pgscan_kswapd_high},
126 -  {"pgscan_kswapd_normal",&vm_pgscan_kswapd_normal},
127 -  {"pgsteal",             &vm_pgsteal},  // GONE (now separate dma,high,normal)
128 -  {"pgsteal_dma",         &vm_pgsteal_dma},
129 -  {"pgsteal_high",        &vm_pgsteal_high},
130 -  {"pgsteal_normal",      &vm_pgsteal_normal},
131 -  {"pswpin",              &vm_pswpin},     // important
132 -  {"pswpout",             &vm_pswpout},     // important
133 -  {"slabs_scanned",       &vm_slabs_scanned},
134 +       VM_TABENTRY(allocstall),
135 +       VM_TABENTRY(kswapd_inodesteal),
136 +       VM_TABENTRY(kswapd_steal),
137 +       VM_TABENTRY(nr_dirty),
138 +       VM_TABENTRY(nr_mapped),
139 +       VM_TABENTRY(nr_page_table_pages),
140 +       VM_TABENTRY(nr_pagecache),
141 +       VM_TABENTRY(nr_reverse_maps),
142 +       VM_TABENTRY(nr_slab),
143 +       VM_TABENTRY(nr_unstable),
144 +       VM_TABENTRY(nr_writeback),
145 +       VM_TABENTRY(pageoutrun),
146 +       VM_TABENTRY(pgactivate),
147 +       VM_TABENTRY(pgalloc),
148 +       VM_TABENTRY(pgalloc_dma),
149 +       VM_TABENTRY(pgalloc_high),
150 +       VM_TABENTRY(pgalloc_normal),
151 +       VM_TABENTRY(pgdeactivate),
152 +       VM_TABENTRY(pgfault),
153 +       VM_TABENTRY(pgfree),
154 +       VM_TABENTRY(pginodesteal),
155 +       VM_TABENTRY(pgmajfault),
156 +       VM_TABENTRY(pgpgin),
157 +       VM_TABENTRY(pgpgout),
158 +       VM_TABENTRY(pgrefill),
159 +       VM_TABENTRY(pgrefill_dma),
160 +       VM_TABENTRY(pgrefill_high),
161 +       VM_TABENTRY(pgrefill_normal),
162 +       VM_TABENTRY(pgrotated),
163 +       VM_TABENTRY(pgscan),
164 +       VM_TABENTRY(pgscan_direct_dma),
165 +       VM_TABENTRY(pgscan_direct_high),
166 +       VM_TABENTRY(pgscan_direct_normal),
167 +       VM_TABENTRY(pgscan_kswapd_dma),
168 +       VM_TABENTRY(pgscan_kswapd_high),
169 +       VM_TABENTRY(pgscan_kswapd_normal),
170 +       VM_TABENTRY(pgsteal),
171 +       VM_TABENTRY(pgsteal_dma),
172 +       VM_TABENTRY(pgsteal_high),
173 +       VM_TABENTRY(pgsteal_normal),
174 +       VM_TABENTRY(pswpin),
175 +       VM_TABENTRY(pswpout),
176 +       VM_TABENTRY(slabs_scanned)
177    };
178    const int vm_table_count = sizeof(vm_table)/sizeof(vm_table_struct);
179  
180 @@ -741,7 +744,10 @@
181      );
182      head = tail+1;
183      if(!found) goto nextline;
184 -    *(found->slot) = strtoul(head,&tail,10);
185 +    if (found->sz == sizeof(unsigned long long))
186 +           *((unsigned long long *) found->slot) = strtoull(head,&tail,10);
187 +    else
188 +           *((unsigned long *) found->slot) = strtoul(head,&tail,10);
189  nextline:
190  
191  //if(found) fprintf(stderr,"%s=%d\n",found->name,*(found->slot));
192 --- procps-3.2.7/vmstat.c.kzak  2006-08-04 10:52:38.000000000 +0200
193 +++ procps-3.2.7/vmstat.c       2006-08-04 12:05:49.000000000 +0200
194 @@ -180,7 +180,7 @@
195    unsigned int running,blocked,dummy_1,dummy_2;
196    jiff cpu_use[2], cpu_nic[2], cpu_sys[2], cpu_idl[2], cpu_iow[2], cpu_xxx[2], cpu_yyy[2], cpu_zzz[2];
197    jiff duse, dsys, didl, diow, dstl, Div, divo2;
198 -  unsigned long pgpgin[2], pgpgout[2], pswpin[2], pswpout[2];
199 +  unsigned long long pgpgin[2], pgpgout[2], pswpin[2], pswpout[2];
200    unsigned int intr[2], ctxt[2];
201    unsigned int sleep_half; 
202    unsigned long kb_per_page = sysconf(_SC_PAGESIZE) / 1024ul;
203 @@ -509,7 +509,7 @@
204  static void sum_format(void) {
205    unsigned int running, blocked, btime, processes;
206    jiff cpu_use, cpu_nic, cpu_sys, cpu_idl, cpu_iow, cpu_xxx, cpu_yyy, cpu_zzz;
207 -  unsigned long pgpgin, pgpgout, pswpin, pswpout;
208 +  unsigned long long pgpgin, pgpgout, pswpin, pswpout;
209    unsigned int intr, ctxt;
210  
211    meminfo();
212 @@ -539,10 +539,10 @@
213    printf("%13Lu IRQ cpu ticks\n", cpu_xxx);
214    printf("%13Lu softirq cpu ticks\n", cpu_yyy);
215    printf("%13Lu stolen cpu ticks\n", cpu_zzz);
216 -  printf("%13lu pages paged in\n", pgpgin);
217 -  printf("%13lu pages paged out\n", pgpgout);
218 -  printf("%13lu pages swapped in\n", pswpin);
219 -  printf("%13lu pages swapped out\n", pswpout);
220 +  printf("%13llu pages paged in\n", pgpgin);
221 +  printf("%13llu pages paged out\n", pgpgout);
222 +  printf("%13llu pages swapped in\n", pswpin);
223 +  printf("%13llu pages swapped out\n", pswpout);
224    printf("%13u interrupts\n", intr);
225    printf("%13u CPU context switches\n", ctxt);
226    printf("%13u boot time\n", btime);
227 @@ -554,7 +554,7 @@
228  static void fork_format(void) {
229    unsigned int running, blocked, btime, processes;
230    jiff cpu_use, cpu_nic, cpu_sys, cpu_idl, cpu_iow, cpu_xxx, cpu_yyy, cpu_zzz;
231 -  unsigned long pgpgin, pgpgout, pswpin, pswpout;
232 +  unsigned long long pgpgin, pgpgout, pswpin, pswpout;
233    unsigned int intr, ctxt;
234  
235    getstat(&cpu_use, &cpu_nic, &cpu_sys, &cpu_idl,