drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop.
Subsystems (2)
PATCH 1/1 drivers, vmw_balloon.c: Determine page allocation flag can_sleep outside loop.
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.
---
drivers/misc/vmw_balloon.c +1 -1
@@ -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)
Quoted 5 lines · Rakib Mullick
In
vmballoon_reserve_pagefunction, flags has been passed from the
callee function (vmballoon_inflatehere). So, we can determinecan_sleepoutside the loop.Signed-off-by Rakib Mullick <[email protected]>
Thanks Rakib.
Quoted 15 lines
---
drivers/misc/vmw_balloon.c +1
-0@@ -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)
drivers/misc/vmw_balloon.c static int vmballoon_reserve_page(struct vmballoon · line 422
Quoted 4 lines
drivers/misc/vmw_balloon.c +0
-1@@ -419,7 +420,6 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep) elseSTATS_INC (b->stats.sleep_alloc); - flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP :
VMW_PAGE_ALLOC_NOSLEEP;
Quoted 3 lines
drivers/misc/vmw_balloon.c +0
-0page =alloc_page (flags);if (!page) {if (!can_sleep)
drivers/misc/vmw_balloon.c static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep) · line 418
Quoted 12 lines · Rakib Mullick
drivers/misc/vmw_balloon.c +1
-0@@ -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?
Quoted 8 lines
drivers/misc/vmw_balloon.c +0
-1@@ -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)
Quoted 12 lines · David Rientjes
Quoted 10 lines · Rakib Mullick
drivers/misc/vmw_balloon.c +1
-0@@ -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;
Quoted 7 lines
drivers/misc/vmw_balloon.c static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep) · line 418
Quoted 2 lines
drivers/misc/vmw_balloon.c +0
-0do { if (!can_sleep)Should be folded in with the declaration of
gfp_tflags.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
Quoted 1 line · Rakib Mullick
On Tue, Oct 18, 2011 at 1:31 AM, David Rientjes <[email protected]>
Quoted 17 lines · wrote:
Quoted 17 lines · Rakib Mullick
Quoted 12 lines
drivers/misc/vmw_balloon.c +1
-0@@ -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 {Quoted 1 line
if (!can_sleep)Should be folded in with the declaration of
gfp_tflags.
Quoted 6 lines
Quoted 1 line
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_sleeptells whetheralloc_pagecan 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
Quoted 3 lines
Thanks,
Rakib