public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds.
@ 2011-10-17 18:57 Rakib Mullick
  2011-10-17 19:35 ` David Rientjes
  0 siblings, 1 reply; 5+ messages in thread
From: Rakib Mullick @ 2011-10-17 18:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Dmitry Torokhov

 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 */



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds.
  2011-10-17 18:57 [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds Rakib Mullick
@ 2011-10-17 19:35 ` David Rientjes
  2011-10-17 19:45   ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2011-10-17 19:35 UTC (permalink / raw)
  To: Rakib Mullick; +Cc: linux-kernel, akpm, Dmitry Torokhov

On Tue, 18 Oct 2011, Rakib Mullick wrote:

>  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.
> 

Dmitry could say for sure, but this seems to actually change the 
semantics.  If the allocations fail, it increments alloc_fail and 
sleep_alloc_fail accordingly so you could easily see 10 alloc and 5 
alloc_fail.  With your patch, it would be 5 alloc and 5 alloc_fail.

I don't know which one is best, but I would opt to stay with the semantics 
that alloc and sleep_alloc have already had rather than changing them.

> 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 */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds.
  2011-10-17 19:35 ` David Rientjes
@ 2011-10-17 19:45   ` Dmitry Torokhov
  2011-10-17 20:17     ` Rakib Mullick
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2011-10-17 19:45 UTC (permalink / raw)
  To: David Rientjes; +Cc: Rakib Mullick, linux-kernel, akpm

On Monday, October 17, 2011 12:35:34 PM David Rientjes wrote:
> On Tue, 18 Oct 2011, Rakib Mullick wrote:
> >  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.
> 
> Dmitry could say for sure, but this seems to actually change the
> semantics.  If the allocations fail, it increments alloc_fail and
> sleep_alloc_fail accordingly so you could easily see 10 alloc and 5
> alloc_fail.  With your patch, it would be 5 alloc and 5 alloc_fail.
> 
> I don't know which one is best, but I would opt to stay with the
> semantics that alloc and sleep_alloc have already had rather than
> changing them.

Right, b->stats.alloc and b->stats.sleep_alloc show number of allocation
attempts and alloc_fail and sleep_alloc_fail show how many of these
attempts failed. This behavior matches behavior of the driver we have
been shipping out of the tree for many years and I would prefer to keep
it as is.

Thanks,
Dmitry


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds.
  2011-10-17 19:45   ` Dmitry Torokhov
@ 2011-10-17 20:17     ` Rakib Mullick
  2011-10-17 20:25       ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Rakib Mullick @ 2011-10-17 20:17 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: David Rientjes, linux-kernel, akpm

On Tue, Oct 18, 2011 at 1:45 AM, Dmitry Torokhov <dtor@vmware.com> wrote:
> On Monday, October 17, 2011 12:35:34 PM David Rientjes wrote:
>> On Tue, 18 Oct 2011, Rakib Mullick wrote:
>> >  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.
>>
>> Dmitry could say for sure, but this seems to actually change the
>> semantics.  If the allocations fail, it increments alloc_fail and
>> sleep_alloc_fail accordingly so you could easily see 10 alloc and 5
>> alloc_fail.  With your patch, it would be 5 alloc and 5 alloc_fail.
>>
>> I don't know which one is best, but I would opt to stay with the
>> semantics that alloc and sleep_alloc have already had rather than
>> changing them.
>
> Right, b->stats.alloc and b->stats.sleep_alloc show number of allocation
> attempts and alloc_fail and sleep_alloc_fail show how many of these
> attempts failed. This behavior matches behavior of the driver we have
> been shipping out of the tree for many years and I would prefer to keep
> it as is.
>
Then why b->stats.alloc and b->stats.sleep_alloc are not renamed as
b->stats.alloc_attempted and b->stats.sleep_alloc_attempted
respectively. Current naming is confusing, anyone looking at the alloc
and sleep_alloc stat would easily think that, if 10 alloc and 5
alloc_fail then 10 has been allocated and 5 times has been allocation
fails. Isn't it?

Thanks,
Rakib

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds.
  2011-10-17 20:17     ` Rakib Mullick
@ 2011-10-17 20:25       ` Dmitry Torokhov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2011-10-17 20:25 UTC (permalink / raw)
  To: Rakib Mullick; +Cc: David Rientjes, linux-kernel, akpm

On Monday, October 17, 2011 01:17:02 PM Rakib Mullick wrote:
> On Tue, Oct 18, 2011 at 1:45 AM, Dmitry Torokhov <dtor@vmware.com> wrote:
> > On Monday, October 17, 2011 12:35:34 PM David Rientjes wrote:
> >> On Tue, 18 Oct 2011, Rakib Mullick wrote:
> >> >  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.
> >> 
> >> Dmitry could say for sure, but this seems to actually change the
> >> semantics.  If the allocations fail, it increments alloc_fail and
> >> sleep_alloc_fail accordingly so you could easily see 10 alloc and 5
> >> alloc_fail.  With your patch, it would be 5 alloc and 5 alloc_fail.
> >> 
> >> I don't know which one is best, but I would opt to stay with the
> >> semantics that alloc and sleep_alloc have already had rather than
> >> changing them.
> > 
> > Right, b->stats.alloc and b->stats.sleep_alloc show number of
> > allocation attempts and alloc_fail and sleep_alloc_fail show how many
> > of these attempts failed. This behavior matches behavior of the
> > driver we have been shipping out of the tree for many years and I
> > would prefer to keep it as is.
> 
> Then why b->stats.alloc and b->stats.sleep_alloc are not renamed as
> b->stats.alloc_attempted and b->stats.sleep_alloc_attempted
> respectively. Current naming is confusing, anyone looking at the alloc
> and sleep_alloc stat would easily think that, if 10 alloc and 5
> alloc_fail then 10 has been allocated and 5 times has been allocation
> fails. Isn't it?

I'd give you this point if they were named alloc_succeeded and
sleep_alloc_succeeded... but they are not.

Thanks,
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-17 20:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-17 18:57 [PATCH] drivers, vmw_balloon.c: Increment alloc and sleep_alloc only when page allocation succeeds Rakib Mullick
2011-10-17 19:35 ` David Rientjes
2011-10-17 19:45   ` Dmitry Torokhov
2011-10-17 20:17     ` Rakib Mullick
2011-10-17 20:25       ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox