* [PATCH] drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop.
@ 2011-10-17 18:13 Rakib Mullick
2011-10-17 18:36 ` Dmitry Torokhov
2011-10-17 19:31 ` David Rientjes
0 siblings, 2 replies; 5+ messages in thread
From: Rakib Mullick @ 2011-10-17 18:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Andrew Morton, Dmitry Torokhov
In vmballoon_reserve_page function, flags has been passed from the callee function (vmballoon_inflate here). So, we can determine can_sleep outside the loop.
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..6983d80 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -412,6 +412,7 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
gfp_t flags;
unsigned int hv_status;
bool locked = false;
+ flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
do {
if (!can_sleep)
@@ -419,7 +420,6 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
else
STATS_INC(b->stats.sleep_alloc);
- flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
page = alloc_page(flags);
if (!page) {
if (!can_sleep)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop.
2011-10-17 18:13 [PATCH] drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop Rakib Mullick
@ 2011-10-17 18:36 ` Dmitry Torokhov
2011-10-17 19:31 ` David Rientjes
1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2011-10-17 18:36 UTC (permalink / raw)
To: Rakib Mullick; +Cc: linux-kernel, Andrew Morton
On Monday, October 17, 2011 11:13:47 AM Rakib Mullick wrote:
> In vmballoon_reserve_page function, flags has been passed from the
> callee function (vmballoon_inflate here). So, we can determine
> can_sleep outside the loop.
>
> Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
Thanks Rakib.
Acked-by: Dmitry Torokhov <dtor@vmware.com>
> ---
>
> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> index 053d36c..6983d80 100644
> --- a/drivers/misc/vmw_balloon.c
> +++ b/drivers/misc/vmw_balloon.c
> @@ -412,6 +412,7 @@ static int vmballoon_reserve_page(struct vmballoon
> *b, bool can_sleep) gfp_t flags;
> unsigned int hv_status;
> bool locked = false;
> + flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
>
> do {
> if (!can_sleep)
> @@ -419,7 +420,6 @@ static int vmballoon_reserve_page(struct vmballoon
> *b, bool can_sleep) else
> STATS_INC(b->stats.sleep_alloc);
>
> - flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP :
VMW_PAGE_ALLOC_NOSLEEP;
> page = alloc_page(flags);
> if (!page) {
> if (!can_sleep)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop.
2011-10-17 18:13 [PATCH] drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop Rakib Mullick
2011-10-17 18:36 ` Dmitry Torokhov
@ 2011-10-17 19:31 ` David Rientjes
2011-10-17 20:10 ` Rakib Mullick
1 sibling, 1 reply; 5+ messages in thread
From: David Rientjes @ 2011-10-17 19:31 UTC (permalink / raw)
To: Rakib Mullick; +Cc: linux-kernel, Andrew Morton, Dmitry Torokhov
On Tue, 18 Oct 2011, Rakib Mullick wrote:
> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> index 053d36c..6983d80 100644
> --- a/drivers/misc/vmw_balloon.c
> +++ b/drivers/misc/vmw_balloon.c
> @@ -412,6 +412,7 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
> gfp_t flags;
> unsigned int hv_status;
> bool locked = false;
> + flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
>
> do {
> if (!can_sleep)
Should be folded in with the declaration of gfp_t flags.
Would you also like to add a might_sleep_if(can_sleep) here?
> @@ -419,7 +420,6 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
> else
> STATS_INC(b->stats.sleep_alloc);
>
> - flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
> page = alloc_page(flags);
> if (!page) {
> if (!can_sleep)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop.
2011-10-17 19:31 ` David Rientjes
@ 2011-10-17 20:10 ` Rakib Mullick
2011-10-17 20:16 ` Dmitry Torokhov
0 siblings, 1 reply; 5+ messages in thread
From: Rakib Mullick @ 2011-10-17 20:10 UTC (permalink / raw)
To: David Rientjes; +Cc: linux-kernel, Andrew Morton, Dmitry Torokhov
On Tue, Oct 18, 2011 at 1:31 AM, David Rientjes <rientjes@google.com> wrote:
> On Tue, 18 Oct 2011, Rakib Mullick wrote:
>
>> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
>> index 053d36c..6983d80 100644
>> --- a/drivers/misc/vmw_balloon.c
>> +++ b/drivers/misc/vmw_balloon.c
>> @@ -412,6 +412,7 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
>> gfp_t flags;
>> unsigned int hv_status;
>> bool locked = false;
>> + flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
>>
>> do {
>> if (!can_sleep)
>
> Should be folded in with the declaration of gfp_t flags.
>
> Would you also like to add a might_sleep_if(can_sleep) here?
>
I'm not sure. But, I don't think it's needed here. can_sleep tells
whether alloc_page can sleep or not, which has been determined and
passed by the callee function.
Thanks,
Rakib
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop.
2011-10-17 20:10 ` Rakib Mullick
@ 2011-10-17 20:16 ` Dmitry Torokhov
0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2011-10-17 20:16 UTC (permalink / raw)
To: Rakib Mullick; +Cc: David Rientjes, linux-kernel, Andrew Morton
On Monday, October 17, 2011 01:10:38 PM Rakib Mullick wrote:
> On Tue, Oct 18, 2011 at 1:31 AM, David Rientjes <rientjes@google.com>
wrote:
> > On Tue, 18 Oct 2011, Rakib Mullick wrote:
> >> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> >> index 053d36c..6983d80 100644
> >> --- a/drivers/misc/vmw_balloon.c
> >> +++ b/drivers/misc/vmw_balloon.c
> >> @@ -412,6 +412,7 @@ static int vmballoon_reserve_page(struct
> >> vmballoon *b, bool can_sleep) gfp_t flags;
> >> unsigned int hv_status;
> >> bool locked = false;
> >> + flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP :
> >> VMW_PAGE_ALLOC_NOSLEEP;
> >>
> >> do {
> >> if (!can_sleep)
> >
> > Should be folded in with the declaration of gfp_t flags.
> >
> > Would you also like to add a might_sleep_if(can_sleep) here?
>
> I'm not sure. But, I don't think it's needed here. can_sleep tells
> whether alloc_page can sleep or not, which has been determined and
> passed by the callee function.
>
vmballon_reserve_page() is always called from workqueue context and
thus is always allowed to sleep. I do not see the benefit of adding
might_sleep() here.
Thanks,
Dmitry
>
> Thanks,
> Rakib
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-10-17 20:16 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:13 [PATCH] drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop Rakib Mullick
2011-10-17 18:36 ` Dmitry Torokhov
2011-10-17 19:31 ` David Rientjes
2011-10-17 20:10 ` Rakib Mullick
2011-10-17 20:16 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox