From: Rakib Mullick <rakib.mullick@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: akpm@linux-foundation.org, Dmitry Torokhov <dtor@vmware.com>
Subject: [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds.
Date: Tue, 18 Oct 2011 00:57:31 +0600 [thread overview]
Message-ID: <1318877852.10091.11.camel@localhost.localdomain> (raw)
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 */
next reply other threads:[~2011-10-17 18:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-17 18:57 Rakib Mullick [this message]
2011-10-17 19:35 ` [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds David Rientjes
2011-10-17 19:45 ` Dmitry Torokhov
2011-10-17 20:17 ` Rakib Mullick
2011-10-17 20:25 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1318877852.10091.11.camel@localhost.localdomain \
--to=rakib.mullick@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dtor@vmware.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox