53 lines
1.9 KiB
Diff
53 lines
1.9 KiB
Diff
--- proc/sysinfo.c
|
|
+++ proc/sysinfo.c 2015-01-27 15:04:57.337518882 +0000
|
|
@@ -708,8 +708,14 @@ nextline:
|
|
kb_main_cached = kb_page_cache + kb_slab;
|
|
if ((ev=getenv("PS_FULL_CACHE")))
|
|
kb_main_cached += kb_slab_reclaimable + kb_swap_cached + kb_nfs_unstable;
|
|
- kb_swap_used = kb_swap_total - kb_swap_free;
|
|
- kb_main_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers;
|
|
+ if (kb_swap_total > kb_swap_free)
|
|
+ kb_swap_used = kb_swap_total - kb_swap_free;
|
|
+ else
|
|
+ kb_swap_used = 0;
|
|
+ if (kb_main_total > kb_main_free + kb_main_cached + kb_main_buffers)
|
|
+ kb_main_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers;
|
|
+ else
|
|
+ kb_main_used = 0;
|
|
|
|
/* zero? might need fallback for 2.6.27 <= kernel <? 3.14 */
|
|
if (!kb_main_available) {
|
|
--- free.c
|
|
+++ free.c 2015-01-27 15:07:36.725518136 +0000
|
|
@@ -327,15 +327,28 @@ int main(int argc, char **argv)
|
|
* to print the high info, even if it is zero.
|
|
*/
|
|
if (flags & FREE_LOHI) {
|
|
+ unsigned long kb_low_used;
|
|
+ unsigned long kb_high_used;
|
|
+
|
|
+ if (kb_low_total > kb_low_free)
|
|
+ kb_low_used = kb_low_total - kb_low_free;
|
|
+ else
|
|
+ kb_low_used = 0;
|
|
+
|
|
+ if (kb_high_total > kb_high_free)
|
|
+ kb_high_used = kb_high_total - kb_high_free;
|
|
+ else
|
|
+ kb_high_used = 0;
|
|
+
|
|
printf("%-7s", _("Low:"));
|
|
printf(" %11s", scale_size(kb_low_total, flags, args));
|
|
- printf(" %11s", scale_size(kb_low_total - kb_low_free, flags, args));
|
|
+ printf(" %11s", scale_size(kb_low_used, flags, args));
|
|
printf(" %11s", scale_size(kb_low_free, flags, args));
|
|
printf("\n");
|
|
|
|
printf("%-7s", _("High:"));
|
|
printf(" %11s", scale_size(kb_high_total, flags, args));
|
|
- printf(" %11s", scale_size(kb_high_total - kb_high_free, flags, args));
|
|
+ printf(" %11s", scale_size(kb_high_used, flags, args));
|
|
printf(" %11s", scale_size(kb_high_free, flags, args));
|
|
printf("\n");
|
|
}
|