linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/page_alloc.c: improve allocation fast path
@ 2017-07-08  1:28 zbestahu
  2017-07-08 19:47 ` Mel Gorman
  0 siblings, 1 reply; 2+ messages in thread
From: zbestahu @ 2017-07-08  1:28 UTC (permalink / raw)
  To: akpm, vbabka, mgorman, mhocko, hannes, minchan; +Cc: linux-mm, Yue Hu

From: Yue Hu <huyue2@coolpad.com>

We currently is taking time to check if the watermark is safe when
alloc_flags is setting with ALLOC_NO_WATERMARK in slowpath, the check
to alloc_flags is faster check which should be first check option
compared to the slow check of watermark, it could benefit to urgency
allocation request in slowpath, it also almost has no effect for
allocation with successful watermark check.

Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
 mm/page_alloc.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 07efbc3..f1ba0e37 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3014,16 +3014,16 @@ static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone)
 			}
 		}
 
+		/* Checked here to keep the fast path fast */
+		BUILD_BUG_ON(ALLOC_NO_WATERMARKS < NR_WMARK);
+		if (alloc_flags & ALLOC_NO_WATERMARKS)
+			goto try_this_zone;
+
 		mark = zone->watermark[alloc_flags & ALLOC_WMARK_MASK];
 		if (!zone_watermark_fast(zone, order, mark,
 				       ac_classzone_idx(ac), alloc_flags)) {
 			int ret;
 
-			/* Checked here to keep the fast path fast */
-			BUILD_BUG_ON(ALLOC_NO_WATERMARKS < NR_WMARK);
-			if (alloc_flags & ALLOC_NO_WATERMARKS)
-				goto try_this_zone;
-
 			if (node_reclaim_mode == 0 ||
 			    !zone_allows_reclaim(ac->preferred_zoneref->zone, zone))
 				continue;
-- 
1.7.10.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/page_alloc.c: improve allocation fast path
  2017-07-08  1:28 [PATCH] mm/page_alloc.c: improve allocation fast path zbestahu
@ 2017-07-08 19:47 ` Mel Gorman
  0 siblings, 0 replies; 2+ messages in thread
From: Mel Gorman @ 2017-07-08 19:47 UTC (permalink / raw)
  To: zbestahu; +Cc: akpm, vbabka, mhocko, hannes, minchan, linux-mm, Yue Hu

On Sat, Jul 08, 2017 at 09:28:39AM +0800, zbestahu@aliyun.com wrote:
> From: Yue Hu <huyue2@coolpad.com>
> 
> We currently is taking time to check if the watermark is safe when
> alloc_flags is setting with ALLOC_NO_WATERMARK in slowpath, the check
> to alloc_flags is faster check which should be first check option
> compared to the slow check of watermark, it could benefit to urgency
> allocation request in slowpath, it also almost has no effect for
> allocation with successful watermark check.
> 
> Signed-off-by: Yue Hu <huyue2@coolpad.com>

NAK. Was this measured as being a benefit to anything?

ALLOC_NO_WATERMARKS is rare so it's in the slow path. Even though the
watermark check is redundent when watermarks should be ignored, your patch
adds a branch that is rarely true to the common case. The comment you move
even gives a hint as to why it's located there!

-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2017-07-08 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-08  1:28 [PATCH] mm/page_alloc.c: improve allocation fast path zbestahu
2017-07-08 19:47 ` Mel Gorman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).