mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm/page_alloc:add a missing mm_page_alloc_zone_locked tracepoint
@ 2020-12-28 13:29 Hailong liu
  2020-12-29 21:23 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Hailong liu @ 2020-12-28 13:29 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, liu.hailong6

From: Hailong liu <liu.hailong6@zte.com.cn>

The trace point *trace_mm_page_alloc_zone_locked()* in __rmqueue() does not
currently cover all branches. Add the missing tracepoint and check the page
before do that.

Signed-off-by: Hailong liu <liu.hailong6@zte.com.cn>
---
 mm/page_alloc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 7a2c89b21115..8cfa58bcf21a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2871,7 +2871,7 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype,
 	    zone_page_state(zone, NR_FREE_PAGES) / 2) {
 		page = __rmqueue_cma_fallback(zone, order);
 		if (page)
-			return page;
+			goto out;
 	}
 #endif
 retry:
@@ -2884,8 +2884,9 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype,
 								alloc_flags))
 			goto retry;
 	}
-
-	trace_mm_page_alloc_zone_locked(page, order, migratetype);
+out:
+	if (page)
+		trace_mm_page_alloc_zone_locked(page, order, migratetype);
 	return page;
 }
 
-- 
2.17.1



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

* Re: [PATCH] mm/page_alloc:add a missing mm_page_alloc_zone_locked tracepoint
  2020-12-28 13:29 [PATCH] mm/page_alloc:add a missing mm_page_alloc_zone_locked tracepoint Hailong liu
@ 2020-12-29 21:23 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2020-12-29 21:23 UTC (permalink / raw)
  To: Hailong liu; +Cc: linux-mm, linux-kernel, liu.hailong6

On Mon, 28 Dec 2020 21:29:01 +0800 Hailong liu <carver4lio@163.com> wrote:

> The trace point *trace_mm_page_alloc_zone_locked()* in __rmqueue() does not
> currently cover all branches. Add the missing tracepoint and check the page
> before do that.
> 
> ...
>
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2871,7 +2871,7 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype,
>  	    zone_page_state(zone, NR_FREE_PAGES) / 2) {
>  		page = __rmqueue_cma_fallback(zone, order);
>  		if (page)
> -			return page;
> +			goto out;
>  	}
>  #endif
>  retry:
> @@ -2884,8 +2884,9 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype,
>  								alloc_flags))
>  			goto retry;
>  	}
> -
> -	trace_mm_page_alloc_zone_locked(page, order, migratetype);
> +out:
> +	if (page)
> +		trace_mm_page_alloc_zone_locked(page, order, migratetype);
>  	return page;
>  }

Looks right to me, but it generates a warning.  Using IS_ENABLED()
works around it.



From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm-page_alloc-add-a-missing-mm_page_alloc_zone_locked-tracepoint-fix

use IS_ENABLED() to suppress warning

mm/page_alloc.c: In function ‘__rmqueue’:
mm/page_alloc.c:2889:1: warning: label ‘out’ defined but not used [-Wunused-label]
 out:
 ^~~

Cc: Hailong liu <liu.hailong6@zte.com.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/page_alloc.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

--- a/mm/page_alloc.c~mm-page_alloc-add-a-missing-mm_page_alloc_zone_locked-tracepoint-fix
+++ a/mm/page_alloc.c
@@ -2862,20 +2862,20 @@ __rmqueue(struct zone *zone, unsigned in
 {
 	struct page *page;
 
-#ifdef CONFIG_CMA
-	/*
-	 * Balance movable allocations between regular and CMA areas by
-	 * allocating from CMA when over half of the zone's free memory
-	 * is in the CMA area.
-	 */
-	if (alloc_flags & ALLOC_CMA &&
-	    zone_page_state(zone, NR_FREE_CMA_PAGES) >
-	    zone_page_state(zone, NR_FREE_PAGES) / 2) {
-		page = __rmqueue_cma_fallback(zone, order);
-		if (page)
-			goto out;
+	if (IS_ENABLED(CONFIG_CMA)) {
+		/*
+		 * Balance movable allocations between regular and CMA areas by
+		 * allocating from CMA when over half of the zone's free memory
+		 * is in the CMA area.
+		 */
+		if (alloc_flags & ALLOC_CMA &&
+		    zone_page_state(zone, NR_FREE_CMA_PAGES) >
+		    zone_page_state(zone, NR_FREE_PAGES) / 2) {
+			page = __rmqueue_cma_fallback(zone, order);
+			if (page)
+				goto out;
+		}
 	}
-#endif
 retry:
 	page = __rmqueue_smallest(zone, order, migratetype);
 	if (unlikely(!page)) {
_


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

end of thread, other threads:[~2020-12-29 21:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 13:29 [PATCH] mm/page_alloc:add a missing mm_page_alloc_zone_locked tracepoint Hailong liu
2020-12-29 21:23 ` Andrew Morton

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

all inboxes | Powered by JetHome®