From 40de1c9c7cdcba7bad760a00c702935ce3b3095b Mon Sep 17 00:00:00 2001 From: Craig Small Date: Mon, 25 Apr 2016 20:24:20 +1000 Subject: [PATCH] library: fix order of operations for %use of slabinfo In some environments, 100 * nr_active_objs is calculated at first, and lower 32bit of the result is divided by nr_objs. If 100 * nr_active_objs > 42949672, %use will be incorrect. Reported by Takayuki Nagata and adopted his patch for new library (see reference) References: commit 99d71ad5810b8fbfab5c4c6be97f3e86953b6157 http://www.freelists.org/post/procps/PATCH-bprocps-fix-order-of-operations-for-use-of-slabinfo --- proc/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proc/slab.c b/proc/slab.c index 2a3c5f7d..a3c5dca6 100644 --- a/proc/slab.c +++ b/proc/slab.c @@ -231,7 +231,7 @@ static int parse_slabinfo20 ( * page_size; if (node->nr_objs) { - node->use = (unsigned int)100 * node->nr_active_objs / node->nr_objs; + node->use = (unsigned int)100 * (node->nr_active_objs / node->nr_objs); stats->nr_active_caches++; } else node->use = 0;