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 <tnagata@redhat.com> and adopted
his patch for new library (see reference)
References:
commit 99d71ad581
http://www.freelists.org/post/procps/PATCH-bprocps-fix-order-of-operations-for-use-of-slabinfo
This commit is contained in:
parent
9c877bf636
commit
40de1c9c7c
@ -231,7 +231,7 @@ static int parse_slabinfo20 (
|
|||||||
* page_size;
|
* page_size;
|
||||||
|
|
||||||
if (node->nr_objs) {
|
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++;
|
stats->nr_active_caches++;
|
||||||
} else
|
} else
|
||||||
node->use = 0;
|
node->use = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user