[Crash-utility] [PATCH] Fix for swap used percentage reporting when totalswap_pages is 0.

Dave Anderson anderson at redhat.com
Wed Aug 17 18:52:00 UTC 2016



Hi John,

Queued for crash-7.1.6:

  https://github.com/crash-utility/crash/commit/004218c50f3cad008ec924c1c00d8b9444998464

Thanks,
  Dave


----- Original Message -----
> Without the patch, when totalswap_pages is 0, swap used percentage
> reports as 100%. This is confusing on first glance as it seems to
> indicate potential memory pressure. Fix this and also fix indentation on
> 'pct' calculations to improve readability.
> ---
>  memory.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/memory.c b/memory.c
> index e994d13..f39c667 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -8302,12 +8302,12 @@ dump_kmeminfo(void)
>  			fprintf(fp, "%13s  %7ld  %11s         ----\n",
>  				"TOTAL SWAP", totalswap_pages,
>  				pages_to_size(totalswap_pages, buf));
> -				pct = totalswap_pages ? (totalused_pages * 100) /
> -				totalswap_pages : 100;
> +			pct = totalswap_pages ? (totalused_pages * 100) /
> +				totalswap_pages : 0;
>  			fprintf(fp, "%13s  %7ld  %11s  %3ld%% of TOTAL SWAP\n",
>  				"SWAP USED", totalused_pages,
>  				pages_to_size(totalused_pages, buf), pct);
> -		 		pct = totalswap_pages ?
> +	 		pct = totalswap_pages ?
>  				((totalswap_pages - totalused_pages) *
>  				100) / totalswap_pages : 0;
>  			fprintf(fp, "%13s  %7ld  %11s  %3ld%% of TOTAL SWAP\n",
> --
> 2.7.4
> 
> --
> Crash-utility mailing list
> Crash-utility at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
> 




More information about the Crash-utility mailing list