bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] utils/vmstat: Be less aggressive about switching to bigger units


From: olafBuddenhagen
Subject: [PATCH] utils/vmstat: Be less aggressive about switching to bigger units
Date: Sat, 23 Jul 2011 01:50:16 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

>From 69bcde9dc1f2b4450122f87072cc1e3c471e5f26 Mon Sep 17 00:00:00 2001
From: Olaf Buddenhagen <antrik@users.sourceforge.net>
Date: Sat, 23 Jul 2011 01:13:05 +0200
Subject: [PATCH] utils/vmstat: Be less aggressive about switching to bigger 
units

Instead of switching to the next bigger unit as soon as the value
exceeds 1024, do so only when it gets larger than four digits.
---

After resizing my swap partition to be > 1024 MiB, I observed with
dismay that now vmstat started to report the swap free size as 1.xxG --
meaning I get less precision (10.24 MiB instead of 1 MiB); and also
meaning it now uses a different unit than the other memory-related
fields, which are still in MiB. This makes the vmstat output
considerably less useful -- and there is no good reason for using GiB
here: as long as the value fits in four digits, sticking to MiB doesn't
increase the field size, or make the output less readable.

This trivial patch "fixes" the issue.

(Considering that the patch is trivial, I'm not sure the copyright year
change is appropriate BTW...)

 utils/vmstat.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/vmstat.c b/utils/vmstat.c
index 86494dc..90aac6b 100644
--- a/utils/vmstat.c
+++ b/utils/vmstat.c
@@ -1,6 +1,6 @@
 /* Print vm statistics
 
-   Copyright (C) 1996,97,99,2002 Free Software Foundation, Inc.
+   Copyright (C) 1996,97,99,2002,2011 Free Software Foundation, Inc.
    Written by Miles Bader <miles@gnu.org>
 
    This program is free software; you can redistribute it and/or
@@ -111,7 +111,7 @@ print_val (val_t val, enum val_type type,
       float fval = val;
       char *units = " KMGT", *u = units;
 
-      while (fval > 1024)
+      while (fval >= 10000)
        {
          fval /= 1024;
          u++;
-- 
1.7.5.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]