lkml.org 
[lkml]   [2011]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds.
From
Date
 While doing allocation statistics in vmballoon_reserve_page function, alloc and sleep_alloc has been incremented even if allocation fails. But, b->stats.alloc and b->stats.sleep_alloc supposed to increment only when they succeed. This patch makes sure that, alloc and sleep_alloc gets incremented when page allocation succeeds.

Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
---

diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 053d36c..d2c25c9 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -414,11 +414,6 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
bool locked = false;

do {
- if (!can_sleep)
- STATS_INC(b->stats.alloc);
- else
- STATS_INC(b->stats.sleep_alloc);
-
flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
page = alloc_page(flags);
if (!page) {
@@ -427,6 +422,11 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
else
STATS_INC(b->stats.sleep_alloc_fail);
return -ENOMEM;
+ } else {
+ if (!can_sleep)
+ STATS_INC(b->stats.alloc);
+ else
+ STATS_INC(b->stats.sleep_alloc);
}

/* inform monitor */



\
 
 \ /
  Last update: 2011-10-17 20:59    [W:0.045 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site